Renamed and reorganized Livewire components, namespaces, and views for improved file structure and clarity. Introduced filaments.show and filaments.edit routes. Updated database migrations and navigation routes accordingly. Upgraded dependencies in composer.
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Buildplate;
|
||||
|
||||
use App\Models\Buildplate as BuildplateModel;
|
||||
use App\Models\Manufacturer as Manufacturer;
|
||||
use Flux\Flux;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
#[title('Buildplates')]
|
||||
class Buildplate extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
#[Validate('required')]
|
||||
public $name = '';
|
||||
public $description = '';
|
||||
public $manufacturer_id = '';
|
||||
public $temp_max = '';
|
||||
public $amount = '';
|
||||
|
||||
public $search ='';
|
||||
|
||||
// Edit Modal + Query
|
||||
public $editquery = '';
|
||||
|
||||
public $editid = '';
|
||||
public $deleteid = '';
|
||||
|
||||
public function create() {
|
||||
@Auth::check();
|
||||
|
||||
|
||||
// Validate
|
||||
$this->validate();
|
||||
|
||||
$buildplate = new BuildplateModel();
|
||||
$buildplate->name = $this->name;
|
||||
$buildplate->description = $this->description;
|
||||
$buildplate->manufacturer_id = $this->manufacturer_id;
|
||||
$buildplate->temp_max = $this->temp_max;
|
||||
$buildplate->amount = $this->amount;
|
||||
$buildplate->save();
|
||||
|
||||
// Clear the form
|
||||
$this->resetInputFields();
|
||||
|
||||
// Close the modal
|
||||
Flux::modal('createModal')->close();
|
||||
}
|
||||
|
||||
public function edit($buildplateid) {
|
||||
@Auth::check();
|
||||
|
||||
$editid = $buildplateid;
|
||||
$this->editid = $editid;
|
||||
|
||||
$buildplate = BuildplateModel::findOrFail($editid);
|
||||
|
||||
$this->name = $buildplate->name;
|
||||
$this->description = $buildplate->description;
|
||||
$this->manufacturer_id = $buildplate->manufacturer_id;
|
||||
$this->temp_max = $buildplate->temp_max;
|
||||
$this->amount = $buildplate->amount;
|
||||
|
||||
Flux::modal('editModal')->show();
|
||||
}
|
||||
|
||||
public function save($editid) {
|
||||
@Auth::check();
|
||||
|
||||
$buildplate = BuildplateModel::findOrFail($editid);
|
||||
$buildplate->name = $this->name;
|
||||
$buildplate->description = $this->description;
|
||||
$buildplate->manufactuerer_id = $this->manufacturer_id;
|
||||
$buildplate->temp_max = $this->temp_max;
|
||||
$buildplate->amount = $this->amount;
|
||||
$buildplate->save();
|
||||
|
||||
$this->resetInputFields();
|
||||
|
||||
Flux::modal('editModal')->close();
|
||||
}
|
||||
|
||||
public function deleteModal($buildplateid) {
|
||||
@Auth::check();
|
||||
|
||||
$deleteid = $buildplateid;
|
||||
$this->deleteid = $deleteid;
|
||||
|
||||
$buildplate = BuildplateModel::findOrFail($deleteid);
|
||||
$this->name = $buildplate->name;
|
||||
$this->description = $buildplate->description;
|
||||
$this->manufacturer_id = $buildplate->manufacturer_id;
|
||||
$this->temp_max = $buildplate->temp_max;
|
||||
$this->amount = $buildplate->amount;
|
||||
|
||||
Flux::modal('deleteModal')->show();
|
||||
}
|
||||
|
||||
public function delete($deleteid) {
|
||||
@Auth::check();
|
||||
|
||||
$buildplate = BuildplateModel::findOrFail($deleteid)->delete();
|
||||
|
||||
$this->deleteid = $deleteid;
|
||||
Flux::modal('deleteModal')->close();
|
||||
|
||||
// Clear the form
|
||||
$this->resetInputFields();
|
||||
}
|
||||
|
||||
public function cancel() {
|
||||
$this->resetInputFields();
|
||||
Flux::modals()->close();
|
||||
}
|
||||
|
||||
public function resetInputFields() {
|
||||
$this->reset(['name', 'description', 'manufacturer_id', 'temp_max', 'amount', 'deleteid', 'editid']);;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.buildplate.index', [
|
||||
'buildplates' => BuildplateModel::search('name', $this->search)->paginate(20),
|
||||
'manufacturers' => Manufacturer::all(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user