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',
]);
}
Also in PHP:
- data type php display
- disable cache laravel 8 development
- data type php varchar
- build strong password in php
- add date ti particular date in php
- console.log equivalent in php
- composer create-project laravel 6
- dynamic carousel bootstrap php
- all capital in php
- date year php
- artisan seed
- find array key value by check key
- console.log. php print
- /phpspreadsheet 1.15.0 requires ext-dom * centos
- create folder with php
- ext-dom install php 7.4
- datetime::timeformat php
- array sort array reverse php
- check string exist in php
- change header php
- create laravel project 7
- Best Image Manipulation and Graphs tools for php
- check if string contains specific string php
- Codeigniter count query results