Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php namespace App\Http\Controllers;
- use Session;
- use Request;
- use DB;
- use CRUDBooster;
- use App\Models\AreaModel;
- use App\Models\UserModel;
- use App\Models\OwnerModel;
- use App\Models\UserOwnerModel;
- class AdminCpiMstOwnerController extends \crocodicstudio\crudbooster\controllers\CBController {
- public function cbInit() {
- # START CONFIGURATION DO NOT REMOVE THIS LINE
- $this->title_field = "name";
- $this->limit = "10";
- $this->orderby = "id,desc";
- $this->global_privilege = false;
- $this->button_table_action = true;
- $this->button_bulk_action = false;
- $this->button_action_style = "button_icon";
- $this->button_add = true;
- $this->button_edit = true;
- $this->button_delete = true;
- $this->button_detail = true;
- $this->button_show = false;
- $this->button_filter = false;
- $this->button_import = false;
- $this->button_export = false;
- $this->table = "cpi_mst_owner";
- # END CONFIGURATION DO NOT REMOVE THIS LINE
- # START COLUMNS DO NOT REMOVE THIS LINE
- $this->col = [];
- $this->col[] = ["label"=>"Owner","name"=>"owner_name"];
- $this->col[] = ["label"=>"Technical Support", "name"=>"employee_id", "callback_php"=>'$this->technical_support($row->id)'];
- $this->col[] = ["label"=>"Email","name"=>"email"];
- $this->col[] = ["label"=>"No HP","name"=>"phone_number"];
- # END COLUMNS DO NOT REMOVE THIS LINE
- # START FORM DO NOT REMOVE THIS LINE
- $this->form = [];
- $this->form[] = ['label'=>'Owner','name'=>'owner_name','type'=>'text','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
- $this->form[] = ['label'=>'Technical Support','name'=>'employee_ids[]','type'=>'select2','validation'=>'required|integer|min:0','width'=>'col-sm-10','datatable'=>'cpi_mst_employee,name'];
- $this->form[] = ['label'=>'Email','name'=>'email','type'=>'email','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
- $this->form[] = ['label'=>'No HP','name'=>'phone_number','type'=>'number','validation'=>'required|numeric','width'=>'col-sm-10'];
- # END FORM DO NOT REMOVE THIS LINE
- # OLD START FORM
- //$this->form = [];
- //$this->form[] = ["label"=>"Name","name"=>"name","type"=>"text","required"=>TRUE,"validation"=>"required|string|min:3|max:70","placeholder"=>"You can only enter the letter only"];
- //$this->form[] = ["label"=>"Address","name"=>"address","type"=>"text","required"=>TRUE,"validation"=>"required|min:1|max:255"];
- //$this->form[] = ["label"=>"Phone Number","name"=>"phone_number","type"=>"number","required"=>TRUE,"validation"=>"required|numeric","placeholder"=>"You can only enter the number only"];
- //$this->form[] = ["label"=>"Created By","name"=>"created_by","type"=>"number","required"=>TRUE,"validation"=>"required|integer|min:0"];
- //$this->form[] = ["label"=>"Updated By","name"=>"updated_by","type"=>"number","required"=>TRUE,"validation"=>"required|integer|min:0"];
- //$this->form[] = ["label"=>"Deleted","name"=>"deleted","type"=>"number","required"=>TRUE,"validation"=>"required|integer|min:0"];
- # OLD END FORM
- /*
- | ----------------------------------------------------------------------
- | Sub Module
- | ----------------------------------------------------------------------
- | @label = Label of action
- | @path = Path of sub module
- | @foreign_key = foreign key of sub table/module
- | @button_color = Bootstrap Class (primary,success,warning,danger)
- | @button_icon = Font Awesome Class
- | @parent_columns = Sparate with comma, e.g : name,created_at
- |
- */
- $this->sub_module = array();
- /*
- | ----------------------------------------------------------------------
- | Add More Action Button / Menu
- | ----------------------------------------------------------------------
- | @label = Label of action
- | @url = Target URL, you can use field alias. e.g : [id], [name], [title], etc
- | @icon = Font awesome class icon. e.g : fa fa-bars
- | @color = Default is primary. (primary, warning, succecss, info)
- | @showIf = If condition when action show. Use field alias. e.g : [id] == 1
- |
- */
- $this->addaction = array();
- /*
- | ----------------------------------------------------------------------
- | Add More Button Selected
- | ----------------------------------------------------------------------
- | @label = Label of action
- | @icon = Icon from fontawesome
- | @name = Name of button
- | Then about the action, you should code at actionButtonSelected method
- |
- */
- $this->button_selected = array();
- /*
- | ----------------------------------------------------------------------
- | Add alert message to this module at overheader
- | ----------------------------------------------------------------------
- | @message = Text of message
- | @type = warning,success,danger,info
- |
- */
- $this->alert = array();
- /*
- | ----------------------------------------------------------------------
- | Add more button to header button
- | ----------------------------------------------------------------------
- | @label = Name of button
- | @url = URL Target
- | @icon = Icon from Awesome.
- |
- */
- $this->index_button = array();
- /*
- | ----------------------------------------------------------------------
- | Customize Table Row Color
- | ----------------------------------------------------------------------
- | @condition = If condition. You may use field alias. E.g : [id] == 1
- | @color = Default is none. You can use bootstrap success,info,warning,danger,primary.
- |
- */
- $this->table_row_color = array();
- /*
- | ----------------------------------------------------------------------
- | You may use this bellow array to add statistic at dashboard
- | ----------------------------------------------------------------------
- | @label, @count, @icon, @color
- |
- */
- $this->index_statistic = array();
- /*
- | ----------------------------------------------------------------------
- | Add javascript at body
- | ----------------------------------------------------------------------
- | javascript code in the variable
- | $this->script_js = "function() { ... }";
- |
- */
- $this->script_js = "";
- /*
- | ----------------------------------------------------------------------
- | Include HTML Code before index table
- | ----------------------------------------------------------------------
- | html code to display it before index table
- | $this->pre_index_html = "<p>test</p>";
- |
- */
- $this->pre_index_html = null;
- /*
- | ----------------------------------------------------------------------
- | Include HTML Code after index table
- | ----------------------------------------------------------------------
- | html code to display it after index table
- | $this->post_index_html = "<p>test</p>";
- |
- */
- $this->post_index_html = null;
- /*
- | ----------------------------------------------------------------------
- | Include Javascript File
- | ----------------------------------------------------------------------
- | URL of your javascript each array
- | $this->load_js[] = asset("myfile.js");
- |
- */
- $this->load_js = [
- asset("js/owner-form.js")
- ];
- /*
- | ----------------------------------------------------------------------
- | Add css style at body
- | ----------------------------------------------------------------------
- | css code in the variable
- | $this->style_css = ".style{....}";
- |
- */
- $this->style_css = NULL;
- /*
- | ----------------------------------------------------------------------
- | Include css File
- | ----------------------------------------------------------------------
- | URL of your css each array
- | $this->load_css[] = asset("myfile.css");
- |
- */
- $this->load_css = array();
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for button selected
- | ----------------------------------------------------------------------
- | @id_selected = the id selected
- | @button_name = the name of button
- |
- */
- public function actionButtonSelected($id_selected,$button_name) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for manipulate query of index result
- | ----------------------------------------------------------------------
- | @query = current sql query
- |
- */
- public function hook_query_index(&$query) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for manipulate row of index table html
- | ----------------------------------------------------------------------
- |
- */
- public function hook_row_index($column_index,&$column_value) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for manipulate data input before add data is execute
- | ----------------------------------------------------------------------
- | @arr
- |
- */
- public function hook_before_add(&$postdata) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for execute command after add public static function called
- | ----------------------------------------------------------------------
- | @id = last insert id
- |
- */
- public function hook_after_add($id) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for manipulate data input before update data is execute
- | ----------------------------------------------------------------------
- | @postdata = input post data
- | @id = current id
- |
- */
- public function hook_before_edit(&$postdata,$id) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for execute command after edit public static function called
- | ----------------------------------------------------------------------
- | @id = current id
- |
- */
- public function hook_after_edit($id) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for execute command before delete public static function called
- | ----------------------------------------------------------------------
- | @id = current id
- |
- */
- public function hook_before_delete($id) {
- //Your code here
- }
- /*
- | ----------------------------------------------------------------------
- | Hook for execute command after delete public static function called
- | ----------------------------------------------------------------------
- | @id = current id
- |
- */
- public function hook_after_delete($id) {
- //Your code here
- }
- //By the way, you can still create your own method in here... :)
- public function postAddSave(){
- dd(Request::all());
- try{
- $owner = OwnerModel::create([
- 'owner_name' => Request::get('owner_name'),
- // 'area_id' => Request::get('area_id'),
- 'employee_id' => Request::get('employee_id'),
- // 'city_id' => Request::get('city_id'),
- 'request_id' => Request::get('request_id'),
- // 'address' => Request::get('address'),
- 'email' => Request::get('email'),
- 'phone_number' => Request::get('phone_number'),
- 'created_at' => Request::get('created_at'),
- 'created_by' => Request::get('created_by'),
- 'updated_at' => Request::get('updated_at'),
- 'updated_by' => Request::get('updated_by'),
- ])->id;
- foreach (Request::get('employee_id') as $employee_id) {
- UserOwnerModel::create([
- 'owner_id'=> $owner,
- 'employee_id'=> $employee_id
- ]);
- }
- return redirect('/admin/cpi_mst_owner?m=6');
- } catch (\Exception $e){
- return redirect()->back();
- }
- }
- public function technical_support($id){
- // $owner = OwnerModel::find($id);
- // $ts = UserModel::find($owner->request_by)->name;
- // // dd($ts);
- // return $ts;
- }
- // public function area($id){
- // $area= AreaModel::find($id)->name;
- // return $area;
- // }
- // public function city($id){
- // $ct= CityModel::find($id)->name_city;
- // return $ct;
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement