86 lines
2.2 KiB
PHP
Executable file
86 lines
2.2 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 $customerRepo;
|
|
|
|
public function __construct(CustomerRepository $customerRepo)
|
|
{
|
|
$this->middleware('admin');
|
|
$this->customerRepo = $customerRepo;
|
|
}
|
|
|
|
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)
|
|
{
|
|
return back();
|
|
/* $data = Request::all();
|
|
|
|
\Session()->flash('alert-save', '1');
|
|
return redirect(route('lead_detail', [$lead->id]));*/
|
|
|
|
}
|
|
|
|
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');
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
|