how to create request in laravel code example
Example 1: php artisan make:request
php artisan make:request User\CreateUserRequest
Example 2: public function store(Request $request)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function store(Request $request)
{
$name = $request->input('name');
}
}
Example 3: laravel add request
$request->all() + ['index' => 'value'];
Example 4: laravel get all request parameters
$request->input('name');
$request->input('user.name');
Example 5: laravel request has
if ($request->has('name')) {
}
Example 6: laravel get data from request
dd($request->all());