Sylar Sylar - 1 year ago 86
PHP Question

Delete User Record in Laravel 5

Coming from a Ruby on Rails experience where you load up the rails console to delete a user or all users. I am new to Laravel 5 and I am looking for something similar to delete a user already in the sqlite3 database.

I see where people are talking about

to delete a user but where to you put that and run in? Is there a console to perform a delete task in? I would like to know how to delete a user without dropping the table. I do not want to soft delete. Thanks.

Answer Source

You can put this code for example in controller.

You can use

$user = User::find($id);    

if you don't use SoftDeletingTrait trait or

$user = User::find($id);    

if you do, and you want to really remove user from database, not just hide it from results.

More you can read at Laravel page