New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nova Creator Field Package #46

dillingham opened this Issue Sep 18, 2018 · 3 comments


None yet
3 participants

dillingham commented Sep 18, 2018

Package that sets the current authenticated user to be the BelongsTo relationship


// ^ Auth user's name in disabled select box setting owner_id


// ^ Hidden, auth user id for user_id

Probably just extend BelongsTo and override the resolve() method

Maybe Owner::make(‘Team’); ?

Isn’t too difficult to set up mutators for this but it’s also more explicit and makes models a little more dry maybe? Idk


This comment has been minimized.

alexbowers commented Sep 19, 2018

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


This comment has been minimized.


dillingham commented Sep 25, 2018

@alexbowers yeah. I was picturing it making a behind the scenes model event

// Order resource
// behind the scenes
Order::saving user_id = auth()->user()->id

// Blog resource
// behind the scenes
Blog::saving author_id = auth()->user()->id

// behind the scenes
Blog::saving author_id = auth()->user()->id

// behind the scenes
Blog::saving team_id = $id

This comment has been minimized.

MarceauKa commented Oct 1, 2018

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment