Refactored Color Livewire components, added CreateColor, EditColor, and ShowColor components. Updated views, navigation, and Tailwind color schemes. Adjusted database migrations for consistency.
This commit is contained in:
@@ -34,11 +34,11 @@ class CreateType extends Component
|
||||
$type->description = $this->description;
|
||||
$type->save();
|
||||
|
||||
return redirect()->route('type.index');
|
||||
return $this->redirectRoute('type.show', $type->id, navigate: true);
|
||||
}
|
||||
|
||||
public function cancel(){
|
||||
return redirect()->route('type.index');
|
||||
return $this->redirectRoute('type.index', navigate: true);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace App\Livewire\Type;
|
||||
|
||||
use App\Models\FilamentType;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\FilamentType as Model;
|
||||
use Livewire\Attributes\title;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
@@ -11,29 +10,41 @@ use Livewire\Component;
|
||||
#[title('Types')]
|
||||
class EditType extends Component
|
||||
{
|
||||
public FilamentType $type;
|
||||
public Model $type;
|
||||
|
||||
public string $name = '';
|
||||
public string $description = '';
|
||||
|
||||
public function mount(Model $type)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->name = $type->name;
|
||||
$this->description = $type->description;
|
||||
}
|
||||
|
||||
// Validation
|
||||
#[Validate('required')]
|
||||
|
||||
public function save() {
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'type.name' => ['required', 'string', 'max:255'],
|
||||
'type.description' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$this->type->save();
|
||||
$this->type->update([
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
]);
|
||||
|
||||
return redirect()->route('type.show', $this->type->id );
|
||||
|
||||
return $this->redirectRoute('type.show', $this->type->id, navigate: true);
|
||||
}
|
||||
|
||||
public function cancel(){
|
||||
return redirect()->route('type.index');
|
||||
public function cancel()
|
||||
{
|
||||
return $this->redirectRoute('type.index', navigate: true);
|
||||
}
|
||||
|
||||
public function mount(FilamentType $type){
|
||||
$this->type = $type;
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.type.edit', [
|
||||
|
||||
@@ -16,11 +16,11 @@ class ShowType extends Component
|
||||
public FilamentType $type;
|
||||
|
||||
public function back(){
|
||||
return redirect()->route('type.index');
|
||||
return $this->redirectRoute('type.index', navigate: true);
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
return redirect()->route('type.edit', $id);
|
||||
return $this->redirectRoute('type.edit', $id, navigate: true);
|
||||
}
|
||||
|
||||
public function mount(FilamentType $type){
|
||||
|
||||
@@ -20,15 +20,19 @@ class Type extends Component
|
||||
// Validation
|
||||
#[Validate('required')]
|
||||
|
||||
public function create() {
|
||||
@Auth::check();
|
||||
return redirect()->route('type.create');
|
||||
public function create()
|
||||
{
|
||||
return $this->redirectRoute('type.create', navigate: true);
|
||||
}
|
||||
public function edit($id){
|
||||
return redirect()->route('type.edit', $id);
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
return $this->redirectRoute('type.edit', $id, navigate: true);
|
||||
}
|
||||
public function show($id){
|
||||
return redirect()->route('type.show', $id);
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return $this->redirectRoute('type.show', $id, navigate: true);
|
||||
}
|
||||
public function delete($id){
|
||||
@Auth::check();
|
||||
|
||||
Reference in New Issue
Block a user