<?php

namespace Bixo\Collection\Policies;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Bixo\Collection\Models\Collections;

class CollectionsPolicy
{


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

        return $collections->is_owner;
    }

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

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

        return $collections->is_owner;
    }

    /**
     * Determine if the given user can delete the given collections.
     *
     * @param Authenticatable $user
     *
     * @return bool
     */
    public function destroy(Authenticatable $user, Collections $collections)
    {
        return $collections->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;
        }
    }
}