SwitchesController.php 716 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Models\AppSwitch;
  4. use Illuminate\Http\Request;
  5. class SwitchesController
  6. {
  7. public function index(Request $request)
  8. {
  9. $query = AppSwitch::query();
  10. if ($request->input('name')) {
  11. $query->where('name', $request->input('name'));
  12. }
  13. $switches = $query->paginate(20);
  14. return view('admin.switches.index', [
  15. 'list' => $switches,
  16. 'request' => $request,
  17. ]);
  18. }
  19. public function setStatus($id)
  20. {
  21. $appSwitch = AppSwitch::findOrFail($id);
  22. $appSwitch->status = $appSwitch->status ? 0 : 1;
  23. $appSwitch->save();
  24. return apiReturnSuc();
  25. }
  26. }