| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Http\Controllers;
- use App\Components\AsyncResponse;
- use App\TaxRate;
- class TaxRateController extends Controller
- {
- use AsyncResponse;
- public function get()
- {
- return TaxRate::query()->get();
- }
- public function index()
- {
- $taxRates = TaxRate::query()->orderByDesc("id")->paginate(50);
- return view("maintenance.taxRate.index",compact("taxRates"));
- }
- public function save()
- {
- $this->gate("税率-编辑");
- $value = request("value");
- if (!is_numeric($value) || $value>=100)$this->error("非法值");
- if (request("id"))$taxRate = TaxRate::query()->where("id",request("id"))->update(["value"=>$value]);
- else $taxRate = TaxRate::query()->create(["value"=>$value]);
- $this->success($taxRate);
- }
- public function destroy()
- {
- $this->gate("税率-删除");
- $this->success(TaxRate::destroy(request("id")));
- }
- }
|