Laravel Model saving data without primary key
You might want to consider adding an id
field. It is pretty important to Laravel and packages (for aggregation, specifically)
but if you must...
Student Model: (camel case primaryKey
property)
class Student extends Eloquent {
protected $primaryKey = null;
public $incrementing = false;
protected $fillable = array('username', 'password', 'status', 'profile_id');
public function profile() {
return $this->belongsTo('Profile');
}
}
I had the same problem and couldn't use a primary key field for this table.
Since Eloquent cannot update tables like this, I solved it simply deciding updating the row in a different way:
NameOfMyTable::where('entity_type', 1)->update(['last_import' => Carbon::now()]);