<?php

namespace Bixo\Schedule\Policies;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Bixo\Schedule\Models\FollowUps;

class FollowUpsPolicy
{

    use FollowUpsAction;
    use FollowUpsReport;
    use FollowUpsWorkflow;

    /**
     * Determine if the given user can view the follow_ups.
     *
     * @param Authenticatable $user
     * @param FollowUps $follow_ups
     *
     * @return bool
     */
    public function view(Authenticatable $user, FollowUps $follow_ups)
    {
        if ($authUser->canDo('schedule.follow_ups.view') && $authUser->isAdmin() || $user->isClient()) {
            return true;
        }

        return $follow_ups->is_owner;
    }

    /**
     * Determine if the given user can create a follow_ups.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function create(Authenticatable $user)
    {
        return  $authUser->canDo('schedule.follow_ups.create');
    }

    /**
     * Determine if the given user can update the given follow_ups.
     *
     * @param Authenticatable $user
     * @param FollowUps $follow_ups
     *
     * @return bool
     */
    public function update(Authenticatable $user, FollowUps $follow_ups)
    {
        if ($user->canDo('schedule.follow_ups.edit') && $user->isAdmin()) {
            return true;
        }

        return $follow_ups->is_owner;
    }

    /**
     * Determine if the given user can delete the given follow_ups.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function destroy(Authenticatable $user, FollowUps $follow_ups)
    {
        return $follow_ups->is_owner;
    }

    /**
     * Determine if the user can perform a given action ve.
     *
     * @param [type] $user    [description]
     * @param [type] $ability [description]
     *
     * @return [type] [description]
     */
    public function before($user, $ability)
    {
        if ($user->isSuperuser()) {
            return true;
        }
    }
}