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
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();
}
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
}
@LonnyX - Are you saying that I have to do this $smedata->bus_address = $request->bus_address for each form element before saving?
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));
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community