0
votes

I am getting this error "Call to a member function update() on array" and I have no idea why, is it because I am updating an array? I have check other resources similar to this but not much related to array so I am not sure what to do. Thank you in advance

Information: I am trying to update an HTML table but kept getting this error

Controller:

public function update1(Request $request, $id){
    $object2 = qualification::find($id);
    $object2 = array();
$object2['School'] = implode(' , ', $request->School);
$object2['SDate'] = implode(' , ', $request->SDate);
$object2['EDate'] = implode(' , ', $request->EDate);
$object2['qualification'] = implode(' , ', $request->qualification);
 $object2->update();
    return redirect('/home');
}

qualification model:

class qualification extends Eloquent
{
    protected $fillable = array('School', 'user_id', 'SDate', 'EDate', 'qualification');

    // DEFINE RELATIONSHIPS --------------------------------------------------
    public function personal_infos() {
        return $this->belongsTo('App\personal_info');
    }
}
1
Yes. Update your model instead.fubar
U mean change the things inside qualification model?blastme
@fubar I have added my qualification model into my question, shouldn't the model be like this?blastme
Yes, so what are you trying to accomplish with $object2??fubar

1 Answers

2
votes

You need to set the attributes on your Qualification model either individually, or all at once and then call save().

public function update1(Request $request, $id){
    $object2 = qualification::find($id);
    $test = array();
    $test['School'] = implode(' , ', $request->School);
    $test['SDate'] = implode(' , ', $request->SDate);
    $test['EDate'] = implode(' , ', $request->EDate);
    $test['qualification'] = implode(' , ', $request->qualification);
    $object2->update($test);
    return redirect('/home');
}