| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Http\Controllers;
- use App\Customer;
- use App\CustomerLog;
- use App\CustomerLogStatus;
- use Illuminate\Http\RedirectResponse;
- use Illuminate\Http\Request;
- class CustomerLogController extends Controller
- {
- public function __construct()
- {
- $this->middleware('auth');
- }
- public function index(Request $request)
- {
- $customerLog = CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->where('id',$request->id) ->orderByDesc('updated_at')->paginate();
- return view('customer.customerLog.index', compact('customerLog'));
- }
- public function show($customerLog_id)
- {
- $customerLog =CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->where('id',$customerLog_id)->first();
- return view('customer.customerLog.show', compact('customerLog'));
- }
- public function create(CustomerLog $customerLog)
- {
- $customers = Customer::all();
- $customerLogStatuses = CustomerLogStatus::all();
- return view('customer.customerLog.createAndEdit', compact('customerLog', 'customers', 'customerLogStatuses'));
- }
- public function store(Request $request): RedirectResponse
- {
- $data = $request->all();
- $data['user_id'] = auth()->id();
- $customerLog = CustomerLog::query()->create($data);
- return redirect()->route('customerLog.show', $customerLog->id)->with('message', 'Created successfully.');
- }
- public function edit(CustomerLog $customerLog)
- {
- $this->authorize('update', $customerLog);
- $customers = Customer::all();
- $customerLogStatuses = CustomerLogStatus::all();
- return view('customer.customerLog.createAndEdit', compact('customerLog', 'customers', 'customerLogStatuses'));
- }
- public function update(Request $request, CustomerLog $customerLog)
- {
- $this->authorize('update', $customerLog);
- $customerLog->update($request->all());
- return redirect()->route('customerLog.show', $customerLog->id)->with('message', 'Updated successfully.');
- }
- public function destroy(CustomerLog $customerLog)
- {
- $this->authorize('destroy', $customerLog);
- $customerLog->delete();
- return redirect()->route('customerLog.index')->with('message', 'Deleted successfully.');
- }
- }
|