0

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
  • I'm not sure how that would affect anything because $username would have had to have been defined as some other instance of App\User before it would work? Commented Jun 16, 2016 at 20:40

1 Answer 1

3

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();

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

2 Comments

Thanks, is there any documentation specifically handling databases in Tinker? I couldn't find much online. Cheers
Just think of Tinker as being a PHP file that you execute line-by-line. Anything you can write in your Model files you can write in Tinker. If you are looking for something to use as far as checking out your database entries from a high level, I'd recommend the program SequelPro

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.