Fix css on live search, live search now works
This commit is contained in:
parent
2dd20ac85a
commit
f1fb73beec
|
@ -138,25 +138,42 @@ class ContactController extends Controller
|
||||||
|
|
||||||
public function search(Request $request){
|
public function search(Request $request){
|
||||||
if($request->ajax()){
|
if($request->ajax()){
|
||||||
$output = "";
|
$output = "<tr>".
|
||||||
$users = DB::table('users')->where('name_first', 'LIKE',$request->search.'%')
|
"<th>Kontakt Navn</th>".
|
||||||
|
"<th>Titel</th>".
|
||||||
|
"<th>E-mail</th>".
|
||||||
|
"<th>Tlf</th>".
|
||||||
|
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/pencil.svg\" alt=\"Update\"></th>".
|
||||||
|
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>".
|
||||||
|
"</tr>";
|
||||||
|
$users = DB::table('contacts')->where('name_first', 'LIKE',$request->search.'%')
|
||||||
->orWhere('name_last','LIKE', $request->search.'%')
|
->orWhere('name_last','LIKE', $request->search.'%')
|
||||||
->orWhere('phone','LIKE', $request->search.'%')
|
->orWhere('phone','LIKE', $request->search.'%')
|
||||||
->orWhere('email','LIKE',$request->search. '%')->get();
|
->orWhere('email','LIKE',$request->search. '%')->get();
|
||||||
|
|
||||||
if($users){
|
if(count($users) !== 0){
|
||||||
foreach ($users as $key => $user){
|
foreach ($users as $key => $user){
|
||||||
$output.='<tr>'.
|
$output.='<tr>'.
|
||||||
'<td>' . $user->name_first . '</td>'.
|
'<td>' . $user->name_first . '</td>'.
|
||||||
'<td>' . $user->name_last . '</td>'.
|
'<td>' . $user->name_last . '</td>'.
|
||||||
'<td>' . $user->email . '</td>'.
|
'<td>' . $user->email . '</td>'.
|
||||||
'<td>' . $user->phone .'</td>'.
|
'<td>' . $user->phone .'</td>'.
|
||||||
|
'<td><a href="'. route("contacts.edit", [ "contact" => $user->id ]) . '"><img class="w-100" src="'. asset('/images/icons/pencil-dark.svg') . '" alt="Update"></a></td>'.
|
||||||
|
'<td><form method="post" action="' .route("contacts.destroy", [ "contact" => $user->id ]). '" class="w-100 nostyle">'.
|
||||||
|
csrf_field().
|
||||||
|
method_field("delete").
|
||||||
|
|
||||||
|
'<button class="w-100 nostyle" onclick="return confirm(\'Are you sure you want to delete?\');" type="submit"><img class="w-100 cursor-pointer" src="'. asset('/images/icons/trashcan-dark.svg') . '" alt="Delete"></button>'.
|
||||||
|
'</form>'.
|
||||||
|
'</td>'.
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$output.= "</tbody></table><h1>Der er ingen resultater...</h1>";
|
||||||
|
}
|
||||||
return Response($output);
|
return Response($output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6628,6 +6628,11 @@ main {
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#search {
|
||||||
|
margin-bottom: 0;
|
||||||
|
line-height: 2.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
.directorypath {
|
.directorypath {
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
background-color: #333333;
|
background-color: #333333;
|
||||||
|
|
|
@ -47,3 +47,8 @@
|
||||||
height: 1em;
|
height: 1em;
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#search {
|
||||||
|
margin-bottom: 0;
|
||||||
|
line-height: 2.3rem;
|
||||||
|
}
|
||||||
|
|
|
@ -58,8 +58,7 @@
|
||||||
data: {'search':$value},
|
data: {'search':$value},
|
||||||
success:function (data) {
|
success:function (data) {
|
||||||
$('tbody').html(data);
|
$('tbody').html(data);
|
||||||
console.log(data);
|
console.log(data)
|
||||||
console.log($value)
|
|
||||||
},
|
},
|
||||||
error:function (data) {
|
error:function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
Loading…
Reference in New Issue