2018年3月7日 星期三

laravel validations

//Controller
$validator = Validator::make($request->all(), [
'name' => 'required|max:255'
        ],
        [
            'name.required' => '請輸入名稱!',
        ]);

if ($validator->fails()) {
return back()->withErrors($validator)->withInput();
        }

//blade
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif



//api validation
$this->validate($request, [
             'is_important' => 'required',
         ]);

1 則留言:

  1. How to play roulette with a roulette table - DrmCD
    To do this, you should follow the steps below for a 양산 출장안마 roulette table 보령 출장마사지 with the roulette wheel 용인 출장샵 facing. 광주 출장마사지 If you 전주 출장안마 are unsure about the rules of

    回覆刪除

[CentOS] httpd port 9000 to 80

<VirtualHost *:80>     ServerName domain.name     ProxyRequests Off     ProxyVia Block     ProxyPreserveHost On     <Proxy *...