2020-06-26 23:32:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
use App\Application;
|
2020-10-21 00:29:50 +00:00
|
|
|
use Illuminate\Auth\Access\Response;
|
2020-06-26 23:32:33 +00:00
|
|
|
use App\User;
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
|
|
|
|
class ApplicationPolicy
|
|
|
|
{
|
|
|
|
use HandlesAuthorization;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new policy instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
2020-06-27 18:15:33 +00:00
|
|
|
public function viewAny(User $user)
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
if ($user->can('applications.view.all'))
|
|
|
|
{
|
|
|
|
return Response::allow();
|
|
|
|
}
|
2020-06-27 18:15:33 +00:00
|
|
|
|
2020-10-21 00:29:50 +00:00
|
|
|
return Response::deny('Forbidden');
|
2020-06-27 18:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 23:32:33 +00:00
|
|
|
public function view(User $user, Application $application)
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
if ($user->is($application->user) && $user->can('applications.view.own') || $user->can('applications.view.all'))
|
|
|
|
{
|
|
|
|
return Response::allow();
|
|
|
|
}
|
2020-06-26 23:32:33 +00:00
|
|
|
|
2020-10-21 00:29:50 +00:00
|
|
|
return Response::deny('You are not authorised to view this application');
|
2020-06-26 23:32:33 +00:00
|
|
|
}
|
2020-06-27 18:15:33 +00:00
|
|
|
|
|
|
|
public function update(User $user)
|
|
|
|
{
|
|
|
|
return $user->hasAnyRole('admin', 'hiringManager');
|
|
|
|
}
|
2020-07-12 16:01:33 +00:00
|
|
|
|
|
|
|
public function delete(User $user, Application $application)
|
|
|
|
{
|
2020-10-21 00:29:50 +00:00
|
|
|
|
|
|
|
return $user->hasRole('admin');
|
|
|
|
|
2020-07-12 16:01:33 +00:00
|
|
|
}
|
2020-06-26 23:32:33 +00:00
|
|
|
}
|