“validasi bentuk Laravel” Kode Jawaban

Validasi gambar Laravel

'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
Optimus Grind

Validasi email di Laravel

'email' => 'required|email|unique:users,email',
//@sujay
$uj@y

PHP Artisan Make: permintaan

php artisan make:request User\CreateUserRequest 
Encouraging Echidna

Jika ada kesalahan di Blade Laravel

 @if ($errors->any())
     @foreach ($errors->all() as $error)
         <div>{{$error}}</div>
     @endforeach
 @endif
Zamir

validasi bentuk Laravel

use Illuminate\Support\Facades\Validator;

// .... 
  
// On your Store function 
 public function store(Request $request, $id)
// Validation 
        $validator = Validator::make($request, [
            'name' => 'required',
            'username' => 'required|unique:users,username,NULL,id,deleted_at,NULL',
            'email' => 'nullable|email|unique:users,email,NULL,id,deleted_at,NULL',
            'password' => 'required',
        ]);


// Return the message
        if($validator->fails()){
            return response()->json([
                'error' => true,
                'message' => $validator->errors()
            ]);
        }
  // ....
}


// On your Update function 
public function update(Request $request, $id)
    {
		// Validation
        $validator = Validator::make($input, [
            'name' => 'required',
            'username' => 'required|unique:users,username,' . $id. ',id,deleted_at,NULL',
            'email' => 'nullable|email|unique:users,email,' . $id. ',id,deleted_at,NULL',
            'roles' => 'required'
        ]);

        // Return the message
        if($validator->fails()){
            return response()->json([
                'error' => true,
                'msg' => $validator->errors()
            ]);
        }
  // ....
}
edsonjorgef1

Validasi Laravel di Controller

$validator = Validator::make($request->all(), [
            'password' => 'required|string',
            'email' => 'required|string|email',
        ]);
kinjal suryavanshi

Jawaban yang mirip dengan “validasi bentuk Laravel”

Pertanyaan yang mirip dengan “validasi bentuk Laravel”

Lebih banyak jawaban terkait untuk “validasi bentuk Laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya