<?php

namespace App\Http\Requests;

use App\User;
use Illuminate\Foundation\Http\FormRequest;

/**
 * Class EntityRequest
 * @package App\Http\Requests
 */
class EntityRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        $user = $this->getUser();
        if ($user instanceof User) {

            if ($this->method() === 'PUT') {

                return $user->can("putEntity", $this);

            } else if ($this->method() === 'POST') {

                return $user->can("postEntity", $this);
            }
        }
        return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            //
        ];
    }
}
