CountryController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Models\Country;
  5. class CountryController extends Controller
  6. {
  7. /**
  8. * Display a listing of the resource.
  9. *
  10. * @return \Illuminate\Http\Response
  11. */
  12. public function index(Request $request)
  13. {
  14. $sort_country = $request->sort_country;
  15. $country_queries = Country::query();
  16. if($request->sort_country) {
  17. $country_queries->where('name', 'like', "%$sort_country%");
  18. }
  19. $countries = $country_queries->orderBy('status', 'desc')->paginate(15);
  20. return view('backend.setup_configurations.countries.index', compact('countries', 'sort_country'));
  21. }
  22. /**
  23. * Show the form for creating a new resource.
  24. *
  25. * @return \Illuminate\Http\Response
  26. */
  27. public function create()
  28. {
  29. //
  30. }
  31. /**
  32. * Store a newly created resource in storage.
  33. *
  34. * @param \Illuminate\Http\Request $request
  35. * @return \Illuminate\Http\Response
  36. */
  37. public function store(Request $request)
  38. {
  39. //
  40. }
  41. /**
  42. * Display the specified resource.
  43. *
  44. * @param int $id
  45. * @return \Illuminate\Http\Response
  46. */
  47. public function show($id)
  48. {
  49. //
  50. }
  51. /**
  52. * Show the form for editing the specified resource.
  53. *
  54. * @param int $id
  55. * @return \Illuminate\Http\Response
  56. */
  57. public function edit($id)
  58. {
  59. //
  60. }
  61. /**
  62. * Update the specified resource in storage.
  63. *
  64. * @param \Illuminate\Http\Request $request
  65. * @param int $id
  66. * @return \Illuminate\Http\Response
  67. */
  68. public function update(Request $request, $id)
  69. {
  70. //
  71. }
  72. /**
  73. * Remove the specified resource from storage.
  74. *
  75. * @param int $id
  76. * @return \Illuminate\Http\Response
  77. */
  78. public function destroy($id)
  79. {
  80. //
  81. }
  82. public function updateStatus(Request $request){
  83. $country = Country::findOrFail($request->id);
  84. $country->status = $request->status;
  85. if($country->save()){
  86. return 1;
  87. }
  88. return 0;
  89. }
  90. }