product submission
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?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('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->string('slug')->unique();
|
||||
$table->text('description');
|
||||
$table->string('website_url');
|
||||
$table->string('thumbnail')->nullable();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('category_id')->constrained()->onDelete('cascade');
|
||||
$table->string('status')->default('pending');
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->timestamp('rejected_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('status');
|
||||
$table->index('user_id');
|
||||
$table->index('category_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('products');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CategorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$categories = [
|
||||
[
|
||||
'name' => 'Developer Tools',
|
||||
'description' => 'Tools and services for developers',
|
||||
],
|
||||
[
|
||||
'name' => 'Productivity',
|
||||
'description' => 'Apps and tools to boost productivity',
|
||||
],
|
||||
[
|
||||
'name' => 'Design',
|
||||
'description' => 'Design tools and resources',
|
||||
],
|
||||
[
|
||||
'name' => 'Marketing',
|
||||
'description' => 'Marketing tools and platforms',
|
||||
],
|
||||
[
|
||||
'name' => 'AI & Machine Learning',
|
||||
'description' => 'AI-powered tools and services',
|
||||
],
|
||||
[
|
||||
'name' => 'Analytics',
|
||||
'description' => 'Data analytics and tracking tools',
|
||||
],
|
||||
[
|
||||
'name' => 'Communication',
|
||||
'description' => 'Communication and collaboration tools',
|
||||
],
|
||||
[
|
||||
'name' => 'E-commerce',
|
||||
'description' => 'E-commerce platforms and tools',
|
||||
],
|
||||
[
|
||||
'name' => 'Education',
|
||||
'description' => 'Educational tools and platforms',
|
||||
],
|
||||
[
|
||||
'name' => 'Finance',
|
||||
'description' => 'Financial services and tools',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($categories as $category) {
|
||||
Category::create([
|
||||
'name' => $category['name'],
|
||||
'slug' => Str::slug($category['name']),
|
||||
'description' => $category['description'],
|
||||
]);
|
||||
}
|
||||
|
||||
$this->command->info('Categories created successfully!');
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ class DatabaseSeeder extends Seeder
|
||||
{
|
||||
$this->call([
|
||||
RoleSeeder::class,
|
||||
CategorySeeder::class,
|
||||
]);
|
||||
|
||||
// Uncomment to create additional users with factory
|
||||
|
||||
Reference in New Issue
Block a user