Method Jenssegers\Mongodb\Schema\Grammar::compileDisableForeignKeyConstraints does not exist - laravel

I'm trying to run Laravel seeder to test my roles base permission in my project but when I run php artisan db:seed it gives me an error Method Jenssegers\Mongodb\Schema\Grammar::compileDisableForeignKeyConstraints does not exist.

Related

Seeder already exists in Laravel

I migrated the table. Also, I created a seeder and using DB class to seed it. However, I am getting an error Seeder already exists. I used php artisan clear-compiled,
composer dump-autoload, php artisan optimize before running it. Please help me.
if i will run php artian make:seed TestSeeder and TestSeeder class or file already created in seeds/ folder then this error will occur Seeder already exists in Laravel.
Remove old file in seeds/ folder and make new seeder .

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.

Laravel Tinker error with SQLite database

Starting from a fresh project:
laravel new new-project
cd new-project
touch storage/database/database.sqlite
Then at .env
DB_CONNECTION=sqlite
DB_DATABASE=storage/database/database.sqlite
DB_FOREIGN_KEYS=true
The migration succeed...
php artisan migrate
php artisan tinker
>>>App\User::all()
But when I try to get all users it returns the following error:
PHP Fatal error: Class 'App/User' not found in Psy Shell code on line 1
What I could be missing?
Recently I reinstalled Laravel...
And I didn't realized I was using version Laravel 8
the models are at /app/Models
So the right command would be:
>>>App\Models\User::all()
i think it has something to do with the namespace alias. Try without the App/
Users::all();

DatabaseMigrations Not Found In Laravel 5.0

I was watching a video of Unit Testing of Laravel 5.4, and the tutor uses
use Illuminate\Foundation\Testing\DatabaseMigrations;
and
use DatabaseMigrations;
inside the testing file
In Laravel 5.0, there are no such files and I cannot use DatabaseMigrations in my testing file.
I get error like
Fatal error: Trait 'Illuminate\Foundation\Testing\DatabaseMigrations'
not found
Are there any replacements in Laravel 5.0
Just these in command prompt "php artisan make:migration create_users_table --create=users" this will create create_users_table migration.
after that run this command "php artisan migrate" this will create users table in a database. Thanks

How to rollback mistyped migration in Laravel?

I have created a migration using the command
php artisan make:migration create_members_table.php --create=members
So it created a class name CreateMembersTable.php including .. Now I want to rollback it and to correct the class name.
php artisan migrate:rollback --step=1
and I see this error as expected:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected '.', expecting '{'
OR
In order Laravel not to notice if I delete the file manually, how to do it?
Just delete the file and create a new one. Rollbacks are used for database not the migration files itself.
Or you can rename the file and the class name and if you get errors running the migration then run composer dump-autoload.

Resources