mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-11-04 06:23:17 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
namespace Laraspace\Http\Requests;
 | 
						|
 | 
						|
use Illuminate\Foundation\Http\FormRequest;
 | 
						|
use Illuminate\Validation\Rule;
 | 
						|
use Laraspace\User;
 | 
						|
 | 
						|
class ProfileRequest extends FormRequest
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Determine if the user is authorized to make this request.
 | 
						|
     *
 | 
						|
     * @return bool
 | 
						|
     */
 | 
						|
    public function authorize()
 | 
						|
    {
 | 
						|
        return true;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Get the validation rules that apply to the request.
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function rules()
 | 
						|
    {
 | 
						|
        $user = User::find(1);
 | 
						|
 | 
						|
        switch ($this->getMethod()) {
 | 
						|
            case 'POST':
 | 
						|
                return [
 | 
						|
                    'name' => 'required',
 | 
						|
                    'password' => 'required',
 | 
						|
                    'email' => [
 | 
						|
                        'required',
 | 
						|
                        'email',
 | 
						|
                        Rule::unique('users')->ignore($user->id, 'id')
 | 
						|
                    ]
 | 
						|
                ];
 | 
						|
                break;
 | 
						|
            case 'PUT':
 | 
						|
                return [
 | 
						|
                    'name' => 'required',
 | 
						|
                    'email' => 'required|email'
 | 
						|
                ];
 | 
						|
                break;
 | 
						|
            default:
 | 
						|
                break;
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |