Updated Buildplate Forms
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Livewire\Filament;
|
||||
|
||||
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;
|
||||
@@ -16,6 +18,10 @@ class Buildplate extends Component
|
||||
|
||||
#[Validate('required')]
|
||||
public $name = '';
|
||||
public $description = '';
|
||||
public $manufacturer_id = '';
|
||||
public $temp_max = '';
|
||||
public $amount = '';
|
||||
|
||||
public $search ='';
|
||||
|
||||
@@ -25,10 +31,82 @@ class Buildplate extends Component
|
||||
public $editid = '';
|
||||
public $deleteid = '';
|
||||
|
||||
|
||||
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.filament.buildplate', [
|
||||
'buildplates' => BuildplateModel::search('name', $this->search)->paginate(20)
|
||||
'buildplates' => BuildplateModel::search('name', $this->search)->paginate(20),
|
||||
'manufacturers' => Manufacturer::all(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,16 @@ class Type extends Component
|
||||
|
||||
public $editid = '';
|
||||
public $deleteid = '';
|
||||
|
||||
|
||||
public $amount = '0';
|
||||
|
||||
|
||||
public function create() {
|
||||
@Auth::check();
|
||||
|
||||
|
||||
// Validate
|
||||
$this->validate();
|
||||
$this->validate();
|
||||
|
||||
$type = new FilamentType();
|
||||
$type->name = $this->name;
|
||||
@@ -56,20 +58,20 @@ class Type extends Component
|
||||
|
||||
$this->name = $type->name;
|
||||
$this->description = $type->description;
|
||||
|
||||
|
||||
Flux::modal('editModal')->show();
|
||||
}
|
||||
|
||||
public function save($editid) {
|
||||
@Auth::check();
|
||||
|
||||
|
||||
$type = FilamentType::findOrFail($editid);
|
||||
$type->name = $this->name;
|
||||
$type->description = $this->description;
|
||||
$type->save();
|
||||
|
||||
$this->resetInputFields();
|
||||
|
||||
|
||||
Flux::modal('editModal')->close();
|
||||
}
|
||||
public function deleteModal($typeid) {
|
||||
@@ -108,6 +110,7 @@ class Type extends Component
|
||||
{
|
||||
return view('livewire.filament.type', [
|
||||
'types' => FilamentType::search('name', $this->search)->paginate(10)
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user