mirror of
https://github.com/10h30/Test-Laravel-Validation.git
synced 2026-06-05 15:07:56 +09:00
Task 5 - old values staying in the form
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Team;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class TeamController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return view('teams.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|min:5',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return redirect('teams/create')
|
||||
->withInput()
|
||||
->withErrors($validator);
|
||||
}
|
||||
|
||||
Team::create($validator->validated());
|
||||
|
||||
return 'Success';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user