Add External URL Field to Product Schema and Localization: Introduced an 'external_url' field in the ProductForm for enhanced product management. Updated the Product model to include this new field and created a migration to add it to the products table. Enhanced localization support by adding relevant translations in both English and Turkish language files. Updated the menu-item Blade component to utilize the external URL, allowing links to open in a new tab if provided, improving user experience.
This commit is contained in:
@@ -61,6 +61,10 @@ class ProductForm
|
||||
->label(__('products.view_template'))
|
||||
->placeholder(__('products.view_template_placeholder'))
|
||||
->helperText(__('products.view_template_helper')),
|
||||
TextInput::make('external_url')
|
||||
->label(__('products.external_url'))
|
||||
->url()
|
||||
->helperText(__('products.external_url_helper')),
|
||||
TextInput::make('sort_order')
|
||||
->label(__('products.sort_order'))
|
||||
->numeric()
|
||||
|
||||
@@ -19,6 +19,7 @@ class Product extends Model
|
||||
'hero_image',
|
||||
'content',
|
||||
'view_template',
|
||||
'external_url',
|
||||
'sort_order',
|
||||
'is_active',
|
||||
'landing_page_data',
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('products', function (Blueprint $table) {
|
||||
$table->string('external_url')->nullable()->after('view_template');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('external_url');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -17,6 +17,8 @@ return [
|
||||
'view_template' => 'Custom View Path',
|
||||
'view_template_placeholder' => 'e.g. front.products.custom-page',
|
||||
'view_template_helper' => 'Leave empty to use the default landing page.',
|
||||
'external_url' => 'External URL',
|
||||
'external_url_helper' => 'If filled, the menu link will open this URL in a new tab.',
|
||||
'sort_order' => 'Sort Order',
|
||||
'is_active' => 'Active',
|
||||
'translations_section' => 'Translations',
|
||||
|
||||
@@ -17,6 +17,8 @@ return [
|
||||
'view_template' => 'Özel Görünüm Yolu',
|
||||
'view_template_placeholder' => 'örn: front.products.ozel-sayfa',
|
||||
'view_template_helper' => 'Varsayılan şablonu kullanmak için boş bırakın.',
|
||||
'external_url' => 'Harici URL',
|
||||
'external_url_helper' => 'Eğer dolu ise, menüde bu linke yeni sekmede gidilir.',
|
||||
'sort_order' => 'Sıralama',
|
||||
'is_active' => 'Aktif',
|
||||
'translations_section' => 'Çeviriler',
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<ul class="pl-0 list-none">
|
||||
@foreach($services as $service)
|
||||
<li class="w-full">
|
||||
<a class='dropdown-item hover:!text-[#e31e24] !pl-0 !bg-transparent' href="{{ route('products.show', $service->slug) }}">{{ $service->translate('title') }}</a>
|
||||
<a class='dropdown-item hover:!text-[#e31e24] !pl-0 !bg-transparent' href="{{ $service->external_url ? $service->external_url : route('products.show', $service->slug) }}" @if($service->external_url) target="_blank" @endif>{{ $service->translate('title') }}</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@@ -47,7 +47,8 @@
|
||||
@foreach($featuredProducts as $item)
|
||||
<div class="flex-none " style="width: 183px;">
|
||||
<a class="group !bg-transparent !p-0 block transition-transform duration-300 hover:-translate-y-1"
|
||||
href="{{ route('products.show', $item->slug) }}"
|
||||
href="{{ $item->external_url ? $item->external_url : route('products.show', $item->slug) }}"
|
||||
@if($item->external_url) target="_blank" @endif
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="{{ $item->translate('title') }}">
|
||||
|
||||
Reference in New Issue
Block a user