This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="fr"> | |
<head> | |
<title>Le titre</title> | |
</head> | |
<body> | |
<!-- contenu de la page --> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
DB::select('select * from users where votes = ?', [100]); | |
DB::select('select * from users where votes = :votes', ['votes' => 1]); | |
DB::table('users') | |
->where('votes', '=', 100) | |
->get(); | |
User::where('votes', '=', 100) | |
->get(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Http\Controllers\LocationsController; | |
use Illuminate\Http\Request; | |
Route::get('/locations/{location:slug}', [LocationsController::class, 'show']) | |
->name('locations.view') | |
->missing(function (Request $request) { | |
return Redirect::route('locations.index'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// routes | |
use App\Models\Post; | |
Route::get('/posts/{post:slug}', function (Post $post) { | |
return $post; | |
}); | |
// ou dans votre modèle | |
public function getRouteKeyName() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Models\User; | |
Route::get('/users/{user}', function (User $user) { | |
return $user->email; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('/path/{start?}/{end?}', function ($start = null, $end = null) | |
{ | |
if (!$start) { | |
// set start | |
} | |
if (!$end) { | |
// set end | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Http\Request; | |
Route::get('/user/{id}', function (Request $request, $id) { | |
return 'User '.$id; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Actions\Account; | |
use App\Models\User; | |
class ShowDashboard | |
{ | |
public function __invoke(Request $request, Client $client = null): Response | |
{ | |
/** @var $user User * */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::put('post/{id}', function ($id) {})->middleware('role:editor'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The application's route middleware groups. | |
* | |
* @var array | |
*/ | |
protected $middlewareGroups = [ | |
'web' => [ | |
\App\Http\Middleware\EncryptCookies::class, | |
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
NewerOlder