Added Item model, resource and its API.

Updated Category model to have Items.
This commit is contained in:
2023-06-14 17:16:50 +03:00
parent b5a264d92f
commit 18bd849827
12 changed files with 350 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Item>
*/
class ItemFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('items', function (Blueprint $table) {
$table->id();
$table->unsignedBiginteger('category_id')->unsigned();
$table->string('uuid');
$table->string('name');
$table->string('url');
$table->string('description');
$table->decimal('price', 8, 2);
$table->string('image');
$table->foreign('category_id')->references('id')
->on('categories')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('items');
}
};
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ItemSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}