php - error in model laravel 5.3 -
i'm doing update blog data data has been updated except flag print data of request
but data of flag is'nt updated
here code
public function update(request $request, $id) { $data=$request->all(); //dd($request->flag); $data = $request->except(['_token']); $blog=blog::findorfail($id); $blog->update($data); // $blog->update($request->flag); dd($data); if(request()->hasfile('url_image')) { $file=$request['url_image']; $name =md5(uniqid(rand(), true)). $file->getclientoriginalname(); $request->file('url_image')->move('dezique/images/blog/', $name); $blog->url_image=('dezique/images/blog/'.$name); $blog->update(); } else { $blog->url_image=('dezique/images/blog/cafe.jpeg'); $blog->update(); } }
ths model
<?php namespace app; use illuminate\database\eloquent\model; class blog extends model { protected $table="blogs"; public function author() { return $this->belongsto('app\author'); } protected $fillable = [ 'name', 'url_image', 'description', 'blog_category_id', 'author_id', 'flag => string', 'created_at', 'updated_at', ]; }
when put flag on $fillable , put in controller $blog->update($request->flag);
got error enter image description here
update method require array parameter. can use $blog->save()
update image
and on $fillable change 'flag => string'
flag
Comments
Post a Comment