fix(route): fix implicit route model binding for Project
- Move Route::model to register() in AppServiceProvider so it persists in route cache - Re-register in boot() for runtime - Fix navigation spacing for language/notification/user menu All 101 tests pass
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Project;
|
||||
|
||||
class BindProjectModel
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$route = $request->route();
|
||||
if ($route && $route->parameter('project')) {
|
||||
$projectId = $route->parameter('project');
|
||||
if (is_string($projectId) && is_numeric($projectId)) {
|
||||
$project = Project::findOrFail($projectId);
|
||||
$route->setParameter('project', $project);
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user