Answers for "php artisan make -mcr"

PHP
2

php artisan make :migration with model

php artisan make:model ModelName -a
Posted by: Guest on December-28-2020
0

by default null eloquent user data in relationship in laravel 8

# simple handle in blade file 
{{ $post->author->name or 'No author' }}

# Model action 
public function author()
{
    return $this->belongsTo('App\Author')->withDefault();
}

public function author()
{
    return $this->belongsTo('App\Author')->withDefault([
        'name' => 'Guest Author',
    ]);
}
Posted by: Guest on February-04-2021

Browse Popular Code Answers by Language