Support the ongoing development of Laravel.io →
Eloquent Forms Database
Last updated 2 years ago.
0

Could be a mass assignment issue? In your model have you set the $fillable property? It should be an array of fields that the model will accept. You can read more about it here: http://laravel.com/docs/5.1/eloquent#mass-assignment

0

Thanks for your feedback robgeorgeuk, i have added this to my model and i still get the same result :(

class Sme extends Model
{
    protected $table='sme';
    protected $fillable = array('country_id',
                                'bus_name',
                                'bus_address',
                                'province_id',
                                'town_id',
                                'suburb_id',
                                'bus_postal',
                                'reg_number',
                                'vat_number',
                                'bus_contact_number',
                                'bus_email',
                                'cat_id',
                                'bus_contact_person',
                                'person_number',
                                'person_email',
                                'rec_number',
                                'sec_discount',
                                'vip_discount',
                                'rec_discount',
                                'ref_discount',
                                'cus_discount',
                                'total_alloc'
                                );
}

If i do this in my controller to test it works and adds the bus_address value:

public function store(SmeAddDataRequest $request)
    {
        $smedata = new Sme;
        $smedata->bus_address = $request->bus_address;
        $smedata->save();


    }
Last updated 9 years ago.
0

Try this:

 public function store(SmeAddDataRequest $request)
    {
        $smedata = Sme::create($request->except('_token'));
       //please note that i discourage you to use this method for security reason, you have to put one by one

    }
0

@LonnyX - Are you saying that I have to do this $smedata->bus_address = $request->bus_address for each form element before saving?

0

you can do this:

class Sme extends Model
{
   public static  $createFields = ['define', 'fields', 'you', 'need', 'to', 'fill', 'with'] ;

}

 $smedata = Sme::create($request->only(Sme::createFields));

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

AtomicRSA atomicrsa Joined 24 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.