How to run seeder in Laravel 5.1 with class parameter - laravel-5

I Use laravel 5.1 , I received "Class MySeederClass does not exist " when use --class in php artisan db::seed(like php artisan db::seed --class=MySeederClass) , but when I run this command without class parameter, every thing is ok, what is this parameter problam??

If somebody will have the same error just try to update your composer auto loader class with command.
composer dump-autoload

Related

Adding column using make migration command error

I'm trying to add an icon_path column to an existing table called tbl_device
by using php artisan make:migration add_icon_path_to_tbl_device_table --table=tbl_device
and after running php artisan migrate, it gives me this error.
PHP Fatal error: Cannot declare class CreateFailedJobsTable, because the name is already in use in ...path\database\migrations\<date>_create_failed_jobs_table.php
Cannot declare class CreateFailedJobsTable, because the name is already in use
I've also tried manually adding the icon_path column to the create_tbl_device_table.php migration and after running php artisan migrate it says Nothing to migrate.
I think I followed all the instructions.. any idea where I went wrong?
Call artisan migrate command only for your specific migration using:
php artisan migrate --path=/database/migrations/my_migrations
And see if it works.

no php artisan commands are working after new migration

I am new to laravel .
Following tutorial videos on laracast,i made a new migration (cmd command) like following
php artisan make:migration delete_title_from_posts_table
which gave me the message
Created Migration: 2020_02_05_185721_delete_title_from_posts_table
after that no php artisian command is working in cmd.
Any command i run gives me the following error
In Container.php line 805:
Target class [db] does not exist.
In Container.php line 803:
Class db does not exist
what would be causing this?
my laravel app version=6.2 and php version=7.3.5 on Win10 64-bit.
similar questions i already viewed,not working for me
artisan-commands-not-working-after-composer-update
in-container-php-line-805-target-class-db-does-not-exist
Since it's a facade, add this to the top of the class to make it work:
use DB;
Or use full namespace:
$tables = \DB::table...
run these commands steps by step:
composer dump-autoload clean up all compiled files and their paths
composer update --no-scripts Skips execution of scripts defined in composer.json
composer update update your project's dependencies

Laravel db:seed does not work without --class parameter

Running php artisan db:seed does not work for some reason on my Laravel 5.6 project.
The command runs (quietly) even without a database
Does not return any error on the terminal
However, when I run php artisan db:seed --class=ClassNameTableSeeder it works. What could be the cause of such a weird behavior?
NB : Similar to questions like 39521913 but not a duplicate.
This is because by default DatabaseSeeder does nothing. Original code in fresh Laravel project looks like this:
public function run()
{
// $this->call(UsersTableSeeder::class);
}
So to run any database seeder, you should uncomment this line and put valid class name, so for example:
$this->call(ClassNameTableSeeder1::class);
$this->call(ClassNameTableSeeder2::class);
and so on to run seeders for each class you put here.

Cannot create a handler in laravel 5 using php artisan

I am trying to create an event handler using php artisan but it just won't work. It works perfectly with anything else for example event.
This is what I use in the cmd:
php artisan handler:event myhandler
This is the response:
[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "handler" namespace.
Command handler:event was removed in 5.1, you can't use it anymore.
Maybe you're looking for php artisan event:generate command.

making model and migration with a single command in laravel 5.2

I've tried this artisan command as I followed a tutorial
php artisan make:model Foo -m
but I get this error:
exception 'RuntimeException' with message 'The "-m" option does not exist.'
why It's not recognizing that?
If It's a wrong way to do It , what the right one?
In short, this is how you do it.
C:\xampp\htdocs\lms>php artisan make:model Test -m
Model created successfully.
Created Migration: 2016_08_29_160434_create_tests_table
It must work. If that does not, do.
C:\xampp\htdocs\lms>composer install.
and that should work.

Resources