mirror of
https://github.com/10h30/Test-Laravel-Validation.git
synced 2026-06-05 15:07:56 +09:00
Task 1 - simple validation rules
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Post;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PostController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(
|
||||
// ... TASK: write validation here so that "title" field
|
||||
// would be required and unique in the "posts" DB table
|
||||
);
|
||||
|
||||
// Saving the post
|
||||
Post::create(['title' => $request->title]);
|
||||
|
||||
return 'Success';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user