Fix css on live search, live search now works

This commit is contained in:
victor 2020-07-27 14:03:57 +02:00
parent 2dd20ac85a
commit f1fb73beec
4 changed files with 32 additions and 6 deletions

View File

@ -138,23 +138,40 @@ class ContactController extends Controller
public function search(Request $request){
if($request->ajax()){
$output = "";
$users = DB::table('users')->where('name_first', 'LIKE',$request->search.'%')
$output = "<tr>".
"<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('phone','LIKE', $request->search.'%')
->orWhere('email','LIKE',$request->search. '%')->get();
if($users){
if(count($users) !== 0){
foreach ($users as $key => $user){
$output.='<tr>'.
'<td>' . $user->name_first . '</td>'.
'<td>' . $user->name_last . '</td>'.
'<td>' . $user->email . '</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>';
}
return Response($output);
}else{
$output.= "</tbody></table><h1>Der er ingen resultater...</h1>";
}
return Response($output);
}
}

View File

@ -6628,6 +6628,11 @@ main {
margin-right: 4px;
}
#search {
margin-bottom: 0;
line-height: 2.3rem;
}
.directorypath {
border-radius: 2px;
background-color: #333333;

View File

@ -47,3 +47,8 @@
height: 1em;
margin-right: 4px;
}
#search {
margin-bottom: 0;
line-height: 2.3rem;
}

View File

@ -58,8 +58,7 @@
data: {'search':$value},
success:function (data) {
$('tbody').html(data);
console.log(data);
console.log($value)
console.log(data)
},
error:function (data) {
console.log(data);