1
|
|
|
<?php namespace App\Http\Controllers\Backend; |
2
|
|
|
|
3
|
|
|
use App\Http\Controllers\Controller; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* ClientAddressController |
7
|
|
|
* |
8
|
|
|
* This is the controller for the client addresses |
9
|
|
|
* @author Matthijs Neijenhuijs <[email protected]> |
10
|
|
|
* @version 0.1 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
use Hideyo\Ecommerce\Framework\Services\Client\ClientFacade as ClientService; |
14
|
|
|
|
15
|
|
|
use Illuminate\Http\Request; |
16
|
|
|
use Notification; |
17
|
|
|
use Form; |
18
|
|
|
use Datatables; |
|
|
|
|
19
|
|
|
|
20
|
|
|
class ClientAddressController extends Controller |
21
|
|
|
{ |
22
|
|
|
public function index(Request $request, $clientId) |
23
|
|
|
{ |
24
|
|
|
$client = ClientService::find($clientId); |
25
|
|
|
if ($request->wantsJson()) { |
26
|
|
|
|
27
|
|
|
$addresses = ClientService::getAddressModel()->select( |
28
|
|
|
[ |
29
|
|
|
'id', |
30
|
|
|
'firstname', |
31
|
|
|
'street', |
32
|
|
|
'housenumber', |
33
|
|
|
'housenumber_suffix', |
34
|
|
|
'city', |
35
|
|
|
'lastname'] |
36
|
|
|
)->with(array('clientDeliveryAddress', 'clientBillAddress'))->where('client_id', '=', $clientId); |
37
|
|
|
|
38
|
|
|
$datatables = Datatables::of($addresses) |
39
|
|
|
->addColumn('housenumber', function ($addresses) use ($clientId) { |
|
|
|
|
40
|
|
|
return $addresses->housenumber.$addresses->housenumber_suffix; |
41
|
|
|
}) |
42
|
|
|
->addColumn('delivery', function ($addresses) { |
43
|
|
|
if ($addresses->clientDeliveryAddress()->count()) { |
44
|
|
|
return '<span class="glyphicon glyphicon-ok icon-green"></span>'; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return '<span class="glyphicon glyphicon-remove icon-red"></span>'; |
48
|
|
|
|
49
|
|
|
}) |
50
|
|
|
|
51
|
|
|
->addColumn('bill', function ($addresses) { |
52
|
|
|
if ($addresses->clientBillAddress()->count()) { |
53
|
|
|
return '<span class="glyphicon glyphicon-ok icon-green"></span>'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return '<span class="glyphicon glyphicon-remove icon-red"></span>'; |
57
|
|
|
}) |
58
|
|
|
->addColumn('action', function ($addresses) use ($clientId) { |
59
|
|
|
$deleteLink = Form::deleteajax(url()->route('client.addresses.destroy', array('clientId' => $clientId, 'clientAddressId' => $addresses->id)), 'Delete', '', array('class'=>'btn btn-default btn-sm btn-danger')); |
60
|
|
|
$links = '<a href="'.url()->route('client.addresses.edit', array('clientId' => $clientId, 'clientAddressId' => $addresses->id)).'" class="btn btn-default btn-sm btn-success"><i class="entypo-pencil"></i>Edit</a> '.$deleteLink; |
61
|
|
|
|
62
|
|
|
return $links; |
63
|
|
|
}); |
64
|
|
|
|
65
|
|
|
return $datatables->make(true); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return view('backend.client_address.index')->with(array('client' => $client)); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function create($clientId) |
72
|
|
|
{ |
73
|
|
|
$client = ClientService::find($clientId); |
74
|
|
|
return view('backend.client_address.create')->with(array('client' => $client)); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function store(Request $request, $clientId) |
78
|
|
|
{ |
79
|
|
|
$result = ClientService::createAddress($request->all(), $clientId); |
80
|
|
|
return ClientService::notificationRedirect(array('client.addresses.index', $clientId), $result, 'The client adress is inserted.'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function edit($clientId, $id) |
84
|
|
|
{ |
85
|
|
|
$client = ClientService::find($clientId); |
86
|
|
|
return view('backend.client_address.edit')->with(array('clientAddress' => ClientService::findAddress($id), 'client' => $client)); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function update(Request $request, $clientId, $id) |
90
|
|
|
{ |
91
|
|
|
$result = ClientService::editAddress($clientId, $id, $request->all()); |
92
|
|
|
return ClientService::notificationRedirect(array('client.addresses.index', $clientId), $result, 'The client adress is updated.'); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function destroy($clientId, $id) |
96
|
|
|
{ |
97
|
|
|
$result = ClientService::destroyAddress($id); |
98
|
|
|
|
99
|
|
|
if ($result) { |
100
|
|
|
Notification::success('The client address is deleted.'); |
101
|
|
|
return redirect()->route('client.addresses.index', $clientId); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths