dimanche 27 janvier 2019

laravel route not defined exception

I want to post data insert a user

This is a code snippet in html which is going to be used for adding a user

<form id="register-form" action="" method="post" role="form" style="display: none;">
    <div class="form-group">
        <input type="text" name="name" id="name" tabindex="1" class="form-control" placeholder="Username" value="">
    </div>
    <div class="form-group">
        <input type="email" name="email" id="email" tabindex="1" class="form-control" placeholder="Email Address" value="">
    </div>
    <div class="form-group">
        <input type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="Password">
    </div>
    <div class="form-group">
        <input type="password" name="confirm-password" id="confirm-password" tabindex="2" class="form-control" placeholder="Confirm Password">
    </div>
    <div class="form-group">
        <div class="row">
            <div class="col-sm-6 col-sm-offset-3">
                <input type="submit" name="register-submit" id="register-submit" tabindex="4" class="form-control btn btn-register" value="Register Now">
            </div>
        </div>
    </div> </form>

i added a route Routes/web.php

Route::resource('products','ProductController');

An inside of my ProductController i have situation like

public function add(Request $request)
{
    $this->validate($request, [
        'name' => 'required|min:3',
        'email' => 'required|email|unique:users',
        'password' => 'required|min:6',
    ]);

    $user = User::create([
        'name' => $request->name,
        'email' => $request->email,
        'password' => bcrypt($request->password)
    ]);

    $token = $user->createToken('TutsForWeb')->accessToken;

    return response()->json(['token' => $token], 200);
}

So when i run my server it throw me exception like

Route [register.add] not defined. (View: \apiauthexample\resources\views\welcome.blade.php)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire