Added the rest of the policy files

This commit is contained in:
mwalbeck 2016-10-26 16:17:58 +02:00
commit 6511f3a248
8 changed files with 326 additions and 55 deletions
app/Policies

View file

@ -0,0 +1,58 @@
<?php
namespace App\Policies;
use App\User;
use App\Question;
use App\Test;
use Illuminate\Auth\Access\HandlesAuthorization;
class QuestionPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can create questions.
*
* @param \App\User $user
* @return mixed
*/
public function create(User $user)
{
if ($user->isAdministrator() || $user->isModerator()) {
dd("hit");
return true;
}
return false;
}
/**
* Determine whether the user can update the question.
*
* @param \App\User $user
* @param \App\Question $question
* @return mixed
*/
public function update(User $user, Question $question)
{
if ($user->isAdministrator() || ($user->isModerator() AND $user->group_id === $question->test->group_id)) {
return true;
}
return false;
}
/**
* Determine whether the user can delete the question.
*
* @param \App\User $user
* @param \App\Question $question
* @return mixed
*/
public function delete(User $user, Question $question)
{
if ($user->isAdministrator() || ($user->isModerator() AND $user->group_id === $question->test->group_id)) {
return true;
}
return false;
}
}