简体   繁体   中英

Base table or view not found: 1146 Table 'admin.model' doesn't exist

How to fix this error. I am trying to update data in table. This is my controller

 public function update($id)
    {
        $input = request()->all();

        return response()->json(['success' => true], 200);
    }

This is my model

namespace App\Models\Models;

use Illuminate\Database\Eloquent\Model;

class ModelsCategory extends Model
{

    protected $table = 'models_categories';

    protected $guarded  = ['id'];

}

You have not made any updates within the function

Make changes like me

public function update(Requeat $request, $id)
{

    ModelsCategory::where("id",$id)->update([
      // Herer set your column and data like this
          'tiltle'=>$request->title,
    ]);

    return response()->json(['success' => true], 200);
}

Or you can use this.

first change route like this:

 Route::post("/category/{modelscategory}","categorycontroller@update")

update mthod

public function update(Requeat $request, ModelsCategory $modelscategory)
{
    $modelscategory->title=$request->title;

    $modelscategory->save();
    return response()->json(['success' => true], 200);
}

I hope I helped

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM