- 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
23 lines
591 B
PHP
23 lines
591 B
PHP
<?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);
|
|
}
|
|
} |