PATH:
home
/
rwabteecom
/
project_11
/
app
/
Helpers
/
Editing: Switcher.php
<?php namespace App\Helpers; class Switcher { private string $switcherModel; private int $switcherModelId; private ?string $switcher_column_name = "status"; private bool $status = false; public function model(object $model): self { $this->switcherModel = get_class($model); return $this; } public function column(string $column_name = "status"): self { $this->switcher_column_name = $column_name; return $this; } public function modelId($model_id): self { $this->switcherModelId = $model_id; return $this; } public function checkStatus($status): self { $this->status = $status; return $this; } public function make($show = true): string { if (!$show) { return "--"; } $html = '<label class="form-check cursor-pointer form-switch form-check-custom form-check-solid justify-content-center">'; $html .= '<input class="form-check-input cursor-pointer w-50px switcher" type="checkbox" data-modelId="' . $this->switcherModelId . '" data-model="' . $this->switcherModel . '" data-columnName="' . $this->switcher_column_name . '" ' . ($this->status == 1 ? 'checked="checked"' : '') . '>'; $html .= '</label>'; return $html; } }
SAVE
CANCEL