Skip to content
Discussion options

You must be logged in to vote

Hello @infiniteroles

First you need to add "risk" to the fillable on "AccountVerification" model.

Then to handle it i recommend use Accessor and Mutator in "AccountVerification" model, like this:

public function getRiskAttribute()
    {
        return $this->user ? $this->user->risk : null;
    }

    public function setRiskAttribute($value)
    {
        if ($this->user) {
            $this->user->risk = $value;
            $this->user->save();
        }
    }

Finally, with this set, you can simplify your controller field:

CRUD::addField([
            'name' => 'risk',
            'label' => 'Risk',
            'type' => 'select2_from_array',
            'allows_null' => false,
        …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@infiniteroles
Comment options

Answer selected by infiniteroles
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants