This commit is contained in:
Meghdad committed 2026-11-26 12:29:14 +03:30
commit 647c8a8cab
236 files changed
+24692

No files matched your search

+57
View File
@@ -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