CustomerLogsController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\CustomerLog;
  4. use Illuminate\Http\Request;
  5. use App\Http\Controllers\Controller;
  6. class CustomerLogsController extends Controller
  7. {
  8. public function __construct()
  9. {
  10. $this->middleware('auth', ['except' => ['index', 'show']]);
  11. }
  12. public function index()
  13. {
  14. $customer_logs = CustomerLog::paginate();
  15. return view('customer_logs.index', compact('customer_logs'));
  16. }
  17. public function show(CustomerLog $customer_log)
  18. {
  19. return view('customer_logs.show', compact('customer_log'));
  20. }
  21. public function create(CustomerLog $customer_log)
  22. {
  23. return view('customer_logs.create_and_edit', compact('customer_log'));
  24. }
  25. public function store($request)
  26. {
  27. $customer_log = CustomerLog::create($request->all());
  28. return redirect()->route('customer_logs.show', $customer_log->id)->with('message', 'Created successfully.');
  29. }
  30. public function edit(CustomerLog $customer_log)
  31. {
  32. $this->authorize('update', $customer_log);
  33. return view('customer_logs.create_and_edit', compact('customer_log'));
  34. }
  35. public function update($request, CustomerLog $customer_log)
  36. {
  37. $this->authorize('update', $customer_log);
  38. $customer_log->update($request->all());
  39. return redirect()->route('customer_logs.show', $customer_log->id)->with('message', 'Updated successfully.');
  40. }
  41. public function destroy(CustomerLog $customer_log)
  42. {
  43. $this->authorize('destroy', $customer_log);
  44. $customer_log->delete();
  45. return redirect()->route('customer_logs.index')->with('message', 'Deleted successfully.');
  46. }
  47. }