finish basic crud api
This commit is contained in:
13
database/factories/EventCategoryFactory.php
Normal file
13
database/factories/EventCategoryFactory.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\Models\EventCategory;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(EventCategory::class, function (Faker $faker) {
|
||||
return [
|
||||
'name' => $faker->words(3, [false]),
|
||||
'description' => $faker->words(rand(10, 30), [false]),
|
||||
];
|
||||
});
|
||||
23
database/factories/EventFactory.php
Normal file
23
database/factories/EventFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\EventCategory;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(Event::class, function (Faker $faker) {
|
||||
$startDate = $faker->dateTimeThisMonth;
|
||||
$endDate = $faker->dateTimeBetween($startDate, date_add($startDate, date_interval_create_from_date_string('10 days')));
|
||||
$endDate = (rand(0, 1) === 0) ? null : $endDate;
|
||||
return [
|
||||
'user_id' => factory(\App\User::class),
|
||||
'category_id' => factory(EventCategory::class),
|
||||
'name' => $faker->words(3, [false]),
|
||||
'description' => $faker->words(rand(10, 300), [false]),
|
||||
'private' => rand(0,1),
|
||||
'start_date' => $startDate,
|
||||
'end_date' => $endDate,
|
||||
'location' => $faker->city,
|
||||
];
|
||||
});
|
||||
@@ -19,6 +19,7 @@ class CreateEventsTable extends Migration
|
||||
$table->unsignedBigInteger('category_id');
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('private')->default(true);
|
||||
$table->timestamp('start_date');
|
||||
$table->timestamp('end_date')->nullable();
|
||||
$table->string('location')->nullable();
|
||||
|
||||
Reference in New Issue
Block a user