/ / Laravel dołącz do sprawdzania poprawności tabel - laravel, dołącz

Laravel dołącza do sprawdzania poprawności tabel - laravel, dołącz

Chcę zweryfikować tabelę dołączeń. Sprawdziłem tylko jedną tabelę, ale co, jeśli mam połączoną tabelę. Na podstawie załączonego obrazu. Jak mogę to sprawdzić?

    public function store()
{
$input = Input::all();
$validation = Validator::make($input, User::$rules);


if ($validation->passes()){
User::create($input);
return View::make("users.create");
}
return Redirect::route("users.create")
->withInput()
->withErrors($validation)
->with("message", "Please correct the following errors:");

}

wprowadź opis obrazu tutaj

Odpowiedzi:

0 dla odpowiedzi № 1

Możesz używać wielu walidatorów, a także sprawdzać poprawność UserAccount Model:

public function store()
{
$input = Input::all();
$validation = Validator::make($input, User::$rules);

$validation2 = Validator::make($input, UserAccount::$rules);


$result = true;

if (!$validation->passes()) {
$result = false;
}
if (!$validation2->passes()) {
$result = false;
}

if ($result) {
User::create($input);
return View::make("users.create");
}
return Redirect::route("users.create")
->withInput()
->withErrors([$validation, $validation2])
->with("message", "Please correct the following errors:");

}