1

I'm kinda new to laravel (5.7) and I'm stuck trying to create a registration form. the validation works great but then the page refresh and nothing happens, no errors, nothing changes on the registration form with no records on the database.

Here is my controller, I tweaked the basic form that laravel gives you to start with so it matches my database. And I created a folder for my models, so I changed the path to the "users" model that's all the tweaks I've done on this.

namespace App\Http\Controllers\Auth;

use App\Models\users;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{

    use RegistersUsers;

    protected $redirectTo = '/home';

    public function __construct()
    {
        $this->middleware('guest');
    }

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users,User_Email',
            'passowrd' => 'required|string|min:2|confirmed',
        ]);
    }

    protected function create(array $data)
    {
       return users::create([
            'User_Nom' => $data['name'],
            'User_Email' => $data['email'],
            'User_pwd' => Hash::make($data['password']),
        ]);
    }
}

I'm guessing that it has something to do with my Model but I can't put my finger in it. so here is my Model :

namespace App;

    use Illuminate\Notifications\Notifiable;
    use Illuminate\Foundation\Auth\User as Authenticatable;

    class users extends Authenticatable
    {
        use Notifiable;

       protected $primaryKey = 'User_Id';
       protected $table = 'users';
        protected $fillable = [
            'User_Id', 'User_Nom', 'User_Prenom', 'User_pwd', 'User_Email', 'User_Tel', 'User_Fax', 'User_Post'
       ];
        protected $hidden = [
            'User_pwd', 'remember_token',
        ];
    }

(Sorry for the indentation the copy - past messed it up)

Thank you

4
  • Do add your form too. Commented Nov 14, 2018 at 10:03
  • i did not change any thing from in the basic form of Laravel Commented Nov 14, 2018 at 10:06
  • any error in laravel logs? Commented Nov 14, 2018 at 10:08
  • No errors at all Commented Nov 14, 2018 at 10:13

2 Answers 2

3

In your model, the namespace should also be changed to match the folder it's in. So: namespace App\Models;. Other than that, you have a typo in your validation: passowrd.

Check out https://laravel.com/docs/5.7/requests to see how you should receive the data in the controller.

Sign up to request clarification or add additional context in comments.

3 Comments

I feel so dumb thank you that was the "password" that was doing it, so now i can see the error. " Invalid datetime format: 1366 Incorrect integer value: 'test' for column 'User_Nom' at row 1 (SQL: insert into users (User_Nom, User_Email, User_pwd, updated_at, created_at) values (test, [email protected], $2y$10$Htv9GgXn3bFbVRQ7c5C8ju5FoLtJX/zQgNnZY/4djY559wjUFC.J., 2018-11-14 10:15:27, 2018-11-14 10:15:27))" But that's another story...
What kind of type is the User_Nom field in your database? Seems like it is set as an integer field, but you are trying to put a string in it.
Since i can see the errors i can fix things :) i've already fixed this issue too, thank you guys !
0

How about calling the model like this ?

use App\users;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.