Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fatenfalfoul's avatar

Cannot add other columns to my users table in the register form on laravel auth 5.1

why Laravel does not add my fields manually added to the page register in the database while submitting the form, here is the code of my register page

resources/views/auth/register.blade.php -->
{!! csrf_field() !!}
<div>
    Nom et prénom
    <input type="text" name="name" value="{{ old('name') }}">
</div>

<div>
    Email
    <input type="email" name="email" value="{{ old('email') }}">
</div>
Telephone --> Mot de passe
<div>
    Confirmer mot de passe
    <input type="password" name="password_confirmation">
</div>

 <div>
    Type
    <select name="type" required=true value="{{ old('type') }}">
        <option value="1">admin</option>
        <option value="2">patient</option>
        <!--<option value="3">cerise</option>   -->
    </select> 
</div>

 <div>
    Numéro de téléphone
    <input type="tel" name="tel" value="{{ old('tel') }}">
</div>

<div>
    <button type="submit">S'inscrire</button>
</div>

and here is the code of my migration classe

use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); // $table->bigInteger('tel')->unique();

        $table->string('password', 60);
        $table->string('type');
        $table->bigInteger('tel')->unique();

        $table->rememberToken();
        $table->timestamps();
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('users');
}

}

0 likes
4 replies
fatenfalfoul's avatar

I used the laravel 5.1 tutorial to make authetification, but my table users must have two other fields than those on the tutorial : telephone number and the type So when I added this fields in the model, in the the database migration classe and even the register form, the registration let these fields having the default variabls and do not take those passed by the form

fatenfalfoul's avatar

BadMethodCallException in Validator.php line 2678: Method [validateTell] does not exist. in Validator.php line 2678 at Validator->__call('validateTell', array('tel', '22572781', array(), object(Validator))) in Validator.php line 362 at Validator->validateTell('tel', '22572781', array(), object(Validator)) in Validator.php line 362 at Validator->validate('tel', 'tell') in Validator.php line 314 at Validator->passes() in Validator.php line 335 at Validator->fails() in RegistersUsers.php line 32 at AuthController->postRegister(object(Request)) at call_user_func_array(array(object(AuthController), 'postRegister'), array(object(Request))) in Controller.php line 256 at Controller->callAction('postRegister', array(object(Request))) in ControllerDispatcher.php line 164 at ControllerDispatcher->call(object(AuthController), object(Route), 'postRegister') in ControllerDispatcher.php line 112 at ControllerDispatcher->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in RedirectIfAuthenticated.php line 41 at RedirectIfAuthenticated->handle(object(Request), object(Closure)) at call_user_func_array(array(object(RedirectIfAuthenticated), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114 at ControllerDispatcher->callWithinStack(object(AuthController), object(Route), object(Request), 'postRegister') in ControllerDispatcher.php line 69 at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Auth\AuthController', 'postRegister') in Route.php line 203 at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134 at Route->run(object(Request)) in Router.php line 708 at Router->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in Router.php line 710 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 675 at Router->dispatchToRoute(object(Request)) in Router.php line 635 at Router->dispatch(object(Request)) in Kernel.php line 236 at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in VerifyCsrfToken.php line 50 at VerifyCsrfToken->handle(object(Request), object(Closure)) at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in StartSession.php line 62 at StartSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in CheckForMaintenanceMode.php line 44 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in Kernel.php line 122 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87 at Kernel->handle(object(Request)) in index.php line 54 at require_once('C:\wamp\www\last\public\index.php') in server.php line 21

Snapey's avatar
Snapey
Best Answer
Level 122

Have you added the new fields to the $fillable array in the User model?

3 likes

Please or to participate in this conversation.