while adding a user in PHP artisan tinker on laracasts/laravel-5-from-scratch/episodes/10, I accidentally typed $username->username = 'JohnDoe'; instead of $user->username = 'JohnDoe'; So the $username does not exist and is, therefore causing an issue when trying to save a user. How do I find $username and delete it? Thanks
1 Answer
If you have a small enough users table, which I am assuming you do because you're running through Jeffrey's tutorials, I'd do something like this to track down that bad row.
App\User::all(), find the id of the User you want to delete, then run App\User::find(<THE ID OF THE ONE TO DELETE>)->delete();
2 Comments
Clinton Green
Thanks, is there any documentation specifically handling databases in Tinker? I couldn't find much online. Cheers
$usernamewould have had to have been defined as some other instance ofApp\Userbefore it would work?