2022-04-26 21:16:46 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
use App\Models\Collective;
|
|
|
|
use App\Models\Owned;
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
|
|
|
|
class OwnedPolicy
|
|
|
|
{
|
|
|
|
use HandlesAuthorization;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can view any models.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
|
|
*/
|
|
|
|
public function viewAny(Collective $collective)
|
|
|
|
{
|
2022-04-27 21:15:01 -07:00
|
|
|
return auth_collective()->id === $collective->id;
|
2022-04-26 21:16:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can view the model.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
|
|
*/
|
|
|
|
public function view(Collective $collective, Owned $owned)
|
|
|
|
{
|
2022-04-27 21:15:01 -07:00
|
|
|
return $collective->id === $owned->collective_id;
|
2022-04-26 21:16:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can create models.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
|
|
*/
|
|
|
|
public function create(Collective $collective)
|
|
|
|
{
|
2022-04-27 21:15:01 -07:00
|
|
|
return auth_collective()->id === $collective->id;
|
2022-04-26 21:16:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can update the model.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
|
|
*/
|
|
|
|
public function update(Collective $collective, Owned $owned)
|
|
|
|
{
|
2022-04-27 21:15:01 -07:00
|
|
|
return $collective->id === $owned->collective_id;
|
2022-04-26 21:16:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can delete the model.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
|
|
*/
|
|
|
|
public function delete(Collective $collective, Owned $owned)
|
|
|
|
{
|
2022-04-27 21:15:01 -07:00
|
|
|
return $collective->id === $owned->collective_id;
|
2022-04-26 21:16:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can restore the model.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
|
|
*/
|
|
|
|
public function restore(Collective $collective, Owned $owned)
|
|
|
|
{
|
2022-04-27 21:15:01 -07:00
|
|
|
return $collective->id === $owned->collective_id;
|
2022-04-26 21:16:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine whether the user can permanently delete the model.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
|
|
*/
|
|
|
|
public function forceDelete(Collective $collective, Owned $owned)
|
|
|
|
{
|
2022-04-27 21:15:01 -07:00
|
|
|
return $collective->id === $owned->collective_id;
|
2022-04-26 21:16:46 -07:00
|
|
|
}
|
|
|
|
}
|