AdminCmsUsersController::hook_before_add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
<?php namespace App\Http\Controllers;
2
3
use Session;
4
use Request;
5
use DB;
6
use CRUDbooster;
0 ignored issues
show
Bug introduced by
The type CRUDbooster 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class AdminCmsUsersController extends \crocodicstudio\crudbooster\controllers\CBController {
9
10
11
	public function cbInit() {
12
		# START CONFIGURATION DO NOT REMOVE THIS LINE
13
		$this->table               = 'cms_users';
14
		$this->primary_key         = 'id';
15
		$this->title_field         = "name";
16
		$this->button_action_style = 'button_icon';	
17
		$this->button_import 	   = FALSE;	
18
		$this->button_export 	   = FALSE;	
19
		# END CONFIGURATION DO NOT REMOVE THIS LINE
20
	
21
		# START COLUMNS DO NOT REMOVE THIS LINE
22
		$this->col = array();
23
		$this->col[] = array("label"=>"Name","name"=>"name");
24
		$this->col[] = array("label"=>"Email","name"=>"email");
25
		$this->col[] = array("label"=>"Privilege","name"=>"id_cms_privileges","join"=>"cms_privileges,name");
26
		$this->col[] = array("label"=>"Photo","name"=>"photo","image"=>1);		
27
		# END COLUMNS DO NOT REMOVE THIS LINE
28
29
		# START FORM DO NOT REMOVE THIS LINE
30
		$this->form = array(); 		
31
		$this->form[] = array("label"=>"Name","name"=>"name",'required'=>true,'validation'=>'required|alpha_spaces|min:3');
32
		$this->form[] = array("label"=>"Email","name"=>"email",'required'=>true,'type'=>'email','validation'=>'required|email|unique:cms_users,email,'.CRUDBooster::getCurrentId());		
33
		$this->form[] = array("label"=>"Photo","name"=>"photo","type"=>"upload","help"=>"Recommended resolution is 200x200px",'required'=>true,'validation'=>'required|image|max:1000','resize_width'=>90,'resize_height'=>90);											
34
		$this->form[] = array("label"=>"Privilege","name"=>"id_cms_privileges","type"=>"select","datatable"=>"cms_privileges,name",'required'=>true);						
35
		// $this->form[] = array("label"=>"Password","name"=>"password","type"=>"password","help"=>"Please leave empty if not change");
36
		$this->form[] = array("label"=>"Password","name"=>"password","type"=>"password","help"=>"Please leave empty if not change");
37
		$this->form[] = array("label"=>"Password Confirmation","name"=>"password_confirmation","type"=>"password","help"=>"Please leave empty if not change");
38
		# END FORM DO NOT REMOVE THIS LINE
39
				
40
	}
41
42
	public function getProfile() {			
43
44
		$this->button_addmore = FALSE;
45
		$this->button_cancel  = FALSE;
46
		$this->button_show    = FALSE;			
47
		$this->button_add     = FALSE;
48
		$this->button_delete  = FALSE;	
49
		$this->hide_form 	  = ['id_cms_privileges'];
50
51
		$data['page_title'] = trans("crudbooster.label_button_profile");
0 ignored issues
show
Comprehensibility Best Practice introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.
Loading history...
52
		$data['row']        = CRUDBooster::first('cms_users',CRUDBooster::myId());		
53
		$this->cbView('crudbooster::default.form',$data);				
54
	}
55
	public function hook_before_edit(&$postdata,$id) { 
56
		unset($postdata['password_confirmation']);
57
	}
58
	public function hook_before_add(&$postdata) {      
59
	    unset($postdata['password_confirmation']);
60
	}
61
}
62