<?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;
    }
}
