All individual subscriptions are 50% off this week only!

chrisgrim
2 months ago
478
26
Laravel

Protected Fillable Not working with Vue Axios Patch

Posted 2 months ago by chrisgrim

Hi, I am building a form input and everything is working great. However I wanted to test to make sure my protected fillable was still working and I discovered I could post to my model even when I removed from protected fillable. In my information.php model I have

class Information extends Model
{
    protected $fillable = [
        'event_id','websiteUrl','ticketUrl','ageRestriction','generalPricing','militaryPricing','seniorPricing','vipPricing','allOtherPricing'
    ];
    public function event() 
    {
        return $this->hasOne(Event::class);
    }
}

I removed the studentPricing option from the array. However when I patch with Vue

  axios.patch(`${this.eventUrl}/information`, this.details)
                .then(response => {

                })
                .catch(errorResponse => {
                   
                });
            },

it updates my database column student details anyways? Here is my store method on the controller

 public function store(InformationStoreRequest $request, Event $event)
    {
        $event->information()->update($request->all());
    }

Thanks

Please sign in or create an account to participate in this conversation.