PHP code example of risetechapps / form-request-for-laravel

1. Go to this page and download the library: Download risetechapps/form-request-for-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

risetechapps / form-request-for-laravel example snippets


  
  use RiseTechApps\FormRequest\Traits\hasFormValidation\hasFormValidation;
  use RiseTechApps\FormRequest\ValidationRuleRepository;
  
  class StoreClientRequest extends FormRequest
  {
    use hasFormValidation;

    protected ValidationRuleRepository $ruleRepository;

    protected array $result = [];

    public function __construct(ValidationRuleRepository $validatorRuleRepository)
    {
        parent::__construct();

        $this->ruleRepository = $validatorRuleRepository;

        $this->result = $this->ruleRepository->getRules('clients');
    }

    public function rules(): array
    {
        return $this->result['rules'];
    }

    public function messages(): array
    {
        return $this->result['messages'];
    }

    public function authorize(): bool
    {

        if(auth()->check() && auth()->user()->hasPermission(Permissions::$DASHBOARD_CLIENT_STORE)) {
            return true;
        }

        return false;
    }
 }