Mọi người cho e hỏi tại sao update lại không tìm đc bảng ‘tbcategory’ trong khi thêm mới thì vẫn thêm đc
Controller function:
> public function editItem(Request $request, $id){
$category = Category::find($id); $this->validate($request, [ 'txt_CateName' => 'unique: tbcategory,cateName' ], [ 'txt_CateName.unique' =>'Tên Category đã tồn tại', ] ); $category->cateName = $request->txt_CateName; $category->cateNameKD = changeTitle($request->txt_CateName); echo $category->cateName ."------".$category->cateNameKD; $category->save(); // return redirect('admin/catelist')->with('message','Sửa thành công'); }
Model:
> class Category extends Model
{ // protected $table = 'tbcategory'; public function subcategory(){ return $this->hasMany('App\SubCategory','cateID','ID'); }
public function news(){ return $this->hasManyThrough('App\News','App\SubCategory','cateID','subcateID','ID'); } }