mardi 6 septembre 2016

Laravel 5.1 Fillable Properties Ignored on Update

I have the following models:

class User {

    public function recruiter()
    {
        return $this->hasOne('App\Recruiter');
     }

 }

 class Recruiter extends Model {

   public function jobs()
   {
      return $this->hasMany('App\Job');
    }

 }

 class Job extends Model {

    protected $fillable = [
      'job_type_id',
      'recruiter_id',
      'start_at',
      'end_at',
      'job_title',
      'job_ref',
      'job_desc'

    ];

     // other stuff
 }

When I call the following create method the fillable properties on the Job model work as expected.

$job = Auth::user()->recruiter->jobs()->create($request->all());

When I call the update method the fillable properties are ignored and I end up with all sorts of form input fields which the Job model does not contain and thus end up with SQL errors.

Auth::user()->recruiter->jobs()->update($request->all());

Why is this happening?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire