In laravel we specify foreign keys this way
public function creator() {
return $this->belongsTo('App\Models\User', 'creator_id', 'id');
}
Is there some way to return dummy user ('system') when creator_id is null?
Reason: to display it in template.
For example:
If creator_id = 10 =>
creator = {id: 1, name: 'John'}
If creator_id = null =>
creator = {id: 0, name: 'system'}
via Jackson J