Add delivery_note field to products for planned delivery info
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,7 @@ class ProductController extends Controller
|
|||||||
'featured' => 'boolean',
|
'featured' => 'boolean',
|
||||||
'track_stock' => 'boolean',
|
'track_stock' => 'boolean',
|
||||||
'sort_order' => 'integer',
|
'sort_order' => 'integer',
|
||||||
|
'delivery_note' => 'nullable|string|max:255',
|
||||||
]);
|
]);
|
||||||
$data['slug'] = Str::slug($data['name']);
|
$data['slug'] = Str::slug($data['name']);
|
||||||
$data['active'] = $request->boolean('active');
|
$data['active'] = $request->boolean('active');
|
||||||
@@ -91,6 +92,7 @@ class ProductController extends Controller
|
|||||||
'featured' => 'boolean',
|
'featured' => 'boolean',
|
||||||
'track_stock' => 'boolean',
|
'track_stock' => 'boolean',
|
||||||
'sort_order' => 'integer',
|
'sort_order' => 'integer',
|
||||||
|
'delivery_note' => 'nullable|string|max:255',
|
||||||
]);
|
]);
|
||||||
$data['slug'] = Str::slug($data['name']);
|
$data['slug'] = Str::slug($data['name']);
|
||||||
$data['active'] = $request->boolean('active');
|
$data['active'] = $request->boolean('active');
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
|
|
||||||
class Product extends Model
|
class Product extends Model
|
||||||
{
|
{
|
||||||
protected $fillable = ['category_id','name','slug','description','base_price','sale_price','tax_rate','weight','active','featured','track_stock','sort_order'];
|
protected $fillable = ['category_id','name','slug','description','base_price','sale_price','tax_rate','weight','active','featured','track_stock','sort_order','delivery_note'];
|
||||||
|
|
||||||
protected $casts = ['active' => 'boolean', 'featured' => 'boolean', 'track_stock' => 'boolean', 'base_price' => 'decimal:2', 'sale_price' => 'decimal:2', 'tax_rate' => 'decimal:2'];
|
protected $casts = ['active' => 'boolean', 'featured' => 'boolean', 'track_stock' => 'boolean', 'base_price' => 'decimal:2', 'sale_price' => 'decimal:2', 'tax_rate' => 'decimal:2'];
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?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('products', function (Blueprint $table) {
|
||||||
|
$table->string('delivery_note')->nullable()->after('track_stock');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void {
|
||||||
|
Schema::table('products', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('delivery_note');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -165,6 +165,12 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium mb-1">Lieferhinweis <span class="text-gray-400 font-normal">(optional, z.B. "Geplante Lieferung: Mai 2026")</span></label>
|
||||||
|
<input type="text" name="delivery_note" value="{{ old('delivery_note', $product->delivery_note ?? '') }}"
|
||||||
|
class="w-full border rounded px-3 py-2 text-sm" placeholder="z.B. Geplante Lieferung: Mai 2026">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<button type="submit" class="flex-1 bg-blue-600 text-white py-2 rounded hover:bg-blue-700 text-sm">Speichern</button>
|
<button type="submit" class="flex-1 bg-blue-600 text-white py-2 rounded hover:bg-blue-700 text-sm">Speichern</button>
|
||||||
<a href="{{ route('admin.products.index') }}" class="flex-1 text-center py-2 rounded border text-sm hover:bg-gray-50">Abbrechen</a>
|
<a href="{{ route('admin.products.index') }}" class="flex-1 text-center py-2 rounded border text-sm hover:bg-gray-50">Abbrechen</a>
|
||||||
|
|||||||
@@ -24,7 +24,13 @@
|
|||||||
<span class="text-xs text-gray-400">inkl. {{ number_format($product->tax_rate, 0) }}% MwSt.</span>
|
<span class="text-xs text-gray-400">inkl. {{ number_format($product->tax_rate, 0) }}% MwSt.</span>
|
||||||
</div>
|
</div>
|
||||||
@if($product->track_stock && $product->variants->sum('stock') <= 0)
|
@if($product->track_stock && $product->variants->sum('stock') <= 0)
|
||||||
|
@if($product->delivery_note)
|
||||||
|
<p class="text-xs text-orange-500 mt-1">📦 {{ $product->delivery_note }}</p>
|
||||||
|
@else
|
||||||
<p class="text-xs text-red-500 mt-1">Nicht vorrätig</p>
|
<p class="text-xs text-red-500 mt-1">Nicht vorrätig</p>
|
||||||
@endif
|
@endif
|
||||||
|
@elseif($product->delivery_note && !($product->track_stock && $product->variants->sum('stock') > 0))
|
||||||
|
<p class="text-xs text-orange-500 mt-1">📦 {{ $product->delivery_note }}</p>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -74,6 +74,10 @@
|
|||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if($product->delivery_note)
|
||||||
|
<p class="text-sm text-orange-500 mb-3">📦 {{ $product->delivery_note }}</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
{{-- In den Warenkorb --}}
|
{{-- In den Warenkorb --}}
|
||||||
<form method="POST" action="{{ route('cart.add') }}">
|
<form method="POST" action="{{ route('cart.add') }}">
|
||||||
@csrf
|
@csrf
|
||||||
|
|||||||
Reference in New Issue
Block a user