简体   繁体   中英

How do i delete one row in my SQLite table?

I'm trying to delete one row of data from my sql table called "cart". It seems to me that it can not find the id called "cartid". im using a program called insomnia and it wont take my input it feels like.

it is gettting a error that is called :"MethodNotAllowedHttpException"

im using laravel 5.4, it is a requirement for me.

i have other functions that work and i do not understand why this one does not.

https://imgur.com/a/T0aOwJF

some snapshots from my code

i have tried to use

Route::delete('cart-remove/{id}', 'CartController@delete');

and alot more

this is in my 'api.php' file:

Route::delete('cart-remove', 'CartController@delete');

this is in my file called 'CartController':

class CartController extends Controller {

    public function delete($id) {

        DB::table('cart')->where('cartid', '=', $id)->delete();

        return response($id, 200);


    }
}

i want to get the id from my program called 'insomnia' to remove that id in my sqlite database.

Use the model's destroy method when deleting entries from the database:

use App\SomeModel;

class SomeController extends Controller {
    public function destroy($id) //or delete($id)
    {
         SomeModel::destroy($id);
         return response($id, 200);
    }
}

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