mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 11:03:34 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			44 lines
		
	
	
		
			858 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			858 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Http\Requests\Expense;
 | 
						|
 | 
						|
use App\Http\Requests\Request;
 | 
						|
use App\Models\User;
 | 
						|
 | 
						|
class EDocumentRequest extends Request
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Determine if the user is authorized to make this request.
 | 
						|
     *
 | 
						|
     * @return bool
 | 
						|
     */
 | 
						|
    public function authorize(): bool
 | 
						|
    {
 | 
						|
        /** @var User $user */
 | 
						|
        $user = auth()->user();
 | 
						|
 | 
						|
        return $user->isAdmin();
 | 
						|
    }
 | 
						|
 | 
						|
    public function rules()
 | 
						|
    {
 | 
						|
        $rules = [];
 | 
						|
 | 
						|
        if ($this->file('documents') && is_array($this->file('documents'))) {
 | 
						|
            $rules['documents.*'] = $this->fileValidation();
 | 
						|
        } elseif ($this->file('documents')) {
 | 
						|
            $rules['documents'] = $this->fileValidation();
 | 
						|
        }
 | 
						|
        return $rules;
 | 
						|
    }
 | 
						|
 | 
						|
    public function prepareForValidation()
 | 
						|
    {
 | 
						|
        $input = $this->all();
 | 
						|
 | 
						|
        $this->replace($input);
 | 
						|
 | 
						|
    }
 | 
						|
 | 
						|
}
 |