Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

203 create a member page #204

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
/**
* Returns all existing users
*/
public function showAll()
{
$users = User::all();

return view('members', ['users' => $users]);
}

/**
* Searches for a specific user
*/
public function search(Request $request)
{
$query = $request->query('namesearch');
$result = User::where('name', 'LIKE', '%'.$query.'%')->get();

return view('results', ['users' => $result]);
}
}
3 changes: 0 additions & 3 deletions resources/views/components/userpage.blade.php

This file was deleted.

26 changes: 26 additions & 0 deletions resources/views/members.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

<x-app-layout>
<x-slot name="header">
<div class="container w-full">
<form class="w-60 flex flex-row" method="GET" action="{{ route('search') }}">
<input type="search" name="namesearch" id="default-search" class="block w-48 p-2 pl-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50" placeholder="Type any name..." required>
<x-secondary-button class="mx-2" type="submit">rechercher</x-secondary-button>
</form>
</div>

</x-slot>



<div class="container">
<table class="table-fixed w-9/12 text-slate-200">
<tr><td class="font-bold">Nom</td><td class="font-bold">Email</td><td class="font-extrabold">Mot de passe</td></tr>
@foreach($users as $user)
<tr><td>{{ $user->name }}</td><td>{{ $user->email }}</td><td>{{ $user->password }}</td></tr>
@endforeach
</table>
</div>

</x-app-layout>

<
24 changes: 24 additions & 0 deletions resources/views/results.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

<x-app-layout>
<x-slot name="header">
<div class="container w-full">
<form class="w-60 flex flex-row" method="GET" action="{{ route('search') }}">
<input type="search" name="namesearch" id="default-search" class="block w-48 p-2 pl-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50" placeholder="Type any name..." required>
<x-secondary-button class="mx-2" type="submit">rechercher</x-secondary-button>
</form>
</div>

</x-slot>



<div class="container">
<table class="table-fixed w-9/12 text-slate-200">
<tr><td class="font-bold">Nom</td><td class="font-bold">Email</td><td class="font-extrabold">Mot de passe</td></tr>
@foreach($users as $user)
<tr><td>{{ $user->name }}</td><td>{{ $user->email }}</td><td>{{ $user->password }}</td></tr>
@endforeach
</table>
</div>

</x-app-layout>
5 changes: 5 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use App\Http\Controllers\HomeController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;

/*
Expand All @@ -25,3 +26,7 @@
});

Route::get('/', HomeController::class)->name('index');

Route::get('/members', [UserController::class, 'showAll']);

Route::get('/search', [UserController::class, 'search'])->name('search');