129 lines
3 KiB
PHP
129 lines
3 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Game;
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
class GamePolicy
|
|
{
|
|
use HandlesAuthorization;
|
|
|
|
/**
|
|
* Determine whether the user can view any models.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
*/
|
|
public function viewAny(User $user)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view the model.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Game $game
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
*/
|
|
public function view(User $user, Game $game)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can create models.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
*/
|
|
public function create(User $user)
|
|
{
|
|
// Ensure the user has permission to add games into the database.
|
|
if (
|
|
$user->role_id === 1 ||
|
|
$user->role_id === 2 ||
|
|
$user->role_id === 3
|
|
) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can clone the model.
|
|
*/
|
|
public function clone(User $user)
|
|
{
|
|
// Ensure the user has permission to clone games into the database.
|
|
if (
|
|
$user->role_id === 1 ||
|
|
$user->role_id === 2 ||
|
|
$user->role_id === 3
|
|
) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can update the model.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
*/
|
|
public function update(User $user)
|
|
{
|
|
// Ensure the user has permission to updates games in the database.
|
|
if (
|
|
$user->role_id === 1 ||
|
|
$user->role_id === 2 ||
|
|
$user->role_id === 3
|
|
) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the model.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Game $game
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
*/
|
|
public function delete(User $user, Game $game)
|
|
{
|
|
// Ensure the user has permission to delete games from the database.
|
|
if (
|
|
$user->role_id === 1 ||
|
|
$user->role_id === 2 ||
|
|
$user->role_id === 3
|
|
) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can restore the model.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Game $game
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
*/
|
|
public function restore(User $user, Game $game)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can permanently delete the model.
|
|
*
|
|
* @param \App\Models\User $user
|
|
* @param \App\Models\Game $game
|
|
* @return \Illuminate\Auth\Access\Response|bool
|
|
*/
|
|
public function forceDelete(User $user, Game $game)
|
|
{
|
|
//
|
|
}
|
|
}
|