Skip to content

Commit

Permalink
added seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
dipaksarkar committed Nov 5, 2022
1 parent 025ab7f commit b92f9b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion database/seeders/EnquirySeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Seeders;

use App\Models\User;
use App\Models\Admin;
use App\Models\Core\Address;
use App\Models\Core\Enquiry;
Expand All @@ -18,6 +19,12 @@ class EnquirySeeder extends Seeder
*/
public function run()
{
Enquiry::factory()->count(20)->has(Reply::factory()->has(Admin::factory(), 'user')->count(rand(3, 5)))->create();
Enquiry::factory()->for(User::factory())->count(20)->create()->each(function ($enquiry) {
for ($i = 0; $i < rand(0, 3); $i++) {
$reply = Reply::factory()->make();
$reply->user()->associate(Admin::inRandomOrder()->first());
$enquiry->replies()->save($reply);
}
});
}
}

0 comments on commit b92f9b5

Please sign in to comment.