-
database/factories/ProjectFactory.php
Open in GitHubuse App\Models\Project; use App\Models\User; use Faker\Generator as Faker; $factory->define(Project::class, function (Faker $faker) { return [ 'title' => $faker->sentence, 'external_id' => $faker->uuid, 'description' => $faker->paragraph, 'user_created_id' => factory(User::class), 'user_assigned_id' => factory(User::class), 'client_id' => factory(App\Models\Client::class), 'status_id' => $faker->numberBetween($min = 1, $max = 4), 'deadline' => $faker->dateTimeThisYear($max = 'now'), 'created_at' => $faker->dateTimeThisYear($max = 'now'), 'updated_at' => $faker->dateTimeThisYear($max = 'now'), ]; });
-
database/factories/OfferFactory.php
Open in GitHubuse App\Enums\OfferStatus; use App\Models\Client; use App\Models\Lead; use App\Models\Offer; use Faker\Generator as Faker; use Ramsey\Uuid\Uuid; $factory->define(Offer::class, function (Faker $faker) { return [ 'external_id' => Uuid::uuid4()->toString(), 'client_id' => factory(Client::class), 'status' => OfferStatus::inProgress()->getStatus(), 'source_id' => factory(Lead::class), 'source_type' => Lead::class, ]; });
-
database/seeds/DemoTableSeeder.php
Open in GitHubuse App\Enums\OfferStatus; use App\Models\Project; use App\Models\User; use Illuminate\Database\Seeder; class DemoTableSeeder extends Seeder { public function run() { factory(User::class)->create([ 'id' => 2, 'external_id' => Uuid::uuid4(), 'name' => 'DaybydayCRM', 'email' => 'demo@daybydaycrm.com', 'password' => bcrypt('Daybydaycrm123'), ])->each(function ($user) { $this->createData($user); }); } // private function createData(User $user) { factory(App\Models\Client::class, rand(1,5))->create(['user_id' => $user->id])->each(function ($client) use ($user) { $project = null; if(rand(1,3) == 2) { $project = factory(Project::class)->create([ 'client_id' => $client->id, 'user_created_id' => $user->id, 'user_assigned_id' => $user->id, ]); }); factory(Lead::class, rand(3,7))->create([ 'client_id' => $client->id, 'user_created_id' => $user->id, 'user_assigned_id' => $user->id, ])->each(function ($lead) use ($user){ $offer = factory(App\Models\Offer::class)->create([ 'status' => OfferStatus::inProgress()->getStatus(), 'source_id' => $lead->id, 'client_id' => $lead->client_id, 'source_type' => Lead::class, ]); }; }); } }