|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Uccello\Core\Http\Controllers\Core; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
|
|
6
|
|
|
use Uccello\Core\Models\Domain; |
|
7
|
|
|
use Uccello\Core\Models\Module; |
|
8
|
|
|
use Uccello\Core\Events\BeforeDeleteEvent; |
|
9
|
|
|
use Uccello\Core\Events\AfterDeleteEvent; |
|
10
|
|
|
|
|
11
|
|
|
class DeleteController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
protected $viewName = null; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Check user permissions |
|
17
|
|
|
*/ |
|
18
|
|
|
protected function checkPermissions() |
|
19
|
|
|
{ |
|
20
|
|
|
$this->middleware('uccello.permissions:delete'); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @inheritDoc |
|
25
|
|
|
*/ |
|
26
|
|
|
public function process(?Domain $domain, Module $module, Request $request) |
|
27
|
|
|
{ |
|
28
|
|
|
// Pre-process |
|
29
|
|
|
$this->preProcess($domain, $module, $request); |
|
30
|
|
|
|
|
31
|
|
|
$this->deleteRecord($module, $request); |
|
32
|
|
|
$message = 'notification.record.deleted'; |
|
33
|
|
|
|
|
34
|
|
|
// Notification |
|
35
|
|
|
if (!empty($message)) { |
|
|
|
|
|
|
36
|
|
|
ucnotify(uctrans($message, $module), 'success'); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// Redirect to the previous page |
|
40
|
|
|
$route = $this->getRedirectionRoute(); |
|
41
|
|
|
|
|
42
|
|
|
return redirect($route); |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Retrieve the redirection route from request parameters. |
|
47
|
|
|
* |
|
48
|
|
|
* @return string |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function getRedirectionRoute() : string |
|
51
|
|
|
{ |
|
52
|
|
|
$request = $this->request; |
|
|
|
|
|
|
53
|
|
|
$domain = $this->domain; |
|
54
|
|
|
$module = $this->module; |
|
55
|
|
|
|
|
56
|
|
|
return ucroute('uccello.list', $domain, $module); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Delete record after retrieving from the request |
|
61
|
|
|
* |
|
62
|
|
|
* @param Module $module |
|
63
|
|
|
* @param Request $request |
|
64
|
|
|
* @return void |
|
65
|
|
|
*/ |
|
66
|
|
|
protected function deleteRecord(Module $module, Request $request) |
|
67
|
|
|
{ |
|
68
|
|
|
$record = $this->getRecordFromRequest(); |
|
69
|
|
|
|
|
70
|
|
|
// Delete record if exists |
|
71
|
|
|
if ($record) { |
|
72
|
|
|
event(new BeforeDeleteEvent($this->domain, $module, $request, $record, 'delete')); |
|
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
$record->delete(); |
|
75
|
|
|
|
|
76
|
|
|
event(new AfterDeleteEvent($this->domain, $module, $request, $record, 'delete')); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
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