namespace App\Policies;
use App\Models\Post;
use App\Models\User;
class PostPolicy
{
/**
* Determine if the given post can be updated by the user.
*/
public function update(User $user, Post $post): bool
{
return $user->id === $post->user_id;
}
}
use App\Models\Post;
use Illuminate\Support\Facades\Route;
/**
* Define your route model bindings, pattern filters, etc.
*/
public function boot(): void
{
Route::modelAuth('post', Post::class);
// ...
}
Route::get('posts/{post}', function (Post $post) {
return $post;
});
Route::get('posts/{post}/comments/{comment}', function (Post $post, Comment $comment) {
//..
})->scopeBindings();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.