“Laravel Form -Validierung” Code-Antworten

Laravel -Bildvalidierung

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

E -Mail -Validierung in Laravel

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

PHP Artisan Make: Anfrage

php artisan make:request User\CreateUserRequest 
Encouraging Echidna

Wenn ein Fehler in Blade Laravel ein Fehler

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

Laravel Form -Validierung

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

Laravel -Validierung im Controller

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

Ähnliche Antworten wie “Laravel Form -Validierung”

Fragen ähnlich wie “Laravel Form -Validierung”

Weitere verwandte Antworten zu “Laravel Form -Validierung” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen