Compare commits

..

9 Commits

13 changed files with 16 additions and 103 deletions

View File

@@ -41,7 +41,7 @@ return new class extends Migration
return;
}
$sourcePath = public_path('images/website_types/onticket/'.self::FILENAME);
$sourcePath = public_path('images/website_types/'.self::FILENAME);
if (! is_file($sourcePath)) {
throw new RuntimeException("Favicon not found at path: {$sourcePath}");

View File

@@ -1,47 +0,0 @@
<?php
use App\Domains\Core\Tenant\Models\AdminWebsiteType;
use App\Domains\Core\Tenant\Services\AdminWebsiteTypeService;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
return new class extends Migration
{
public function up(): void
{
if (app()->environment('testing')) {
Storage::fake('s3');
}
if (! AdminWebsiteType::query()->where('codigo', 'shopit')->exists()) {
return;
}
app(AdminWebsiteTypeService::class)->updateOrCreate(
['codigo' => 'shopit'],
[
'primary_color' => '#2FD3AC',
'site_logo' => $this->uploadedImage('shopit_logo.png', 'image/png'),
'footer_logo' => $this->uploadedImage('shopit_footer_logo.png', 'image/png'),
'favicon' => $this->uploadedImage('shopit-favicon.svg', 'image/svg+xml'),
],
);
}
public function down(): void
{
// Brand assets are operational data and are intentionally preserved.
}
private function uploadedImage(string $filename, string $mimeType): UploadedFile
{
$path = public_path("images/website_types/shopit/{$filename}");
if (! is_file($path)) {
throw new RuntimeException("ShopIt image not found at path: {$path}");
}
return new UploadedFile($path, $filename, $mimeType, null, true);
}
};

View File

@@ -40,7 +40,7 @@ class WebsiteTypeSeeder extends Seeder
public function run(): void
{
$this->websiteTypeService->updateOrCreate(
$shopIt = $this->websiteTypeService->updateOrCreate(
['codigo' => 'shopit'],
[
'nombre' => 'ShopIt',
@@ -48,10 +48,9 @@ class WebsiteTypeSeeder extends Seeder
'scanner_domain' => 'scanner.localhost',
'site_title' => 'ShopIt',
...self::PRESENTATION,
'primary_color' => '#2FD3AC',
'site_logo' => $this->shopItLogo(),
'footer_logo' => $this->shopItFooterLogo(),
'favicon' => $this->shopItFavicon(),
'site_logo' => $this->onTicketLogo(),
'footer_logo' => $this->onTicketFooterLogo(),
'favicon' => $this->onTicketFavicon(),
],
);
@@ -84,7 +83,7 @@ class WebsiteTypeSeeder extends Seeder
...self::PRESENTATION,
'site_logo' => $this->onTicketLogo(),
'footer_logo' => $this->onTicketFooterLogo(),
'favicon' => $this->onTicketFavicon(),
'favicon' => $shopIt->favicon()->firstOrFail()->key,
],
);
@@ -205,7 +204,7 @@ class WebsiteTypeSeeder extends Seeder
private function onTicketLogo(): UploadedFile
{
$path = public_path('images/website_types/onticket/onticket_logo.png');
$path = public_path('images/website_types/onticket_logo.png');
if (! file_exists($path)) {
throw new RuntimeException("OnTicket logo not found at path: {$path}");
@@ -222,7 +221,7 @@ class WebsiteTypeSeeder extends Seeder
private function onTicketFooterLogo(): UploadedFile
{
$path = public_path('images/website_types/onticket/onticket_footer_logo.png');
$path = public_path('images/website_types/onticket_footer_logo.png');
if (! file_exists($path)) {
throw new RuntimeException("OnTicket footer logo not found at path: {$path}");
@@ -239,7 +238,7 @@ class WebsiteTypeSeeder extends Seeder
private function onTicketFavicon(): UploadedFile
{
$path = public_path('images/website_types/onticket/onticket_favicon.svg');
$path = public_path('images/website_types/onticket_favicon.svg');
if (! file_exists($path)) {
throw new RuntimeException("OnTicket favicon not found at path: {$path}");
@@ -253,30 +252,4 @@ class WebsiteTypeSeeder extends Seeder
true,
);
}
private function shopItLogo(): UploadedFile
{
return $this->uploadedImage('shopit', 'shopit_logo.png', 'image/png');
}
private function shopItFooterLogo(): UploadedFile
{
return $this->uploadedImage('shopit', 'shopit_footer_logo.png', 'image/png');
}
private function shopItFavicon(): UploadedFile
{
return $this->uploadedImage('shopit', 'shopit-favicon.svg', 'image/svg+xml');
}
private function uploadedImage(string $websiteType, string $filename, string $mimeType): UploadedFile
{
$path = public_path("images/website_types/{$websiteType}/{$filename}");
if (! file_exists($path)) {
throw new RuntimeException("Website type image not found at path: {$path}");
}
return new UploadedFile($path, $filename, $mimeType, null, true);
}
}

View File

Before

Width:  |  Height:  |  Size: 422 B

After

Width:  |  Height:  |  Size: 422 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -1,10 +0,0 @@
<svg width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:se="http://svg-edit.googlecode.com" se:swatches="W3siaWQiOiJCMDBEREFFMy0zMjUwLTRERDgtOEU0RS0zMDYxREJGNUE3QTMiLCJuYW1lIjoiIzVCNUI1QiIsImhleCI6IiM1QjVCNUIifSx7ImlkIjoiRjI4QjU4NTYtNUM2OC00QkY4LTk3MDMtOTk5NDJCOTgzNTVBIiwibmFtZSI6IiMyRkQzQUMiLCJoZXgiOiIjMkZEM0FDIn1d">
<g><se:title>Layer 1</se:title><path d="m16.32,27.13c2.29,0 3.13,-0.37 3.73,-0.76c0.65,-0.42 1.17,-1.06 1.24,-1.97c0.06,-0.76 -0.29,-1.4 -0.81,-1.78c-0.7,-0.5 -2.05,-0.81 -3.21,-1.05c-1.13,-0.24 -2.14,-0.6 -3.03,-1.22c-1.06,-0.73 -1.61,-1.47 -1.96,-2.52c-0.45,-1.32 -0.36,-3.12 -0.11,-4.02c0.43,-1.54 1.35,-2.86 2.59,-3.84001c1.6,-1.26 3.58,-2.01999 6.46,-2.17999c0.3,-0.02 0.71,-0.04 1.21,-0.04c0,0 0.16,0 0.21,0h13.3c-3.68,-4.71 -9.41,-7.75 -15.85,-7.75c-11.1,0 -20.09,9 -20.09,20.09c0,2.47 0.45,4.84 1.27,7.03h15.06l-0.01,0.01z" fill="#2FD3AC" id="svg_7"/><path d="m23.11,12.59c-0.65,0 -1.64,0.03 -1.95,0.07c-1.3,0.17 -2.25,0.55 -2.82,1.31c-0.3199,0.43 -0.48,0.99 -0.29,1.66c0.31,1.07 2.1501,1.44 3.4001,1.7c1.49,0.31 2.5599,0.57 3.5899,1.08c1.06,0.53 2.03,1.41 2.51,2.43c0.46,0.98 0.6001,1.96 0.5201,3.08c-0.11,1.56 -0.4701,2.72 -0.9901,3.69c-0.49,0.91 -1.32,1.87 -2.03,2.44c-0.74,0.59 -1.81,1.38 -3.15,1.83c-1.35,0.45 -3.1399,0.63 -5.2999,0.63h-12.30005c3.68,4.68 9.39005,7.68 15.80005,7.68c11.1,0 20.0899,-9 20.0899,-20.09c0,-2.65 -0.5199,-5.18 -1.4499,-7.5h-15.6201l-0.01,-0.01z" fill="#5B5B5B" id="svg_8"/></g></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -34,7 +34,7 @@ class SetWebsiteTypeFaviconTest extends TestCase
$this->assertSame(1, DB::table('attachments')->where('filename', 'onticket_favicon.svg')->count());
Storage::disk('s3')->assertExists($attachment->path);
$this->assertSame(
file_get_contents(public_path('images/website_types/onticket/onticket_favicon.svg')),
file_get_contents(public_path('images/website_types/onticket_favicon.svg')),
Storage::disk('s3')->get($attachment->path),
);
}

View File

@@ -23,7 +23,7 @@ class WebsiteTypeSeederTest extends TestCase
$this->assertSame(2, AdminWebsiteType::query()->count());
$this->assertSame(3, StorefrontWebsiteType::query()->count());
$this->assertSame(6, Attachment::query()->count());
$this->assertSame(5, Attachment::query()->count());
$expectedPresentation = [
'primary_color' => '#FF7006',
@@ -45,15 +45,12 @@ class WebsiteTypeSeederTest extends TestCase
$this->assertSame('ShopIt', $shopIt->nombre);
$this->assertSame('localhost', $shopIt->dominio);
$this->assertSame('scanner.localhost', $shopIt->scanner_domain);
$this->assertSame(
[...$expectedPresentation, 'primary_color' => '#2FD3AC'],
$shopIt->only(array_keys($expectedPresentation)),
);
$this->assertSame('shopit_logo.png', $shopIt->siteLogo->filename);
$this->assertSame($expectedPresentation, $shopIt->only(array_keys($expectedPresentation)));
$this->assertSame('onticket_logo.png', $shopIt->siteLogo->filename);
Storage::disk('s3')->assertExists($shopIt->siteLogo->path);
$this->assertSame('shopit_footer_logo.png', $shopIt->footerLogo->filename);
$this->assertSame('onticket_footer_logo.png', $shopIt->footerLogo->filename);
Storage::disk('s3')->assertExists($shopIt->footerLogo->path);
$this->assertSame('shopit-favicon.svg', $shopIt->favicon->filename);
$this->assertSame('onticket_favicon.svg', $shopIt->favicon->filename);
Storage::disk('s3')->assertExists($shopIt->favicon->path);
$shopItStorefront = StorefrontWebsiteType::query()->where('codigo', 'shopit')->with('extras')->sole();
$this->assertSame('standard', $shopItStorefront->header_type);
@@ -87,7 +84,7 @@ class WebsiteTypeSeederTest extends TestCase
Storage::disk('s3')->assertExists($onTicket->footerLogo->path);
$this->assertNotSame($shopIt->site_logo, $onTicket->site_logo);
$this->assertNotSame($shopIt->footer_logo, $onTicket->footer_logo);
$this->assertNotSame($shopIt->favicon_id, $onTicket->favicon_id);
$this->assertSame($shopIt->favicon_id, $onTicket->favicon_id);
$this->assertSame('onticket_favicon.svg', $onTicket->favicon->filename);
$onTicketStorefront = StorefrontWebsiteType::query()->where('codigo', 'onticket')->with('extras')->sole();
$this->assertSame('standard', $onTicketStorefront->header_type);