ConfigurationController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Configuration;
  5. use Illuminate\Contracts\Foundation\Application;
  6. use Illuminate\Contracts\View\Factory;
  7. use Illuminate\Contracts\View\View;
  8. use Illuminate\Http\Request;
  9. use Illuminate\Http\Response;
  10. class ConfigurationController extends Controller
  11. {
  12. /**
  13. * Display a listing of the resource.
  14. *
  15. * @return Application|Factory|View|Response
  16. */
  17. public function index()
  18. {
  19. return view('admin.configurations.index');
  20. }
  21. /**
  22. * Show the form for creating a new resource.
  23. *
  24. * @return Response
  25. */
  26. public function create()
  27. {
  28. //
  29. }
  30. /**
  31. * Store a newly created resource in storage.
  32. *
  33. * @param Request $request
  34. * @return Response
  35. */
  36. public function store(Request $request)
  37. {
  38. //
  39. }
  40. /**
  41. * Display the specified resource.
  42. *
  43. * @param Configuration $configuration
  44. * @return Response
  45. */
  46. public function show(Configuration $configuration)
  47. {
  48. //
  49. }
  50. /**
  51. * Show the form for editing the specified resource.
  52. *
  53. * @param Configuration $configuration
  54. * @return Response
  55. */
  56. public function edit(Configuration $configuration)
  57. {
  58. //
  59. }
  60. /**
  61. * Update the specified resource in storage.
  62. *
  63. * @param Request $request
  64. * @param Configuration $configuration
  65. * @return Response
  66. */
  67. public function update(Request $request, Configuration $configuration)
  68. {
  69. //
  70. }
  71. /**
  72. * @param Request $request
  73. * @return \Illuminate\Http\RedirectResponse
  74. */
  75. public function updatevalue(Request $request)
  76. {
  77. $configuration = Configuration::findOrFail($request->input('key'));
  78. $request->validate([
  79. 'key' => 'required|string|max:191',
  80. 'value' => 'required|string|max:191',
  81. ]);
  82. $configuration->update($request->all());
  83. return redirect()->route('admin.configurations.index')->with('success', __('configuration has been updated!'));
  84. }
  85. /**
  86. * Remove the specified resource from storage.
  87. *
  88. * @param Configuration $configuration
  89. * @return Response
  90. */
  91. public function destroy(Configuration $configuration)
  92. {
  93. //
  94. }
  95. public function datatable()
  96. {
  97. $query = Configuration::query();
  98. return datatables($query)
  99. ->addColumn('actions', function (Configuration $configuration) {
  100. return '<button data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" onclick="configuration.parse(\'' . $configuration->key . '\',\'' . $configuration->value . '\',\'' . $configuration->type . '\')" data-content="Edit" data-trigger="hover" data-toggle="tooltip" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></button> ';
  101. })
  102. ->editColumn('created_at', function (Configuration $configuration) {
  103. return $configuration->created_at ? $configuration->created_at->diffForHumans() : '';
  104. })
  105. ->rawColumns(['actions'])
  106. ->make();
  107. }
  108. }