95 lines
2.1 KiB
PHP
95 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Bookmark;
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
class BookmarkPolicy
|
|
{
|
|
use HandlesAuthorization;
|
|
|
|
/**
|
|
* Determine whether the user can view any bookmarks.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @return mixed
|
|
*/
|
|
public function viewAny(User $user)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view the bookmark.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Bookmark $bookmark
|
|
* @return mixed
|
|
*/
|
|
public function view(User $user, Bookmark $bookmark)
|
|
{
|
|
return $user->id == $bookmark->user_id;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can create bookmarks.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @return mixed
|
|
*/
|
|
public function create(User $user)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can update the bookmark.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Bookmark $bookmark
|
|
* @return mixed
|
|
*/
|
|
public function update(User $user, Bookmark $bookmark)
|
|
{
|
|
return $user->id == $bookmark->user_id;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the bookmark.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Bookmark $bookmark
|
|
* @return mixed
|
|
*/
|
|
public function delete(User $user, Bookmark $bookmark)
|
|
{
|
|
return $user->id == $bookmark->user_id;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can restore the bookmark.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Bookmark $bookmark
|
|
* @return mixed
|
|
*/
|
|
public function restore(User $user, Bookmark $bookmark)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can permanently delete the bookmark.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Bookmark $bookmark
|
|
* @return mixed
|
|
*/
|
|
public function forceDelete(User $user, Bookmark $bookmark)
|
|
{
|
|
return false;
|
|
}
|
|
}
|