Skip to content

Commit 819f226

Browse files
committed
LaraAdmin Upgrade
1 parent 467bac9 commit 819f226

26 files changed

+1300
-589
lines changed

app/Http/Controllers/LA/BackupsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function destroy($id)
131131
*
132132
* @return
133133
*/
134-
public function dtajax()
134+
public function dtajax(Request $request)
135135
{
136136
$module = Module::get('Backups');
137137
$listing_cols = Module::getListingColumns('Backups');

app/Http/Controllers/LA/ContactsController.php

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@
2222
class ContactsController extends Controller
2323
{
2424
public $show_action = true;
25-
public $view_col = 'first_name';
26-
public $listing_cols = ['id', 'first_name', 'last_name', 'title', 'organization', 'email', 'phone_primary', 'assigned_to'];
27-
28-
public function __construct() {
29-
// Field Access of Listing Columns
30-
if(\Dwij\Laraadmin\Helpers\LAHelper::laravel_ver() == 5.3) {
31-
$this->middleware(function ($request, $next) {
32-
$this->listing_cols = ModuleFields::listingColumnAccessScan('Contacts', $this->listing_cols);
33-
return $next($request);
34-
});
35-
} else {
36-
$this->listing_cols = ModuleFields::listingColumnAccessScan('Contacts', $this->listing_cols);
37-
}
38-
}
3925

4026
/**
4127
* Display a listing of the Contacts.
@@ -49,7 +35,7 @@ public function index()
4935
if(Module::hasAccess($module->id)) {
5036
return View('la.contacts.index', [
5137
'show_actions' => $this->show_action,
52-
'listing_cols' => $this->listing_cols,
38+
'listing_cols' => Module::getListingColumns('Contacts'),
5339
'module' => $module
5440
]);
5541
} else {
@@ -111,7 +97,7 @@ public function show($id)
11197

11298
return view('la.contacts.show', [
11399
'module' => $module,
114-
'view_col' => $this->view_col,
100+
'view_col' => $module->view_col,
115101
'no_header' => true,
116102
'no_padding' => "no-padding"
117103
])->with('contact', $contact);
@@ -143,7 +129,7 @@ public function edit($id)
143129

144130
return view('la.contacts.edit', [
145131
'module' => $module,
146-
'view_col' => $this->view_col,
132+
'view_col' => $module->view_col,
147133
])->with('contact', $contact);
148134
} else {
149135
return view('errors.404', [
@@ -209,23 +195,26 @@ public function destroy($id)
209195
*/
210196
public function dtajax(Request $request)
211197
{
198+
$module = Module::get('Contacts');
199+
$listing_cols = Module::getListingColumns('Contacts');
200+
212201
if(isset($request->filter_column)) {
213-
$values = DB::table('contacts')->select($this->listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
202+
$values = DB::table('contacts')->select($listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
214203
} else {
215-
$values = DB::table('contacts')->select($this->listing_cols)->whereNull('deleted_at');
204+
$values = DB::table('contacts')->select($listing_cols)->whereNull('deleted_at');
216205
}
217206
$out = Datatables::of($values)->make();
218207
$data = $out->getData();
219208

220209
$fields_popup = ModuleFields::getModuleFields('Contacts');
221210

222211
for($i=0; $i < count($data->data); $i++) {
223-
for ($j=0; $j < count($this->listing_cols); $j++) {
224-
$col = $this->listing_cols[$j];
212+
for ($j=0; $j < count($listing_cols); $j++) {
213+
$col = $listing_cols[$j];
225214
if($fields_popup[$col] != null && starts_with($fields_popup[$col]->popup_vals, "@")) {
226215
$data->data[$i][$j] = ModuleFields::getFieldValue($fields_popup[$col], $data->data[$i][$j]);
227216
}
228-
if($col == $this->view_col) {
217+
if($col == $module->view_col) {
229218
$data->data[$i][$j] = '<a href="'.url(config('laraadmin.adminRoute') . '/contacts/'.$data->data[$i][0]).'">'.$data->data[$i][$j].'</a>';
230219
}
231220
// else if($col == "author") {

app/Http/Controllers/LA/DepartmentsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function destroy($id)
193193
*
194194
* @return
195195
*/
196-
public function dtajax()
196+
public function dtajax(Request $request)
197197
{
198198
$module = Module::get('Departments');
199199
$listing_cols = Module::getListingColumns('Departments');

app/Http/Controllers/LA/EmployeesController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,15 @@ public function destroy($id)
245245
*
246246
* @return
247247
*/
248-
public function dtajax()
248+
public function dtajax(Request $request)
249249
{
250250
$module = Module::get('Employees');
251251
$listing_cols = Module::getListingColumns('Employees');
252252

253253
if(isset($request->filter_column)) {
254-
$values = DB::table('employees')->select($this->listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
254+
$values = DB::table('employees')->select($listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
255255
} else {
256-
$values = DB::table('employees')->select($this->listing_cols)->whereNull('deleted_at');
256+
$values = DB::table('employees')->select($listing_cols)->whereNull('deleted_at');
257257
}
258258
$out = Datatables::of($values)->make();
259259
$data = $out->getData();

app/Http/Controllers/LA/LeadsController.php

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@
2222
class LeadsController extends Controller
2323
{
2424
public $show_action = true;
25-
public $view_col = 'first_name';
26-
public $listing_cols = ['id', 'first_name', 'last_name', 'company', 'phone_primary', 'email_primary', 'assigned_to'];
27-
28-
public function __construct() {
29-
// Field Access of Listing Columns
30-
if(\Dwij\Laraadmin\Helpers\LAHelper::laravel_ver() == 5.3) {
31-
$this->middleware(function ($request, $next) {
32-
$this->listing_cols = ModuleFields::listingColumnAccessScan('Leads', $this->listing_cols);
33-
return $next($request);
34-
});
35-
} else {
36-
$this->listing_cols = ModuleFields::listingColumnAccessScan('Leads', $this->listing_cols);
37-
}
38-
}
3925

4026
/**
4127
* Display a listing of the Leads.
@@ -49,7 +35,7 @@ public function index()
4935
if(Module::hasAccess($module->id)) {
5036
return View('la.leads.index', [
5137
'show_actions' => $this->show_action,
52-
'listing_cols' => $this->listing_cols,
38+
'listing_cols' => Module::getListingColumns('Leads'),
5339
'module' => $module
5440
]);
5541
} else {
@@ -111,7 +97,7 @@ public function show($id)
11197

11298
return view('la.leads.show', [
11399
'module' => $module,
114-
'view_col' => $this->view_col,
100+
'view_col' => $module->view_col,
115101
'no_header' => true,
116102
'no_padding' => "no-padding"
117103
])->with('lead', $lead);
@@ -143,7 +129,7 @@ public function edit($id)
143129

144130
return view('la.leads.edit', [
145131
'module' => $module,
146-
'view_col' => $this->view_col,
132+
'view_col' => $module->view_col,
147133
])->with('lead', $lead);
148134
} else {
149135
return view('errors.404', [
@@ -209,23 +195,26 @@ public function destroy($id)
209195
*/
210196
public function dtajax(Request $request)
211197
{
198+
$module = Module::get('Leads');
199+
$listing_cols = Module::getListingColumns('Leads');
200+
212201
if(isset($request->filter_column)) {
213-
$values = DB::table('leads')->select($this->listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
202+
$values = DB::table('leads')->select($listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
214203
} else {
215-
$values = DB::table('leads')->select($this->listing_cols)->whereNull('deleted_at');
204+
$values = DB::table('leads')->select($listing_cols)->whereNull('deleted_at');
216205
}
217206
$out = Datatables::of($values)->make();
218207
$data = $out->getData();
219208

220209
$fields_popup = ModuleFields::getModuleFields('Leads');
221210

222211
for($i=0; $i < count($data->data); $i++) {
223-
for ($j=0; $j < count($this->listing_cols); $j++) {
224-
$col = $this->listing_cols[$j];
212+
for ($j=0; $j < count($listing_cols); $j++) {
213+
$col = $listing_cols[$j];
225214
if($fields_popup[$col] != null && starts_with($fields_popup[$col]->popup_vals, "@")) {
226215
$data->data[$i][$j] = ModuleFields::getFieldValue($fields_popup[$col], $data->data[$i][$j]);
227216
}
228-
if($col == $this->view_col) {
217+
if($col == $module->view_col) {
229218
$data->data[$i][$j] = '<a href="'.url(config('laraadmin.adminRoute') . '/leads/'.$data->data[$i][0]).'">'.$data->data[$i][$j].'</a>';
230219
}
231220
// else if($col == "author") {
@@ -249,7 +238,7 @@ public function dtajax(Request $request)
249238
}
250239
$out->setData($data);
251240
return $out;
252-
}
241+
}
253242

254243
/**
255244
* Store a lead in database from Homepage form

app/Http/Controllers/LA/OpportunitiesController.php

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@
2222
class OpportunitiesController extends Controller
2323
{
2424
public $show_action = true;
25-
public $view_col = 'name';
26-
public $listing_cols = ['id', 'name', 'organization', 'sales_stage', 'lead_source', 'expected_close_date', 'amount', 'assigned_to', 'contact'];
27-
28-
public function __construct() {
29-
// Field Access of Listing Columns
30-
if(\Dwij\Laraadmin\Helpers\LAHelper::laravel_ver() == 5.3) {
31-
$this->middleware(function ($request, $next) {
32-
$this->listing_cols = ModuleFields::listingColumnAccessScan('Opportunities', $this->listing_cols);
33-
return $next($request);
34-
});
35-
} else {
36-
$this->listing_cols = ModuleFields::listingColumnAccessScan('Opportunities', $this->listing_cols);
37-
}
38-
}
3925

4026
/**
4127
* Display a listing of the Opportunities.
@@ -49,7 +35,7 @@ public function index()
4935
if(Module::hasAccess($module->id)) {
5036
return View('la.opportunities.index', [
5137
'show_actions' => $this->show_action,
52-
'listing_cols' => $this->listing_cols,
38+
'listing_cols' => Module::getListingColumns('Opportunities'),
5339
'module' => $module
5440
]);
5541
} else {
@@ -111,7 +97,7 @@ public function show($id)
11197

11298
return view('la.opportunities.show', [
11399
'module' => $module,
114-
'view_col' => $this->view_col,
100+
'view_col' => $module->view_col,
115101
'no_header' => true,
116102
'no_padding' => "no-padding"
117103
])->with('opportunity', $opportunity);
@@ -143,7 +129,7 @@ public function edit($id)
143129

144130
return view('la.opportunities.edit', [
145131
'module' => $module,
146-
'view_col' => $this->view_col,
132+
'view_col' => $module->view_col,
147133
])->with('opportunity', $opportunity);
148134
} else {
149135
return view('errors.404', [
@@ -207,25 +193,28 @@ public function destroy($id)
207193
*
208194
* @return
209195
*/
210-
public function dtajax(Request $request)
196+
public function dtajax(Request $request)
211197
{
198+
$module = Module::get('Opportunities');
199+
$listing_cols = Module::getListingColumns('Opportunities');
200+
212201
if(isset($request->filter_column)) {
213-
$values = DB::table('opportunities')->select($this->listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
202+
$values = DB::table('opportunities')->select($listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
214203
} else {
215-
$values = DB::table('opportunities')->select($this->listing_cols)->whereNull('deleted_at');
204+
$values = DB::table('opportunities')->select($listing_cols)->whereNull('deleted_at');
216205
}
217206
$out = Datatables::of($values)->make();
218207
$data = $out->getData();
219208

220209
$fields_popup = ModuleFields::getModuleFields('Opportunities');
221210

222211
for($i=0; $i < count($data->data); $i++) {
223-
for ($j=0; $j < count($this->listing_cols); $j++) {
224-
$col = $this->listing_cols[$j];
212+
for ($j=0; $j < count($listing_cols); $j++) {
213+
$col = $listing_cols[$j];
225214
if($fields_popup[$col] != null && starts_with($fields_popup[$col]->popup_vals, "@")) {
226215
$data->data[$i][$j] = ModuleFields::getFieldValue($fields_popup[$col], $data->data[$i][$j]);
227216
}
228-
if($col == $this->view_col) {
217+
if($col == $module->view_col) {
229218
$data->data[$i][$j] = '<a href="'.url(config('laraadmin.adminRoute') . '/opportunities/'.$data->data[$i][0]).'">'.$data->data[$i][$j].'</a>';
230219
}
231220
// else if($col == "author") {

app/Http/Controllers/LA/OrganizationsController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ public function destroy($id)
203203
*
204204
* @return
205205
*/
206-
public function dtajax()
206+
public function dtajax(Request $request)
207207
{
208208
$module = Module::get('Organizations');
209209
$listing_cols = Module::getListingColumns('Organizations');
210210

211211
if(isset($request->filter_column)) {
212-
$values = DB::table('organizations')->select($this->listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
212+
$values = DB::table('organizations')->select($listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
213213
} else {
214-
$values = DB::table('organizations')->select($this->listing_cols)->whereNull('deleted_at');
214+
$values = DB::table('organizations')->select($listing_cols)->whereNull('deleted_at');
215215
}
216216
$out = Datatables::of($values)->make();
217217
$data = $out->getData();

app/Http/Controllers/LA/PermissionsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function destroy($id)
199199
*
200200
* @return
201201
*/
202-
public function dtajax()
202+
public function dtajax(Request $request)
203203
{
204204
$module = Module::get('Permissions');
205205
$listing_cols = Module::getListingColumns('Permissions');

app/Http/Controllers/LA/ProjectsController.php

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@
2222
class ProjectsController extends Controller
2323
{
2424
public $show_action = true;
25-
public $view_col = 'name';
26-
public $listing_cols = ['id', 'name', 'start_date', 'target_end_date', 'actual_end_date', 'target_budget', 'status', 'assigned_to'];
27-
28-
public function __construct() {
29-
// Field Access of Listing Columns
30-
if(\Dwij\Laraadmin\Helpers\LAHelper::laravel_ver() == 5.3) {
31-
$this->middleware(function ($request, $next) {
32-
$this->listing_cols = ModuleFields::listingColumnAccessScan('Projects', $this->listing_cols);
33-
return $next($request);
34-
});
35-
} else {
36-
$this->listing_cols = ModuleFields::listingColumnAccessScan('Projects', $this->listing_cols);
37-
}
38-
}
3925

4026
/**
4127
* Display a listing of the Projects.
@@ -49,7 +35,7 @@ public function index()
4935
if(Module::hasAccess($module->id)) {
5036
return View('la.projects.index', [
5137
'show_actions' => $this->show_action,
52-
'listing_cols' => $this->listing_cols,
38+
'listing_cols' => Module::getListingColumns('Projects'),
5339
'module' => $module
5440
]);
5541
} else {
@@ -111,7 +97,7 @@ public function show($id)
11197

11298
return view('la.projects.show', [
11399
'module' => $module,
114-
'view_col' => $this->view_col,
100+
'view_col' => $module->view_col,
115101
'no_header' => true,
116102
'no_padding' => "no-padding"
117103
])->with('project', $project);
@@ -143,7 +129,7 @@ public function edit($id)
143129

144130
return view('la.projects.edit', [
145131
'module' => $module,
146-
'view_col' => $this->view_col,
132+
'view_col' => $module->view_col,
147133
])->with('project', $project);
148134
} else {
149135
return view('errors.404', [
@@ -209,23 +195,26 @@ public function destroy($id)
209195
*/
210196
public function dtajax(Request $request)
211197
{
198+
$module = Module::get('Projects');
199+
$listing_cols = Module::getListingColumns('Projects');
200+
212201
if(isset($request->filter_column)) {
213-
$values = DB::table('projects')->select($this->listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
202+
$values = DB::table('projects')->select($listing_cols)->whereNull('deleted_at')->where($request->filter_column, $request->filter_column_value);
214203
} else {
215-
$values = DB::table('projects')->select($this->listing_cols)->whereNull('deleted_at');
204+
$values = DB::table('projects')->select($listing_cols)->whereNull('deleted_at');
216205
}
217206
$out = Datatables::of($values)->make();
218207
$data = $out->getData();
219208

220209
$fields_popup = ModuleFields::getModuleFields('Projects');
221210

222211
for($i=0; $i < count($data->data); $i++) {
223-
for ($j=0; $j < count($this->listing_cols); $j++) {
224-
$col = $this->listing_cols[$j];
212+
for ($j=0; $j < count($listing_cols); $j++) {
213+
$col = $listing_cols[$j];
225214
if($fields_popup[$col] != null && starts_with($fields_popup[$col]->popup_vals, "@")) {
226215
$data->data[$i][$j] = ModuleFields::getFieldValue($fields_popup[$col], $data->data[$i][$j]);
227216
}
228-
if($col == $this->view_col) {
217+
if($col == $module->view_col) {
229218
$data->data[$i][$j] = '<a href="'.url(config('laraadmin.adminRoute') . '/projects/'.$data->data[$i][0]).'">'.$data->data[$i][$j].'</a>';
230219
}
231220
// else if($col == "author") {

0 commit comments

Comments
 (0)