1 | <?php namespace crocodicstudio\crudbooster\controllers; |
||||
2 | |||||
3 | use CRUDBooster; |
||||
0 ignored issues
–
show
|
|||||
4 | use Illuminate\Support\Facades\Cache; |
||||
5 | use Illuminate\Support\Facades\DB; |
||||
6 | use Illuminate\Support\Facades\Excel; |
||||
0 ignored issues
–
show
The type
Illuminate\Support\Facades\Excel was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
7 | use Illuminate\Support\Facades\PDF; |
||||
0 ignored issues
–
show
The type
Illuminate\Support\Facades\PDF was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
8 | use Illuminate\Support\Facades\Request; |
||||
9 | use Illuminate\Support\Facades\Storage; |
||||
10 | |||||
11 | class SettingsController extends CBController |
||||
12 | { |
||||
13 | public function cbInit() |
||||
14 | { |
||||
15 | $this->module_name = "Settings"; |
||||
16 | $this->table = 'cms_settings'; |
||||
17 | $this->primary_key = 'id'; |
||||
18 | $this->title_field = "name"; |
||||
19 | $this->index_orderby = ['name' => 'asc']; |
||||
0 ignored issues
–
show
|
|||||
20 | $this->button_delete = true; |
||||
21 | $this->button_show = false; |
||||
22 | $this->button_cancel = false; |
||||
23 | $this->button_import = false; |
||||
24 | $this->button_export = false; |
||||
25 | |||||
26 | $this->col = []; |
||||
27 | $this->col[] = ["label" => "Nama", "name" => "name", "callback_php" => "ucwords(str_replace('_',' ',%field%))"]; |
||||
28 | $this->col[] = ["label" => "Setting", "name" => "content"]; |
||||
29 | |||||
30 | $this->form = []; |
||||
31 | |||||
32 | if (Request::get('group_setting')) { |
||||
33 | $value = Request::get('group_setting'); |
||||
34 | } else { |
||||
35 | $value = 'General Setting'; |
||||
36 | } |
||||
37 | |||||
38 | $this->form[] = ['label' => 'Group', 'name' => 'group_setting', 'value' => $value]; |
||||
39 | $this->form[] = ['label' => 'Label', 'name' => 'label']; |
||||
40 | |||||
41 | $this->form[] = [ |
||||
42 | "label" => "Type", |
||||
43 | "name" => "content_input_type", |
||||
44 | "type" => "select", |
||||
45 | "dataenum" => ["text", "number", "email", "textarea", "wysiwyg", "upload_image", "upload_document", "datepicker", "radio", "select"], |
||||
46 | ]; |
||||
47 | $this->form[] = [ |
||||
48 | "label" => "Radio / Select Data", |
||||
49 | "name" => "dataenum", |
||||
50 | "placeholder" => "Example : abc,def,ghi", |
||||
51 | "jquery" => " |
||||
52 | function show_radio_data() { |
||||
53 | var cit = $('#content_input_type').val(); |
||||
54 | if(cit == 'radio' || cit == 'select') { |
||||
55 | $('#form-group-dataenum').show(); |
||||
56 | }else{ |
||||
57 | $('#form-group-dataenum').hide(); |
||||
58 | } |
||||
59 | } |
||||
60 | $('#content_input_type').change(show_radio_data); |
||||
61 | show_radio_data(); |
||||
62 | ", |
||||
63 | ]; |
||||
64 | $this->form[] = ["label" => "Helper Text", "name" => "helper", "type" => "text"]; |
||||
65 | } |
||||
66 | |||||
67 | function getShow() |
||||
0 ignored issues
–
show
|
|||||
68 | { |
||||
69 | $this->cbLoader(); |
||||
70 | |||||
71 | if (! CRUDBooster::isSuperadmin()) { |
||||
72 | CRUDBooster::insertLog(trans("crudbooster.log_try_view", ['name' => 'Setting', 'module' => 'Setting'])); |
||||
73 | CRUDBooster::redirect(CRUDBooster::adminPath(), trans('crudbooster.denied_access')); |
||||
74 | } |
||||
75 | |||||
76 | $data['page_title'] = urldecode(Request::get('group')); |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
77 | |||||
78 | return view('crudbooster::setting', $data); |
||||
79 | } |
||||
80 | |||||
81 | function hook_before_edit(&$posdata, $id) |
||||
0 ignored issues
–
show
|
|||||
82 | { |
||||
83 | $this->return_url = CRUDBooster::mainpath("show")."?group=".$posdata['group_setting']; |
||||
84 | } |
||||
85 | |||||
86 | function getDeleteFileSetting() |
||||
0 ignored issues
–
show
|
|||||
87 | { |
||||
88 | $id = g('id'); |
||||
89 | $row = CRUDBooster::first('cms_settings', $id); |
||||
90 | Cache::forget('setting_'.$row->name); |
||||
91 | if (Storage::exists($row->content)) { |
||||
92 | Storage::delete($row->content); |
||||
93 | } |
||||
94 | DB::table('cms_settings')->where('id', $id)->update(['content' => null]); |
||||
95 | CRUDBooster::redirect(Request::server('HTTP_REFERER'), trans('alert_delete_data_success'), 'success'); |
||||
96 | } |
||||
97 | |||||
98 | function postSaveSetting() |
||||
0 ignored issues
–
show
|
|||||
99 | { |
||||
100 | |||||
101 | if (! CRUDBooster::isSuperadmin()) { |
||||
102 | CRUDBooster::insertLog(trans("crudbooster.log_try_view", ['name' => 'Setting', 'module' => 'Setting'])); |
||||
103 | CRUDBooster::redirect(CRUDBooster::adminPath(), trans('crudbooster.denied_access')); |
||||
104 | } |
||||
105 | |||||
106 | $group = Request::get('group_setting'); |
||||
107 | $setting = DB::table('cms_settings')->where('group_setting', $group)->get(); |
||||
108 | foreach ($setting as $set) { |
||||
109 | |||||
110 | $name = $set->name; |
||||
111 | |||||
112 | $content = Request::get($set->name); |
||||
113 | |||||
114 | if (Request::hasFile($name)) { |
||||
115 | |||||
116 | if ($set->content_input_type == 'upload_image') { |
||||
117 | CRUDBooster::valid([$name => 'image|max:10000'], 'view'); |
||||
118 | } else { |
||||
119 | CRUDBooster::valid([$name => 'mimes:doc,docx,xls,xlsx,ppt,pptx,pdf,zip,rar|max:20000'], 'view'); |
||||
120 | } |
||||
121 | |||||
122 | $file = Request::file($name); |
||||
123 | $ext = $file->getClientOriginalExtension(); |
||||
124 | |||||
125 | //Create Directory Monthly |
||||
126 | $directory = 'uploads/'.date('Y-m'); |
||||
127 | Storage::makeDirectory($directory); |
||||
128 | |||||
129 | //Move file to storage |
||||
130 | $filename = md5(str_random(5)).'.'.$ext; |
||||
0 ignored issues
–
show
The function
str_random() has been deprecated: Str::random() should be used directly instead. Will be removed in Laravel 6.0.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
131 | $storeFile = Storage::putFileAs($directory, $file, $filename); |
||||
132 | if ($storeFile) { |
||||
133 | $content = $directory.'/'.$filename; |
||||
134 | } |
||||
135 | } |
||||
136 | |||||
137 | DB::table('cms_settings')->where('name', $set->name)->update(['content' => $content]); |
||||
138 | |||||
139 | Cache::forget('setting_'.$set->name); |
||||
140 | } |
||||
141 | |||||
142 | return redirect()->back()->with(['message' => 'Your setting has been saved !', 'message_type' => 'success']); |
||||
143 | } |
||||
144 | |||||
145 | function hook_before_add(&$arr) |
||||
0 ignored issues
–
show
|
|||||
146 | { |
||||
147 | $arr['name'] = str_slug($arr['label'], '_'); |
||||
0 ignored issues
–
show
The function
str_slug() has been deprecated: Str::slug() should be used directly instead. Will be removed in Laravel 6.0.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
148 | $this->return_url = CRUDBooster::mainpath("show")."?group=".$arr['group_setting']; |
||||
149 | } |
||||
150 | |||||
151 | function hook_after_edit($id) |
||||
0 ignored issues
–
show
|
|||||
152 | { |
||||
153 | $row = DB::table($this->table)->where($this->primary_key, $id)->first(); |
||||
154 | |||||
155 | /* REMOVE CACHE */ |
||||
156 | Cache::forget('setting_'.$row->name); |
||||
157 | } |
||||
158 | } |
||||
159 |
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