diff --git a/backend/app/Http/Controllers/TemplateController.php b/backend/app/Http/Controllers/TemplateController.php index 577947a..c5e4085 100644 --- a/backend/app/Http/Controllers/TemplateController.php +++ b/backend/app/Http/Controllers/TemplateController.php @@ -26,7 +26,7 @@ class TemplateController extends Controller 'kategori_id' => 'required|exists:kategoris,id', 'fitur_id' => 'required|exists:fiturs,id', 'foto' => 'nullable|image|mimes:jpg,jpeg,png,gif|max:5120', - 'harga' => 'required|numeric', + 'harga' => 'required|numeric|min:0' ]); if ($request->hasFile('foto')) { @@ -44,7 +44,7 @@ class TemplateController extends Controller 'kategori_id' => 'required|exists:kategoris,id', 'fitur_id' => 'required|exists:fiturs,id', 'foto' => 'nullable|image|mimes:jpg,jpeg,png,gif|max:5120', - 'harga' => 'required|numeric', + 'harga' => 'required|numeric|min:0' ]); if ($request->hasFile('foto')) { @@ -77,6 +77,6 @@ class TemplateController extends Controller $kategoris = Kategori::all(); $fiturs = Fitur::all(); - return view('admin.templates.index', compact('templates', 'kategoris', 'fiturs', 'kategori', 'harga')); + return view('admin.templates.index', compact('templates', 'kategoris', 'fiturs', 'kategori')); } } diff --git a/backend/app/Models/Template.php b/backend/app/Models/Template.php index e1de704..03a7e6a 100644 --- a/backend/app/Models/Template.php +++ b/backend/app/Models/Template.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; class Template extends Model { - protected $fillable = ['nama_template', 'kategori_id', 'fitur_id', 'foto']; + protected $fillable = ['nama_template', 'kategori_id', 'fitur_id', 'foto', 'harga']; public function kategori() { return $this->belongsTo(Kategori::class); diff --git a/backend/database/migrations/2025_09_03_042108_create_templates_table.php b/backend/database/migrations/2025_09_03_042108_create_templates_table.php index 34594c7..f98c705 100644 --- a/backend/database/migrations/2025_09_03_042108_create_templates_table.php +++ b/backend/database/migrations/2025_09_03_042108_create_templates_table.php @@ -12,6 +12,7 @@ return new class extends Migration { $table->string('nama_template'); $table->foreignId('kategori_id')->constrained()->cascadeOnDelete(); $table->foreignId('fitur_id')->constrained()->cascadeOnDelete(); + $table->decimal('harga', 10, 2)->default(0); $table->string('foto')->nullable(); $table->timestamps(); }); diff --git a/backend/resources/views/admin/templates/index.blade.php b/backend/resources/views/admin/templates/index.blade.php index 922e2a3..ee12d49 100644 --- a/backend/resources/views/admin/templates/index.blade.php +++ b/backend/resources/views/admin/templates/index.blade.php @@ -3,102 +3,98 @@ @section('title', 'Manajemen Template') @section('content') -
- -
-

- @isset($kategori) - Template Kategori: {{ $kategori->nama }} - @else - Semua Template - @endisset -

+
+ +
+

+ @isset($kategori) + Template Kategori: {{ $kategori->nama }} + @else + Semua Template + @endisset +

- @if (!isset($kategori)) - - @endif + @if (!isset($kategori)) + + @endif +
+ + + @if (session('success')) +
+ {{ session('success') }}
+ + @endif - - @if (session('success')) -
- {{ session('success') }} -
- - @endif + @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ + @endif - @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- - @endif - - -
-
- - + +
+
+
+ + + + + + + + + + + + + @forelse($templates as $key => $template) - - - - - - - - - - @forelse($templates as $key => $template) - - - - - - - + + + + + + - - @empty - - - - @endforelse - -
NoNama TemplateKategoriFiturFotoHargaAksi
NoNama TemplateKategoriFiturFotoAksi
{{ $key + 1 }}{{ $template->nama_template }}{{ $template->kategori->nama ?? '-' }}{{ $template->fitur->deskripsi ?? '-' }} - -
- foto -
-
-
-
{{ $key + 1 }}{{ $template->nama_template }}{{ $template->kategori->nama ?? '-' }}{{ $template->fitur->deskripsi ?? '-' }} +
+ foto +
+
+ Rp {{ number_format($template->harga, 0, ',', '.') }} + +
+ +
+ @csrf + @method('DELETE') + - - @csrf - @method('DELETE') - -
-
-
Belum ada - template
-
+ +
+ + + @empty + + Belum ada template + + @endforelse + +
@@ -133,6 +129,10 @@ @endforeach
+
+ + +
@@ -140,8 +140,7 @@
- +
@@ -169,8 +168,7 @@ @@ -178,18 +176,21 @@ +
+ + +
@if ($template->foto)
Foto saat ini: -
+
foto
@@ -274,4 +275,5 @@ }); }); +
@endsection