jeudi 27 avril 2017

Laravel Setting User Attribute

I've googled around and searched here but for the life of me I can't work out what I'm getting wrong.

I have a tinyinteger value of 'subscribed' value in a users table in laravel. I'm making mutator and accessor for it in the users model:

public function getSubscribedAttribute($value){
    return $value;
}
public function setSubscribedAttribute($value){
    //dd gives 1 if true
    //dd($value);
    $this->attributes['subscribed'] = $value;
}

and in a subscription controller, after subscribing the user in Stripe I call this:

Auth::user()->subscribed = 1;

In my migration

$table->tinyInteger('subscribed')->default(0); //0 = false, 1=true

Sorry if this is a dumb post, I'm really not sure what I'm not understanding here.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2p6BIbg
via IFTTT

Aucun commentaire:

Enregistrer un commentaire