0

This is why i can't delete by ID, even the code is inactive at id, its a JS file. This is why i can't delete by ID, even the code is inactive at id

This is my delete function in controller

> public function destroy(Estate $estates)
>     {
>         if ($estates->delete()) {
>             return response()->json([
>                 'message' => 'Estate deleted successfully',
>                 'status_code' => 200
>             ], 200);
>         } else {
>             return response()->json([
>                 'message' => 'Can not delete, Some error occured, please try again later',
>                 'status_code' => 500
>             ], 500);
>         }
>     }

Below is my Vue method to initiate the delete method first is my button second is my delete method

<button class="btn btn-danger btn-sm" v-on:click="deleteEstate(estate)"> <span class="fas fa-trash-alt"></span></button>
   
>        deleteEstate: async function(estate) {
>         if (!window.confirm('Are You sure you want to delete this Estate Record!')) {
>            return;
>         }
> 
>         try {
>             await estateService.deleteEstate(estate.id);
> 
>             this.estate = this.estate.filter(obj => {
>               return obj.id != estate.id;
>             });
>         } catch (error) {
>           
>         }
>       }

this is my result on delete, need some help! this is my result on delete, need some help

1
  • You might have to do a bit of troubleshooting. Try Log::info("Deleting ".$estates->id); at the top of your destroy function, and check your log file (/storage/logs) to make sure it's got the correct ID. Surround the delete in a try/catch block and see if there's an exception being thrown. Commented Oct 15, 2021 at 13:19

2 Answers 2

1

In your deleteEstate() you're using single quotes '' but ${} operator needs the backquote `` in order to work. Try changing it.

Sign up to request clarification or add additional context in comments.

Comments

1

You are sending /estate/{id} to your backend. You should wrap the string in backticks `.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.