Merge branch 'laravel-12' into 'LivewireViews'

# Conflicts:
#   resources/views/components/footer.blade.php
#   resources/views/components/layouts/app.blade.php
#   routes/web.php
This commit is contained in:
Iridium34
2025-03-15 21:54:38 +00:00
7 changed files with 143 additions and 55 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Livewire\Color;
use Livewire\WithPagination;
use Livewire\Attributes\Validate;
use Livewire\Component;
use Livewire\Attributes\title;
use Illuminate\Support\Facades\Auth;
use App\Models\Color;
#[title('Colors')]
class Index extends Component
{
use WithPagination;
#[Validate('required')]
public $name = '';
#[Validate('required')]
public $hex = '';
public function create() {
// Validate
$this->validate();
// Create the color
Color::create([
$this->all()
]);
// Clear the form
$this->reset(['name', 'hex']);
}
public function delete(Color $color) {
@Auth::check();
$color->delete();
}
public function render()
{
return view('livewire.color.index', [
'colors' => Color::paginate(10)
]);
}
}
+2
View File
@@ -4,7 +4,9 @@ namespace App\Livewire;
use Livewire\Component;
use App\Models\Manufacturer;
use Livewire\Attributes\title;
#[title('Dashboard')]
class Dashboard extends Component
{
public function render()
+4 -2
View File
@@ -1,5 +1,7 @@
<div class="py-6 px-4 sm:px-6 lg:px-8">
<div class="bg-zinc-700 w-full border-b border-accent">
<div class="container mx-auto py-6 px-4 sm:px-6 lg:px-8">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ $slot }}
</h2>
</div>
</div>
</div>
@@ -20,16 +20,17 @@
@livewireStyles
@fluxAppearance
<title>{{ $title . ' | ' . config('app.name', 'Laravel') ?? config('app.name', 'Laravel') }}</title>
<title>{{ $title . ' | ' . config('app.name') ?? config('app.name') }}</title>
</head>
<body class="font-sans antialiased">
<body class="font-sans antialiased bg-zinc-800">
<x-navbar />
{{ $slot }}
<x-footer/>
<x-footer />
@stack('modals')
@livewireScripts
@fluxScripts
</body>
</html>
@@ -0,0 +1,43 @@
<section>
<x-header>
{{ __('Colors') }}
</x-header>
<div class="container m-auto my-8 bg-zinc-700 rounded">
<form method="POST" class="flex flex-col gap-4" wire:submit="create">
@csrf
<div class="flex justify-center gap-8 py-4">
<label class="text-lg content-center">New Color</label>
<input type="text" placeholder="Name" wire:model="name" class="bg-zinc-800 rounded" required/>
<input type="text" placeholder="Hex" wire:model="hex" class="bg-zinc-800 rounded" required/>
<button type="submit" class="bg-green-500 hover:bg-green-700 text-zinc-800 hover:text-white font-bold py-2 px-4 rounded cursor-pointer">Submit</button>
</div>
</form>
</div>
<div class="container m-auto my-8 bg-zinc-700">
<table class="w-full">
<thead class="bg-zinc-900">
<tr class="text-left">
<th class="px-8 py-4 font-bold text-lg">Name</th>
<th class="px-8 py-4 font-bold text-lg text-center">Color</th>
<th class="px-8 py-4 font-bold text-lg text-center">Hex</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach ($colors as $color)
<tr wire:key="{{ $color->id }}" class="border-b border-zinc-600 hover:bg-zinc-600 transition duration-200">
<td><p class="p-4 pl-8">{{ $color->name }}</p></td>
<td><div class="w-8 h-8 rounded mx-auto" style="background-color: {{ $color->hex }}"></div></td>
<td><p class="p-4 text-center">{{ $color->hex }}</p></td>
<td class="text-right pr-8"><button type="button" wire:click="delete({{ $color->id }})" wire:confirm="Are you sure?" class="text-accent p-4 cursor-pointer"><flux:icon.x-mark/></button></td>
</tr>
@endforeach
</tbody>
</table>
<div class="p-4">
{{ $colors->links() }}
</div>
</div>
</section>
+38 -46
View File
@@ -1,49 +1,41 @@
<div>
<x-app-layout>
<x-slot name="header">
{{ __('Dashboard') }}
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div class="col-span-2">
<x-card>
<h3>
Manufacturers
</h3>
@foreach ($manufacturers as $manufacturer)
{{ $manufacturer->name }}
{{ $manufacturer->filament_count }}
@endforeach
</x-card>
</div>
<div class="col-span-1">
<x-card>
<h3>
Filaments
</h3>
</x-card>
</div>
<div class="col-span-1">
<x-card>
<h3>
Types
</h3>
</x-card>
</div>
<div class="col-span-2">
<x-card>
<h3>
Colors
</h3>
</x-card>
</div>
</div>
</div>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div class="col-span-2">
<x-card>
<h3>
Manufacturers
</h3>
@foreach ($manufacturers as $manufacturer)
{{ $manufacturer->name }}
{{ $manufacturer->filament_count }}
@endforeach
</x-card>
</div>
<div class="col-span-1">
<x-card>
<h3>
Filaments
</h3>
</x-card>
</div>
<div class="col-span-1">
<x-card>
<h3>
Types
</h3>
</x-card>
</div>
<div class="col-span-2">
<x-card>
<h3>
Colors
</h3>
</x-card>
</div>
</div>
</x-app-layout>
</div>
</div>
</div>
+3 -1
View File
@@ -9,6 +9,7 @@ use App\Http\Controllers\ManufacturerController;
use App\Livewire\Types\Index;
use App\Livewire\Dashboard;
use App\Livewire\Color\Index;
Route::get('/', function () {
return view('welcome');
@@ -31,5 +32,6 @@ Route::middleware([
// Manufacturers
Route::resource('manufacturers', ManufacturerController::class);
Route::get('refresh', [ManufacturerController::class, 'refresh'])->name('refresh');
Route::get('colors', Index::class)->name('colors.index');
});