PHP code example of mawuekom / laravel-api-form-request

1. Go to this page and download the library: Download mawuekom/laravel-api-form-request library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mawuekom / laravel-api-form-request example snippets


namespace App\Http\Requests;

use Mawwuekom\ApiFormRequest\ApiFormRequest;

class CreateUserRequest extends ApiFormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'          => '

namespace App\Http\Controllers;

use App\User;
use App\Http\Controllers\Controller;
use App\Http\Requests\CreateUserRequest;

class UserController extends Controller
{

    public function register(CreateUserRequest $request)
    {
        User::create([
            'name' => request('name'),
            'first_name' => request('first_name'),
            'email' => request('email'),
            'password' => bcrypt(request('password')),
        ]);
    }
}