Closed dillingham closed 5 years ago
This could probably be done as part of the BelongsTo with a macro.
This would work as BelongsTo::make('User')->defaultTo(..) and BelongsTo::make('User')->defaultToMe() or something.
BelongsTo::make('User')->defaultTo(..)
BelongsTo::make('User')->defaultToMe()
This should be pretty easy to do
This is my solution.
For example, my Post model belongs to an User model via user_id:
user_id
public function getUserIdAttribute() { return ! $this->exists && \Auth::check() ? \Auth::user()->id : null; }
This could probably be done as part of the BelongsTo with a macro.
This would work as
BelongsTo::make('User')->defaultTo(..)
andBelongsTo::make('User')->defaultToMe()
or something.This should be pretty easy to do