delete()".">
How to delete data in laravel: 1. Query the corresponding record according to the primary key id and return an object. The syntax is "UserModel::find($id);"; 2. Call the object to delete the specified one using the delete method. Data is sufficient, and the syntax is "$user->delete()".
#The operating environment of this article: Windows 10 system, Laravel version 6, Dell G3 computer.
How to delete data in laravel
#If you want to delete data in laravel, you must first query the corresponding record based on the primary key id and return an object. Then call the object's delete method.
For example:
$user = UserModel::find($id); return $user->delete() ? 'ok' : 'fail';
The example is as follows:
Related recommendations:The latest five Laravel video tutorials
The above is the detailed content of How to delete data in laravel. For more information, please follow other related articles on the PHP Chinese website!