Tuesday, April 11, 2017

Laravel ->save() storing variable but not storing data into the database

Having a little issue with Laravel. I have two models (Customer + View), with three tables (customer, customer_vehicle, vehicle) with the customer_vehicle being a pivot table.

I added data fine earlier, and it stored in the database. However now, when I try to run save() it returns true, however does not store in the database. And can only be accessed as a variable.

Current Code in Tinker:

>>> $vehicle->registration="P3N 3LO";
=> "P3N 3LO"
>>> $vehicle->make="Volkswagen";
=> "Volkswagen"
>>> $vehicle->model="Golf";
=> "Golf"
>>> $vehicle->year_of_manufacture="2012";
=> "2012"
>>> $vehicle->save();
=> true

When I switch to Sequel Pro, the data isn't stored but can be accessed when I run vehicle::ScreenTec\Models\Vehicle::find($id);



via Jessica Wallace

Advertisement