tighten / nova-package-development

A forum for talking about the process of Nova Package Development
52 stars 2 forks source link

Nova Creator Field Package #46

Closed dillingham closed 5 years ago

alexbowers commented 6 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.

This should be pretty easy to do

MarceauKa commented 6 years ago

This is my solution.

For example, my Post model belongs to an User model via user_id:

public function getUserIdAttribute()
{
    return ! $this->exists && \Auth::check() ? \Auth::user()->id : null;
}