init
This commit is contained in:
236 files changed
+24692
No files matched your search
@@ -0,0 +1,3 @@
|
||||
*.sqlite*
|
||||
*.db
|
||||
*.db-*
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedSmallInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->string('connection');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
|
||||
$table->index(['connection', 'queue', 'failed_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table): void {
|
||||
$table->boolean('is_staff')->default(false);
|
||||
});
|
||||
|
||||
Schema::create('collections', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$this->localizedCopy($table);
|
||||
$table->string('cover')->nullable();
|
||||
$table->timestamp('published_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('designs', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('collection_id')->constrained()->restrictOnDelete();
|
||||
$this->localizedCopy($table);
|
||||
$table->decimal('width_cm', 6, 2);
|
||||
$table->decimal('height_cm', 6, 2);
|
||||
$table->string('original_path');
|
||||
$table->string('artwork_path')->nullable();
|
||||
$table->boolean('illustrative')->default(false);
|
||||
$table->timestamp('published_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('garment_templates', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('name_fa');
|
||||
$table->string('name_en');
|
||||
$table->string('garment');
|
||||
$table->string('color');
|
||||
$table->string('side')->default('front');
|
||||
$table->string('photo')->unique();
|
||||
$table->unsignedInteger('photo_width_px');
|
||||
$table->decimal('pixels_per_cm', 8, 3);
|
||||
$table->json('placements');
|
||||
$table->boolean('illustrative')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
private function localizedCopy(Blueprint $table): void
|
||||
{
|
||||
foreach (['fa', 'en'] as $locale) {
|
||||
$table->string("name_$locale");
|
||||
$table->string("slug_$locale")->unique();
|
||||
$table->text("description_$locale");
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('garment_templates');
|
||||
Schema::dropIfExists('designs');
|
||||
Schema::dropIfExists('collections');
|
||||
Schema::table('users', function (Blueprint $table): void {
|
||||
$table->dropColumn('is_staff');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table): void {
|
||||
$table->string('key')->primary();
|
||||
$table->json('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('garment_templates', function (Blueprint $table): void {
|
||||
$table->unique(['garment', 'color', 'side']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('garment_templates', function (Blueprint $table): void {
|
||||
$table->dropUnique(['garment', 'color', 'side']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('design_daily_views', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('design_id')->constrained()->cascadeOnDelete();
|
||||
$table->date('viewed_on')->index();
|
||||
$table->unsignedBigInteger('views');
|
||||
$table->unique(['design_id', 'viewed_on']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('design_daily_views');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Collection;
|
||||
use App\Models\Design;
|
||||
use App\Support\Artwork;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$rose = Collection::firstOrCreate(['slug_en' => 'rose-and-thorn'], [
|
||||
'slug_fa' => 'رز-و-خار',
|
||||
'name_fa' => 'رز و خار',
|
||||
'name_en' => 'Rose & Thorn',
|
||||
'description_fa' => 'رزهای سرخ، خارهای سیاه و نقشهای گوتیک برای لباسهای روزمره.',
|
||||
'description_en' => 'Crimson roses, black thorns, and gothic motifs for everyday clothes.',
|
||||
'cover' => 'porint/rose-sheet.webp',
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
Collection::firstOrCreate(['slug_en' => 'sound-wave'], [
|
||||
'slug_fa' => 'موج-صدا',
|
||||
'name_fa' => 'موج صدا',
|
||||
'name_en' => 'Sound Wave',
|
||||
'description_fa' => 'از صفحهٔ وینیل تا هدفون، گیتار و ضربان موسیقی.',
|
||||
'description_en' => 'Vinyl, headphones, guitars, and the pulse of music.',
|
||||
'cover' => 'porint/sound-sheet.webp',
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
if (! Design::where('slug_en', 'skull-and-roses')->exists()) {
|
||||
$source = 'originals/demo-skull-roses.png';
|
||||
Storage::disk('local')->put($source, file_get_contents(database_path('seeders/artwork/skull-roses.png')));
|
||||
Design::create([
|
||||
'collection_id' => $rose->id,
|
||||
'slug_fa' => 'جمجمه-و-رز',
|
||||
'slug_en' => 'skull-and-roses',
|
||||
'name_fa' => 'جمجمه و رز',
|
||||
'name_en' => 'Skull & Roses',
|
||||
'description_fa' => 'جمجمهٔ نقرهای، رزهای سرخ و شاخههای خاردار. طرح را روی تیشرت یا هودی در رنگهای مختلف ببینید.',
|
||||
'description_en' => 'An engraved silver skull among crimson roses and thorns. See the motif on a tee, hoodie, or crewneck.',
|
||||
'original_path' => $source,
|
||||
'artwork_path' => app(Artwork::class)->prepare($source),
|
||||
'width_cm' => 18,
|
||||
'height_cm' => 24,
|
||||
'illustrative' => true,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
$this->call(GarmentTemplateSeeder::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\GarmentTemplate;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class GarmentTemplateSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$colors = ['ink', 'paper', 'navy', 'olive'];
|
||||
$frontAnchors = [
|
||||
'tee' => ['chest' => 42, 'upper-front' => 34, 'mid-front' => 53, 'lower-front' => 66],
|
||||
'hoodie' => ['chest' => 42, 'upper-front' => 40, 'mid-front' => 44],
|
||||
'crewneck' => ['chest' => 43, 'upper-front' => 34, 'mid-front' => 54, 'lower-front' => 65],
|
||||
'oversized-tee' => ['chest' => 43, 'upper-front' => 34, 'mid-front' => 53, 'lower-front' => 65],
|
||||
'long-sleeve' => ['chest' => 42, 'upper-front' => 33, 'mid-front' => 53, 'lower-front' => 65],
|
||||
'polo' => ['chest' => 50, 'mid-front' => 58, 'lower-front' => 68],
|
||||
];
|
||||
|
||||
foreach ($frontAnchors as $garment => $anchors) {
|
||||
$placements = [];
|
||||
foreach ($anchors as $key => $y) {
|
||||
$width = $key === 'chest' ? 34 : 30;
|
||||
$height = $garment === 'hoodie' && $key !== 'chest' ? 24 : 28;
|
||||
$placements[$key] = $this->placement(50, $y, $width, $height);
|
||||
}
|
||||
|
||||
$left = $garment === 'polo' ? 61 : 58;
|
||||
$placements['left-chest'] = $this->placement($left, 35, 12, 15);
|
||||
$placements['right-chest'] = $this->placement(100 - $left, 35, 12, 15);
|
||||
|
||||
foreach ($garment === 'crewneck' ? [...$colors, 'crimson'] : $colors as $color) {
|
||||
$this->saveTemplate($garment, $color, 'front', $placements);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($colors as $color) {
|
||||
$this->saveTemplate('tee', $color, 'back', [
|
||||
'back' => $this->placement(50, 45, 32, 30),
|
||||
'upper-back' => $this->placement(50, 34, 30, 25),
|
||||
'lower-back' => $this->placement(50, 63, 30, 28),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function placement(int $x, int $y, int $width, int $height): array
|
||||
{
|
||||
return ['x' => $x, 'y' => $y, 'max_width_cm' => $width, 'max_height_cm' => $height];
|
||||
}
|
||||
|
||||
private function saveTemplate(string $garment, string $color, string $side, array $placements): void
|
||||
{
|
||||
$file = $side === 'front' ? "$garment-$color" : "$garment-$color-back";
|
||||
$photo = "porint/garments/$file.webp";
|
||||
[$width] = getimagesize(public_path($photo));
|
||||
|
||||
$nameFa = __("studio.garment_labels.$garment", [], 'fa').' '.__("studio.color_labels.$color", [], 'fa');
|
||||
$nameEn = __("studio.color_labels.$color", [], 'en').' '.__("studio.garment_labels.$garment", [], 'en');
|
||||
|
||||
GarmentTemplate::firstOrCreate(['garment' => $garment, 'color' => $color, 'side' => $side], [
|
||||
'name_fa' => $side === 'back' ? "$nameFa (پشت)" : $nameFa,
|
||||
'name_en' => $side === 'back' ? "$nameEn (back)" : $nameEn,
|
||||
'photo' => $photo,
|
||||
'photo_width_px' => $width,
|
||||
'pixels_per_cm' => round(5.9 * $width / 627, 3),
|
||||
'placements' => $placements,
|
||||
'illustrative' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
Reference in new issue
Block a user