Eloquent Collection: Counting and Detect Empty

This may be a trivial question but I am wondering if Laravel recommends a certain way to check whether an Eloquent collection returned from $result = Model::where(…)->get() is empty, as well as counting the number of elements. We are currently using !$result to detect empty result, is that sufficient? As for count($result), does it actually … Read more

Rollback one specific migration in Laravel

I want to rollback only : Rolled back: 2015_05_15_195423_alter_table_web_directories I run php artisan migrate:rollback, 3 of my migration are rolling back. Rolled back: 2015_05_15_195423_alter_table_web_directories Rolled back: 2015_05_13_135240_create_web_directories_table Rolled back: 2015_05_13_134411_create_contacts_table I delete both of my web_directories and my contacts table unintentionally. I never want that to happen, and if I can rollback only that specific … Read more

How can I remove a package from Laravel using PHP Composer?

What is the correct way to remove a package from Laravel using PHP Composer? So far I’ve tried: Remove declaration from file composer.json (in the “require” section) Remove any class aliases from file app.php Remove any references to the package from my code 🙂 Run composer update Run composer dump-autoload None of these options are … Read more