Enth\u00e4lt gemischt: Laravel-10-Upgrade + Phase 1 (Contacts-Modul, Duplicats-Commands, Soft-Delete+Merge-Fields) + Phase 2 Code-Umstellungen (inquiry_id, $table='contacts'/'inquiries') + Offers-Modul (Migrationen, Models, offer_id in Booking, offer-Disk in filesystems.php). Phase 2 + Offers werden im folgenden Commit nach dev/backups/phase2-offers-2026-04-17/ verschoben, damit der Workspace auf Phase-1-only (= Test-System-Stand) reduziert ist und direkt auf Live deploybar wird. Tarball-Backup zus\u00e4tzlich unter: ../backups-safety/workspace-pre-phase1-rollback-2026-04-17.tar.gz Made-with: Cursor
92 lines
2.5 KiB
PHP
Executable file
92 lines
2.5 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Customer;
|
|
use App\Repositories\CustomerRepository;
|
|
use Carbon;
|
|
use Request;
|
|
|
|
class CustomerController extends Controller
|
|
{
|
|
|
|
protected $custRepo;
|
|
|
|
public function __construct(CustomerRepository $custRepo)
|
|
{
|
|
$this->middleware(['admin', '2fa']);
|
|
$this->custRepo = $custRepo;
|
|
}
|
|
|
|
public function index($step = false)
|
|
{
|
|
$data = [
|
|
'step' => $step
|
|
];
|
|
return view('customer.index', $data);
|
|
}
|
|
|
|
public function detail($id)
|
|
{
|
|
if($id === "new") {
|
|
$customer = new Customer();
|
|
$id = 'new';
|
|
|
|
}else{
|
|
$customer = Customer::findOrFail($id);
|
|
$id = $customer->id;
|
|
}
|
|
$data = [
|
|
'customer' => $customer,
|
|
'id' => $id,
|
|
];
|
|
return view('customer.detail', $data);
|
|
|
|
}
|
|
|
|
public function store($id)
|
|
{
|
|
$data = Request::all();
|
|
if(!isset($data['action'])){
|
|
abort(403, 'keine Action');
|
|
}
|
|
//save
|
|
$customer = $this->custRepo->updateCustomer($id, $data);
|
|
\Session()->flash('alert-save', '1');
|
|
|
|
if($data['action'] === 'saveCustomer'){
|
|
return redirect(route('customer_detail', [$id]).'#collapseCustomerDetail');
|
|
}
|
|
return back();
|
|
}
|
|
|
|
public function delete($id){
|
|
/*
|
|
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
|
return redirect(route('lead_detail', [$lead->id]));*/
|
|
}
|
|
|
|
public function getCustomers()
|
|
{
|
|
$query = Customer::with('salutation')->select('contacts.*');
|
|
|
|
return \DataTables::eloquent($query)
|
|
->addColumn('action_edit', function (Customer $customer) {
|
|
return '<a href="'.route('customer_detail', [$customer->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
|
})
|
|
->addColumn('id', function (Customer $customer) {
|
|
return '<a data-order="'.$customer->id.'" href="'.route('customer_detail', [$customer->id]).'" data-id="'.$customer->id.'">'.$customer->id.'</a>';
|
|
})
|
|
|
|
->orderColumn('id', 'id $1')
|
|
->filterColumn('id', function($query, $keyword) {
|
|
if($keyword != ""){
|
|
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
|
}
|
|
})
|
|
->rawColumns(['action_edit', 'id'])
|
|
->make(true);
|
|
}
|
|
}
|
|
|
|
|