Do we need the Request parameter in countryDelete function? Just curious because I didn't include it in mine. Thank you kindly for this straight to the point tutorial. It has helped me so much. Learnt everything I needed in under 1 hour.
@AtifNaseem5 жыл бұрын
You are right there is no need of Request parameter in countryDelete function because we are deleting record just by id only.
@SorrowBee_23 жыл бұрын
thanks this video helped me for the competition
@AtifNaseem3 жыл бұрын
Glad to hear it!
@raymondpang67075 жыл бұрын
thanks guys , this tutorial is very helpful because it is straight to the point which are update and delete function .but i hope you can do another video which is talking or teaching how we use a right way and "how to handle the Exception Error" when we are connecting the frontend and backend.
@raymondpang67075 жыл бұрын
by the way very thx
@AtifNaseem5 жыл бұрын
I will make a lecture soon. Thanks
@ashrafsayed10583 жыл бұрын
if any one face problem with put method in update country you can use post method also it work like a charm
@AtifNaseem3 жыл бұрын
Thanks Ashraf Sayed
@aicreatedvideosforeveryone3 жыл бұрын
i am using laravel 8 for this examples i have to change delete and update functions as below and this worked public function countryDelete(Request $request, $id){ $country = CountryModel::find($id); $country->delete(); return response()->json(null,204); }
@AtifNaseem3 жыл бұрын
great
@Thisarusaduranga4 жыл бұрын
thnks for very much..
@AtifNaseem4 жыл бұрын
Welcome!
@tothebone46135 жыл бұрын
btw don't you need to set up homestead.yawl and vagrant ?,
@AtifNaseem5 жыл бұрын
I didnt setup at this stage.
@tothebone46135 жыл бұрын
@@AtifNaseem are they required for restful api ?
@AtifNaseem5 жыл бұрын
@@tothebone4613 No. Not necessary.
@arjunmalhotra12224 жыл бұрын
Thanks sir
@AtifNaseem4 жыл бұрын
welcome.
@alexyan72453 жыл бұрын
how to get auto increment id for the next post after deleted data?
@AtifNaseem3 жыл бұрын
you can get this in response data by adding 1 in the query (get max id of the table)
@sadidhasanrakib92714 жыл бұрын
While updating, the "ID" that you have passed through api route, would not you use it to check whether the corresponding record is available or not in the database?
@AtifNaseem4 жыл бұрын
Actually I covered all the basics. You must implement record checking before updating and return messages accordingly.
@yasincimic12523 жыл бұрын
He uses model binding.
@muaazhammad44465 жыл бұрын
i think there is no need of request parameter in delete method .... ?
@AtifNaseem5 жыл бұрын
Yes you are right. I didnt use it here. You can use it with any field.
@iammuttaqi5 жыл бұрын
why do we need to pass CountryModel in parameter where updating?
@AtifNaseem5 жыл бұрын
If you auto-generate resource controller using php artisan make:model -a [ModelName] then you have the update() function like below: public function update(Request $request, ModelName $model) { // } Here, Lavarel automatically fetch the Model object into $model. So, we can save the $request using the Model object $model
@melanyadavtyan42444 жыл бұрын
I have an error in postman The PUT method is not supported for this route. Supported methods: GET,
@AtifNaseem4 жыл бұрын
change Route::get to Route::put
@auscencekanhonou4314 жыл бұрын
The postman shows me Method Not Allowed The requested method PUT is not allowed for the URL /api/contry/241.
@AtifNaseem4 жыл бұрын
check the route. is it set to put?
@yasindemirkaya29544 жыл бұрын
@@AtifNaseem mine is set to put but i'm still having the same error
@namphung75924 жыл бұрын
it return note: "Could not get any response", but the record still has deleted, and in console "Error: Parse Error", "Warning: This request did not get sent completely and might not have all the required system headers". Please help me
@AtifNaseem4 жыл бұрын
Did you test on postman?
@namphung75924 жыл бұрын
@@AtifNaseem yes, i tried to fix this error but it did not work :((
@AtifNaseem4 жыл бұрын
I can't say anything without looking your code.
@tarunahuja32304 жыл бұрын
Delete method not working on server. Saying method not allowed laravel 7
@AtifNaseem4 жыл бұрын
check the request, is it GET or POST?
@bishalsubba29034 жыл бұрын
404 page not found!!whats wrong i cant figure it
@AtifNaseem4 жыл бұрын
is your other Laravel routes are working?
@amansayeed4 жыл бұрын
i am using taking a row _z_country first I edit using the put API then delete API same row but its not perform I am getting this error . here is the error Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`api`.`_z_address`, CONSTRAINT `_z_address_country_id_foreign` FOREIGN KEY (`country_id`) REFERENCES `_z_country` (`id`)) (SQL: delete from `_z_country` where `id` = 1) in file
@AtifNaseem3 жыл бұрын
It is because of Foreign Key constraint, simply delete foreign key from Mysql table or create a query to delete child first.
@ashique120095 жыл бұрын
Here also you are not showing us your update / deleting operation code. What is coming from your request object and then how you perform your operation etc etc. Thank you.
@AtifNaseem5 жыл бұрын
Update and delete operation code is also showed, kindly watch all the videos from playlist.
@umermansoor30995 жыл бұрын
error showing 419 page expired
@AtifNaseem5 жыл бұрын
It is difficult to figure out what is missing in your code. Check your code from start.
@umermansoor30995 жыл бұрын
Csrf Token not defined
@AtifNaseem5 жыл бұрын
@@umermansoor3099 Are you using web routes?
@harrylyod34024 жыл бұрын
Hi if someone is having trouble to update the data. Change the countryUpate method to : public function countryUpdate(Request $request, $id){ $country = CountryModel::find($id); $country->update($request->all()); return response()->json($country,200); }
@AtifNaseem4 жыл бұрын
Thank you Harry
@bishalsubba29034 жыл бұрын
still having problem ...404 page not found
@aicreatedvideosforeveryone3 жыл бұрын
Yeah this is worked for me thanks
@yasincimic12523 жыл бұрын
You don't need $request paramater in countryDelete() function it could be countryDelete(Country $country);
@AtifNaseem3 жыл бұрын
You are right, Thanks Yasin Cimic.
@waleedraza80825 жыл бұрын
not fetching data
@AtifNaseem5 жыл бұрын
share your errors?
@hichembed81744 жыл бұрын
yes it didn't fetch data in Put method so I change a little bit the code and it working public function countryUpdate(Request $request, $id) { $country = CountryModel::findOrFail($id); $country->update($request->all()); return response()->json($country, 200); }
@wildhandb4 жыл бұрын
update & delete not working on me sir, thankyou🙏🏻 # onAPI Route::put('country/{id}', 'Country\CountryController@countryUpdate'); Route::delete('country/{id}', 'Country\CountryController@countryDelete'); # onController public function countryUpdate(Request $request, CountryModel $country) { $country->update($request->all()); return response()->json($country, 200); } public function countryDelete(Request $request, CountryModel $country) { $country->delete(); return response()->json(null, 204); }
@AtifNaseem4 жыл бұрын
errors?
@wildhandb4 жыл бұрын
yes sir, not running anything..
@wildhandb4 жыл бұрын
@@AtifNaseem but the other method on controller CountryController still works on me
@jorgeleon92124 жыл бұрын
si jala
@AtifNaseem4 жыл бұрын
si jala ?
@MrFranciscoooooo4 жыл бұрын
those methods for api are not the correct to use.. still you can have ::resource now in API to simplify the "routes"
@AtifNaseem4 жыл бұрын
I explained the same in the series, you will find in next videos and the reason also.