My controller like this :
<?php
use App\Http\Requests\StoreReceiveOrderRequest;
class SellController extends Controller
{
public function receiveOrder(StoreReceiveOrderRequest $request)
{
dd($request->all());
...
}
}
Before executed statement in the receiveOrder method, it will check rules on the StoreReceiveOrderRequest
The StoreReceiveOrderRequest like this :
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreReceiveOrderRequest extends FormRequest
{
public function rules()
{
return [
'is_follow_up'=>'required',
'note'=>'max:300' // I want to make this to be required if is_follow_up = n
];
}
}
the result of dd($request->all());
, there are 2 results, depending user input
If the is_follow_up = y, the result like this :
Array
(
[is_follow_up] => y
)
If the is_follow_up = n, the result like this :
Array
(
[is_follow_up] => n
[note] => test
)
If is_follow_up = n, I want to make the note is required
If is_follow_up = y, the note is not required
Seems it must to add condition on the rules
How can I do it?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iQZswH
via IFTTT
Aucun commentaire:
Enregistrer un commentaire