Laravel one to many table seed is not seeded as expected

So I have a relationship table like this ERD. I’m using eloquent database relationship in laravel to manage the foreign key. It worked, but the data added is skipping one row. This is how I seed the database. public function run(): void { User::factory() ->has(FavPlant::factory(),’fav_Plant’) ->count(5) ->create(); Plants::factory() ->has(FavPlant::factory(),’fav_Plant’) ->count(5) ->create(); } How do I… Read More Laravel one to many table seed is not seeded as expected

Laravel seeder with relation fill only one column

I have an issue with my migrations and my seeder. I just want seed a product table with category as relations. Here my Product seeder : $product = Product::firstOrCreate( [‘name’ => ‘Bla bla bla’], [‘category_id’ => rand(1,4)], [‘code’ => "SP" . rand(1, 50) ], [‘description’ => "Bla bla bla"], [‘actual_price’ => rand(100, 10000) / 100],… Read More Laravel seeder with relation fill only one column

Why doesn't this seeder class code work in production?

I have this seeder class that works/runs in my development setup: class OwnerSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { if(config(‘owner.owner_first_name’)) { $user = User::firstOrCreate( [’email’ => config(‘owner.owner_email’)], [ ‘first_name’ => config(‘owner.owner_first_name’), ‘last_name’ => config(‘owner.owner_last_name’), ‘mobile_phone_number’ => config(‘owner.owner_mobile_phone_number’), ‘password’ => bcrypt(config(‘owner.owner_password’)), ’email_verified_at’ => now(),… Read More Why doesn't this seeder class code work in production?

Class "App\Http\Controllers\Survey" not found

Good day. My group our currently working in our final project using Laravel. I have this problem that I encounter. <?php namespace Database\Seeders; use Illuminate\Database\Seeder; use app\database\seeders\Survey; class SurveySeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { $survey = Survey::create([‘name’ => ‘Register Form’, ‘settings’ =>… Read More Class "App\Http\Controllers\Survey" not found