2023-11-02 22:02:20 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Auth;
|
|
|
|
use App\Models\Link;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class LinkId
|
|
|
|
{
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
$linkId = $request->route('id');
|
|
|
|
$user = Auth::user();
|
|
|
|
|
|
|
|
$link = Link::find($linkId);
|
|
|
|
|
|
|
|
if (!$link) {
|
|
|
|
return abort(404);
|
|
|
|
}
|
|
|
|
|
2024-01-24 19:37:02 +01:00
|
|
|
if ($user->id != $link->user_id) {
|
2023-11-02 22:02:20 +01:00
|
|
|
return abort(403);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|