mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\CustomFilter;
|
|
use App\User;
|
|
|
|
class CustomFilterPolicy
|
|
{
|
|
/**
|
|
* Determine whether the user can view any models.
|
|
*/
|
|
public function viewAny(User $user): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view the custom filter.
|
|
*
|
|
* @param \App\User $user
|
|
* @param \App\Models\CustomFilter $filter
|
|
* @return bool
|
|
*/
|
|
public function view(User $user, CustomFilter $filter)
|
|
{
|
|
return $user->profile_id === $filter->profile_id;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can create models.
|
|
*/
|
|
public function create(User $user): bool
|
|
{
|
|
return CustomFilter::whereProfileId($user->profile_id)->count() <= 100;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can update the custom filter.
|
|
*
|
|
* @param \App\User $user
|
|
* @param \App\Models\CustomFilter $filter
|
|
* @return bool
|
|
*/
|
|
public function update(User $user, CustomFilter $filter)
|
|
{
|
|
return $user->profile_id === $filter->profile_id;
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the custom filter.
|
|
*
|
|
* @param \App\User $user
|
|
* @param \App\Models\CustomFilter $filter
|
|
* @return bool
|
|
*/
|
|
public function delete(User $user, CustomFilter $filter)
|
|
{
|
|
return $user->profile_id === $filter->profile_id;
|
|
}
|
|
}
|