Laravel Mutator to add predefined values into database

I'm new into Laravel and I'm trying to store the user's company id on a column of the products table each time a user creates a new product. The company's id it's retrieved from the user's session. I'm trying it with Laravel's Mutator:

public function setFirstNameAttribute($value) {
$this->attributes['company_id'] = session()->get('company.id');
}

But each time I create a new Product the company id stored it's null. Seems like the function it's never executing. Is there any other resource to perform actions like this?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3l5eVdj
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

5 Free Black and White Social Media Icons Sets with CSS and HTML

How to Create Treeview with Bootstrap and jQuery

How to Change Apache and MySQL Port Number in XAMPP Localhost