jeudi 1 août 2019

Add [title] to fillable property to allow mass assignment on [App\Profile] in index.blade.php

Am creating the create a new user into my users table in MySQL and at the same time trying to create a title fr the same user in a profile table.

This is a course on laravel from freeCodeCamp.

protected static function boot()
    {
        parent::boot();

        static::created(function ($user) {
            $user->profile()->create([
                'title' => $user->username,
            ]);
        });
    }

Am expected to create a null able profile for the user once he/she get registered.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire