40 lines
836 B
PHP
40 lines
836 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Entry;
|
|
use App\Auth\XenForoUser as User;
|
|
use Illuminate\Auth\Access\Response;
|
|
|
|
class EntryPolicy
|
|
{
|
|
|
|
public function view(User $user): bool
|
|
{
|
|
if( $user->_can( 'romhackplaza', 'view' ) )
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
public function create(User $user, ?Entry $entry = null ): bool
|
|
{
|
|
return $user->_can( 'romhackplaza', 'canSubmitEntry' );
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can update the model.
|
|
*/
|
|
public function update(User $user, Entry $entry): bool
|
|
{
|
|
if( $user->_can('romhackplaza', 'canEditOthersEntries') )
|
|
return true;
|
|
|
|
if( $user->_can( 'romhackplaza', 'canEditMyEntries' ) && $entry->user_id === $user->user_id )
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
}
|