first work on To Do Lists

This commit is contained in:
2020-04-19 22:46:28 +02:00
parent c71f3ca4d8
commit c6b94aa1f1
17 changed files with 710 additions and 2 deletions

View File

@@ -0,0 +1,94 @@
<?php
namespace App\Policies;
use App\Models\ToDoList;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class ToDoListPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any to do lists.
*
* @param \App\User $user
* @return mixed
*/
public function viewAny(User $user)
{
return true;
}
/**
* Determine whether the user can view the to do list.
*
* @param \App\User $user
* @param \App\Models\ToDoList $toDoList
* @return mixed
*/
public function view(User $user, ToDoList $toDoList)
{
return $user->id == $toDoList->user_id;
}
/**
* Determine whether the user can create to do lists.
*
* @param \App\User $user
* @return mixed
*/
public function create(User $user)
{
return true;
}
/**
* Determine whether the user can update the to do list.
*
* @param \App\User $user
* @param \App\Models\ToDoList $toDoList
* @return mixed
*/
public function update(User $user, ToDoList $toDoList)
{
return $user->id == $toDoList->user_id;
}
/**
* Determine whether the user can delete the to do list.
*
* @param \App\User $user
* @param \App\Models\ToDoList $toDoList
* @return mixed
*/
public function delete(User $user, ToDoList $toDoList)
{
return $user->id == $toDoList->user_id;
}
/**
* Determine whether the user can restore the to do list.
*
* @param \App\User $user
* @param \App\Models\ToDoList $toDoList
* @return mixed
*/
public function restore(User $user, ToDoList $toDoList)
{
return false;
}
/**
* Determine whether the user can permanently delete the to do list.
*
* @param \App\User $user
* @param \App\Models\ToDoList $toDoList
* @return mixed
*/
public function forceDelete(User $user, ToDoList $toDoList)
{
return false;
}
}