add bookmark back
This commit is contained in:
94
app/Policies/BookmarkPolicy.php
Normal file
94
app/Policies/BookmarkPolicy.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Bookmark;
|
||||
use App\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class BookmarkPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any bookmarks.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public function viewAny(User $user)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the bookmark.
|
||||
*
|
||||
* @param \App\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\User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(User $user)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the bookmark.
|
||||
*
|
||||
* @param \App\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\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\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\User $user
|
||||
* @param \App\Models\Bookmark $bookmark
|
||||
* @return mixed
|
||||
*/
|
||||
public function forceDelete(User $user, Bookmark $bookmark)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user