|
@@ -2,7 +2,10 @@
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
+use App\Customer;
|
|
|
use App\CustomerLog;
|
|
use App\CustomerLog;
|
|
|
|
|
+use App\CustomerLogStatus;
|
|
|
|
|
+use Illuminate\Http\RedirectResponse;
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
|
|
@@ -15,33 +18,41 @@ class CustomerLogsController extends Controller
|
|
|
|
|
|
|
|
public function index()
|
|
public function index()
|
|
|
{
|
|
{
|
|
|
- $customer_logs = CustomerLog::paginate();
|
|
|
|
|
|
|
+ $customer_logs = CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->orderByDesc('updated_at')->paginate();
|
|
|
return view('customer_logs.index', compact('customer_logs'));
|
|
return view('customer_logs.index', compact('customer_logs'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function show(CustomerLog $customer_log)
|
|
|
|
|
|
|
+ public function show($customer_log_id)
|
|
|
{
|
|
{
|
|
|
|
|
+ $customer_log =CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->where('id',$customer_log_id)->first();
|
|
|
return view('customer_logs.show', compact('customer_log'));
|
|
return view('customer_logs.show', compact('customer_log'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function create(CustomerLog $customer_log)
|
|
public function create(CustomerLog $customer_log)
|
|
|
{
|
|
{
|
|
|
- return view('customer_logs.create_and_edit', compact('customer_log'));
|
|
|
|
|
|
|
+ $customers = Customer::all();
|
|
|
|
|
+ $customerLogStatuses = CustomerLogStatus::all();
|
|
|
|
|
+ return view('customer_logs.create_and_edit', compact('customer_log', 'customers', 'customerLogStatuses'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function store($request)
|
|
|
|
|
|
|
+ public function store(Request $request): RedirectResponse
|
|
|
{
|
|
{
|
|
|
- $customer_log = CustomerLog::create($request->all());
|
|
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ $data = $request->all();
|
|
|
|
|
+ $data['user_id'] = auth()->id();
|
|
|
|
|
+ $customer_log = CustomerLog::create($data);
|
|
|
return redirect()->route('customer_logs.show', $customer_log->id)->with('message', 'Created successfully.');
|
|
return redirect()->route('customer_logs.show', $customer_log->id)->with('message', 'Created successfully.');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function edit(CustomerLog $customer_log)
|
|
public function edit(CustomerLog $customer_log)
|
|
|
{
|
|
{
|
|
|
$this->authorize('update', $customer_log);
|
|
$this->authorize('update', $customer_log);
|
|
|
- return view('customer_logs.create_and_edit', compact('customer_log'));
|
|
|
|
|
|
|
+ $customers = Customer::all();
|
|
|
|
|
+ $customerLogStatuses = CustomerLogStatus::all();
|
|
|
|
|
+ return view('customer_logs.create_and_edit', compact('customer_log', 'customers', 'customerLogStatuses'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function update($request, CustomerLog $customer_log)
|
|
|
|
|
|
|
+ public function update(Request $request, CustomerLog $customer_log)
|
|
|
{
|
|
{
|
|
|
$this->authorize('update', $customer_log);
|
|
$this->authorize('update', $customer_log);
|
|
|
$customer_log->update($request->all());
|
|
$customer_log->update($request->all());
|