php - Adding new field to Laravel boilerplate user model -


i'm trying add new field laravel boiler user model. in fresh laravel have app/user.php can add field using $fillable .

in boilerplate have app/models/access/user/user.php , have id guarded protected $guarded = ['id']; . password, remember_token $hidden protected $hidden = ['password', 'remember_token']; else default fillable.

but when i'm trying add new field user model , it's not adding database table.

table have field called summery .

i've added summery field register.blade.php , tried check if it's passing.

added return ($request); app\service\access\trait\registersusers.php

 public function register(registerrequest $request) {     if (config('access.users.confirm_email')) {         $user = $this->user->create($request->all());         event(new userregistered($user));         dd ($request);       //  return redirect()->route('frontend.index')->withflashsuccess(trans('exceptions.frontend.auth.confirmation.created_confirm'));     } else {         auth()->login($this->user->create($request->all()));         event(new userregistered(access()->user()));         return redirect($this->redirectpath());     } } 

and returns

post /register http/1.1 accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding: gzip, deflate accept-language: en-us,en;q=0.8 cache-control: max-age=0 connection: keep-alive content-length: 170 content-type: application/x-www-form-urlencoded cookie: xsrf-token={{removed}} host: localhost:8000 origin: http://localhost:8000 referer: http://localhost:8000/ upgrade-insecure-requests: 1 user-agent: mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/50.0.2661.94 safari/537.36 _token=jwlzc59098aaugfp4pywv0m3sdex91bhpvqn43xq&name=test+user&password=testpass&password_confirmation=testpass&email=testmail%40test.com&summery=test+summery&terms=terms 

but not table not updated correctly .

my other tables inputs , data retrieving . have problem model.

please let me know if need more information helping me on .

edit :

source of app/models/access/user/user.php

<?php  namespace app\models\access\user;  use app\models\access\user\traits\useraccess; use illuminate\database\eloquent\softdeletes; use illuminate\foundation\auth\user authenticatable; use app\models\access\user\traits\attribute\userattribute; use app\models\access\user\traits\relationship\userrelationship;  /**  * class user  * @package app\models\access\user  */ class user extends authenticatable {      use softdeletes, useraccess, userattribute, userrelationship;        /**      * attributes not mass assignable.      *      * @var array      */     protected $guarded = ['id'];      /**      * attributes should hidden arrays.      *      * @var array      */     protected $hidden = ['password', 'remember_token'];      /**      * @var array      */     protected $dates = ['deleted_at']; } 

edit2 : dd ($request);

registerrequest {#430 ▼   #container: application {#3 ▶}   #redirector: redirector {#437 ▶}   #redirect: null   #redirectroute: null   #redirectaction: null   #errorbag: "default"   #dontflash: array:2 [▼     0 => "password"     1 => "password_confirmation"   ]   #json: null   #convertedfiles: []   #userresolver: closure {#356 ▶}   #routeresolver: closure {#355 ▶}   +attributes: parameterbag {#432 ▶}   +request: parameterbag {#429 ▶}   +query: parameterbag {#431 ▶}   +server: serverbag {#435 ▶}   +files: filebag {#434 ▶}   +cookies: parameterbag {#433 ▶}   +headers: headerbag {#436 ▶}   #content: "_token=md4ax1qosbxjdhlwqstyrkwmw25okid1mwu9xhge&name=test+user+two&password=testpass&password_confirmation=testpass&email=test%40test.com&summery=test+summery&terms=terms"   #languages: null   #charsets: null   #encodings: null   #acceptablecontenttypes: null   #pathinfo: null   #requesturi: null   #baseurl: null   #basepath: null   #method: "post"   #format: null   #session: store {#386 ▶}   #locale: null   #defaultlocale: "en" } 

edit 3 : source app\events\auth\userregistered.php

<?php  namespace app\events\frontend\auth;  use app\events\event; use illuminate\queue\serializesmodels;  /**  * class userregistered  * @package app\events\frontend\auth  */ class userregistered extends event {     use serializesmodels;      /**      * @var $user      */     public $user;      /**      * @param $user      */     public function __construct($user)     {         $this->user = $user;     } } 

here solution i've found , goto app\repositories\frontend\access\user\eloquentuserrepository.php

you find

    public function create(array $data, $provider = false) {     if ($provider) {         $user = user::create([             'summery' => $data['summery'], // add new field here             'name' => $data['name'],             'email' => $data['email'],             'password' => null,             'confirmation_code' => md5(uniqid(mt_rand(), true)),             'confirmed' => 1,             'status' => 1,         ]);     } else {         $user = user::create([             'summery' => $data['summery'], // add new field here             'name' => $data['name'],             'email' => $data['email'],             'password' => bcrypt($data['password']),             'confirmation_code' => md5(uniqid(mt_rand(), true)),             'confirmed' => config('access.users.confirm_email') ? 0 : 1,             'status' => 1,         ]);     }   } 

check how added new field 'summery' function.after add new field there oost request send new field data database.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -