Advertisement
Guest User

Untitled

a guest
Feb 27th, 2018
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.35 KB | None | 0 0
  1. <?php namespace App\Http\Controllers;
  2.  
  3. use Session;
  4. use Request;
  5. use DB;
  6. use CRUDBooster;
  7. use QrCode;
  8.  
  9. class AdminWisudawanController extends \crocodicstudio\crudbooster\controllers\CBController {
  10.  
  11. public function cbInit() {
  12. $dt = explode("|",CRUDBooster::getSetting('periode_wisuda'));
  13.  
  14. # START CONFIGURATION DO NOT REMOVE THIS LINE
  15. $this->title_field = "nama";
  16. $this->limit = "20";
  17. $this->orderby = "nrp,asc";
  18. $this->global_privilege = false;
  19. $this->button_table_action = true;
  20. $this->button_bulk_action = true;
  21. $this->button_action_style = "button_icon";
  22. $this->button_add = true;
  23. $this->button_edit = true;
  24. $this->button_delete = true;
  25. $this->button_detail = true;
  26. $this->button_show = true;
  27. $this->button_filter = true;
  28. $this->button_import = true;
  29. $this->button_export = true;
  30. $this->table = "wisudawan";
  31. # END CONFIGURATION DO NOT REMOVE THIS LINE
  32.  
  33. # START COLUMNS DO NOT REMOVE THIS LINE
  34. $this->col = [];
  35. $this->col[] = ["label"=>"Nrp","name"=>"nrp"];
  36. $this->col[] = ["label"=>"Nama","name"=>"nama"];
  37. $this->col[] = ["label"=>"No Kursi","name"=>"no_kursi"];
  38. $this->col[] = ["label"=>"Fakultas","name"=>"fakultas"];
  39. $this->col[] = ["label"=>"Jurusan","name"=>"jurusan"];
  40. $this->col[] = ["label"=>"Jumlah Undangan","name"=>"Jumundangan"];
  41.  
  42. $this->col[] = ["label"=>"Toga ?","name"=>"is_toga"];
  43. $this->col[] = ["label"=>"Undangan ?","name"=>"is_undangan"];
  44. $this->col[] = ["label"=>"Topi ?","name"=>"is_topi"];
  45. $this->col[] = ["label"=>"Kartu ?","name"=>"is_kartu"];
  46. $this->col[] = ["label"=>"Status","name"=>"status"];
  47. $this->col[] = ["label"=>"Predikat","name"=>"predikat"];
  48. # END COLUMNS DO NOT REMOVE THIS LINE
  49.  
  50. # START FORM DO NOT REMOVE THIS LINE
  51. $this->form = [];
  52. $this->form[] = ['label'=>'Periode','name'=>'periode_id','type'=>'hidden','validation'=>'required','width'=>'col-sm-9','value'=>'1'];
  53. $this->form[] = ['label'=>'Nrp','name'=>'nrp','type'=>'text','validation'=>'required|min:1|max:255','width'=>'col-sm-10'];
  54. $this->form[] = ['label'=>'No Kursi','name'=>'no_kursi','type'=>'text','validation'=>'required','width'=>'col-sm-9'];
  55. $this->form[] = ['label'=>'Nama','name'=>'nama','type'=>'text','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
  56. $this->form[] = ['label'=>'Jurusan','name'=>'jurusan','type'=>'text','validation'=>'required|string|min:0','width'=>'col-sm-10'];
  57. $this->form[] = ['label'=>'Fakultas','name'=>'fakultas','type'=>'text','validation'=>'required|string|min:0','width'=>'col-sm-10'];
  58. $this->form[] = ['label'=>'Status','name'=>'status','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Non-Active;1|Active','value'=>'1'];
  59. $this->form[] = ['label'=>'Sudah ambil Toga?','name'=>'is_toga','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  60. $this->form[] = ['label'=>'Sudah ambil Undangan?','name'=>'is_undangan','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  61. $this->form[] = ['label'=>'Sudah ambil Topi?','name'=>'is_topi','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  62. $this->form[] = ['label'=>'Sudah ambil Kartu','name'=>'is_kartu','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah', 'value'=>'0'];
  63. $this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9','value'=>'0'];
  64. $this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9','value'=>'0'];
  65. $this->form[] = ['label'=>'Tanggal Lulus','name'=>'tanggal_lulus','type'=>'datetime','width'=>'col-sm-9'];
  66. $this->form[] = ['label'=>'Alamat','name'=>'alamat','type'=>'text','width'=>'col-sm-9'];
  67. $this->form[] = ['label'=>'Judulta','name'=>'judulta','type'=>'text','width'=>'col-sm-9'];
  68. $this->form[] = ['label'=>'Predikat','name'=>'predikat','type'=>'select2','validation'=>'required','width'=>'col-sm-9','dataenum'=>'Sangat Memuaskan;Biasa','value'=>'Biasa'];
  69. # END FORM DO NOT REMOVE THIS LINE
  70.  
  71. # OLD START FORM
  72. //$this->form = [];
  73. //$this->form[] = ['label'=>'Periode','name'=>'periode_id','type'=>'hidden','validation'=>'required','width'=>'col-sm-9'];
  74. //$this->form[] = ['label'=>'Nrp','name'=>'nrp','type'=>'text','validation'=>'required|min:1|max:255','width'=>'col-sm-10'];
  75. //$this->form[] = ['label'=>'No Kursi','name'=>'no_kursi','type'=>'text','validation'=>'required','width'=>'col-sm-9'];
  76. //$this->form[] = ['label'=>'Nama','name'=>'nama','type'=>'text','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
  77. //$this->form[] = ['label'=>'Jurusan','name'=>'jurusan_id','type'=>'text','validation'=>'required|string|min:0','width'=>'col-sm-10'];
  78. //$this->form[] = ['label'=>'Fakultas','name'=>'fakultas_id','type'=>'text','validation'=>'required|string|min:0','width'=>'col-sm-10'];
  79. //$this->form[] = ['label'=>'Status','name'=>'status','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Non-Active;1|Active','value'=>'1'];
  80. //$this->form[] = ['label'=>'Sudah ambil Toga?','name'=>'is_toga','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  81. //$this->form[] = ['label'=>'Sudah ambil Undangan?','name'=>'is_undangan','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  82. //$this->form[] = ['label'=>'Sudah ambil Topi?','name'=>'is_topi','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  83. //$this->form[] = ['label'=>'Sudah ambil Kartu','name'=>'is_kartu','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah', 'value'=>'0'];
  84. //$this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9','value'=>'0'];
  85. //$this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9','value'=>'0'];
  86. //$this->form[] = ['label'=>'Tanggal Lulus','name'=>'tanggal_lulus','type'=>'datetime','width'=>'col-sm-9'];
  87. //$this->form[] = ['label'=>'Alamat','name'=>'alamat','type'=>'text','width'=>'col-sm-9'];
  88. //$this->form[] = ['label'=>'Judulta','name'=>'judulta','type'=>'text','width'=>'col-sm-9'];
  89. //$this->form[] = ['label'=>'Predikat','name'=>'predikat','type'=>'select2','validation'=>'required','width'=>'col-sm-9'];
  90. # OLD END FORM
  91.  
  92. /*BACKUP F_HAN
  93. $this->form = [];
  94. $this->form[] = ['label'=>'Periode','name'=>'periode_id','type'=>'hidden','validation'=>'required','width'=>'col-sm-9','value'=>$dt[0]];
  95. $this->form[] = ['label'=>'Nrp','name'=>'nrp','type'=>'text','validation'=>'required|min:1|max:255','width'=>'col-sm-10'];
  96. $this->form[] = ['label'=>'No Kursi','name'=>'no_kursi','type'=>'text','validation'=>'required','width'=>'col-sm-9'];
  97. $this->form[] = ['label'=>'Nama','name'=>'nama','type'=>'text','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
  98. $this->form[] = ['label'=>'Jurusan','name'=>'jurusan_id','type'=>'select2','validation'=>'required|integer|min:0','width'=>'col-sm-10','datatable'=>'jurusan,nama','datatable_ajax'=>'true'];
  99. $this->form[] = ['label'=>'Fakultas','name'=>'fakultas_id','type'=>'select2','validation'=>'required|integer|min:0','width'=>'col-sm-10','datatable'=>'fakultas,nama','datatable_ajax'=>'true'];
  100. $this->form[] = ['label'=>'Status','name'=>'status','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Non-Active;1|Active','value'=>'1'];
  101. $this->form[] = ['label'=>'Sudah ambil Toga?','name'=>'is_toga','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  102. $this->form[] = ['label'=>'Sudah ambil Undangan?','name'=>'is_undangan','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  103. $this->form[] = ['label'=>'Sudah ambil Topi?','name'=>'is_topi','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah','value'=>'0'];
  104. $this->form[] = ['label'=>'Sudah ambil Kartu','name'=>'is_kartu','type'=>'radio','validation'=>'required','width'=>'col-sm-9','dataenum'=>'0|Belum; 1|Sudah', 'value'=>'0'];
  105. $this->form[] = ['label'=>'Tambahan Undangan','name'=>'tambahan_undangan','type'=>'text','validation'=>'required','width'=>'col-sm-9'];
  106. */
  107.  
  108. /*
  109. | ----------------------------------------------------------------------
  110. | Sub Module
  111. | ----------------------------------------------------------------------
  112. | @label = Label of action
  113. | @path = Path of sub module
  114. | @foreign_key = foreign key of sub table/module
  115. | @button_color = Bootstrap Class (primary,success,warning,danger)
  116. | @button_icon = Font Awesome Class
  117. | @parent_columns = Sparate with comma, e.g : name,created_at
  118. |
  119. */
  120. $this->sub_module = array();
  121.  
  122.  
  123. /*
  124. | ----------------------------------------------------------------------
  125. | Add More Action Button / Menu
  126. | ----------------------------------------------------------------------
  127. | @label = Label of action
  128. | @url = Target URL, you can use field alias. e.g : [id], [name], [title], etc
  129. | @icon = Font awesome class icon. e.g : fa fa-bars
  130. | @color = Default is primary. (primary, warning, succecss, info)
  131. | @showIf = If condition when action show. Use field alias. e.g : [id] == 1
  132. |
  133. */
  134. $this->addaction = array();
  135. $this->addaction[] = ['label'=>'','url'=>CRUDBooster::mainpath('set-qrcode/[nrp]'),'icon'=>'fa fa-qrcode','color'=>'info', 'target'=>'blank'];
  136.  
  137. //dd($this->addaction);
  138.  
  139.  
  140. /*
  141. | ----------------------------------------------------------------------
  142. | Add More Button Selected
  143. | ----------------------------------------------------------------------
  144. | @label = Label of action
  145. | @icon = Icon from fontawesome
  146. | @name = Name of button
  147. | Then about the action, you should code at actionButtonSelected method
  148. |
  149. */
  150. $this->button_selected = array();
  151. $this->button_selected[] = ['label'=>'Set Active','icon'=>'fa fa-check','name'=>'set_active'];
  152. $this->button_selected[] = ['label'=>'Set Deactive','icon'=>'fa fa-check','name'=>'set_deactive'];
  153. $this->button_selected[] = ['label'=>'Generate Qr Code','icon'=>'fa fa-qrcode','name'=>'generate_qrcode'];
  154.  
  155.  
  156.  
  157. /*
  158. | ----------------------------------------------------------------------
  159. | Add alert message to this module at overheader
  160. | ----------------------------------------------------------------------
  161. | @message = Text of message
  162. | @type = warning,success,danger,info
  163. |
  164. */
  165. $this->alert = array();
  166.  
  167.  
  168.  
  169. /*
  170. | ----------------------------------------------------------------------
  171. | Add more button to header button
  172. | ----------------------------------------------------------------------
  173. | @label = Name of button
  174. | @url = URL Target
  175. | @icon = Icon from Awesome.
  176. |
  177. */
  178. $this->index_button = array();
  179.  
  180.  
  181. //timexecution lebih dari 30 second. hati2
  182. // $this->index_button[] = ['label'=>'Get All QRCode','url'=>CRUDBooster::mainpath("print"),"icon"=>"fa fa-qrcode"];
  183.  
  184.  
  185. /*
  186. | ----------------------------------------------------------------------
  187. | Customize Table Row Color
  188. | ----------------------------------------------------------------------
  189. | @condition = If condition. You may use field alias. E.g : [id] == 1
  190. | @color = Default is none. You can use bootstrap success,info,warning,danger,primary.
  191. |
  192. */
  193. $this->table_row_color = array();
  194.  
  195. // $this->table_row_color[] = ["condition"=>"[status] == '1' && [is_toga] == '1'","color"=>"danger"];
  196.  
  197.  
  198. /*
  199. | ----------------------------------------------------------------------
  200. | You may use this bellow array to add statistic at dashboard
  201. | ----------------------------------------------------------------------
  202. | @label, @count, @icon, @color
  203. |
  204. */
  205. $this->index_statistic = array();
  206. $this->index_statistic[] = ['label'=>'Total Mahasiswa yang Lulus','count'=>DB::table('wisudawan')->count(),'icon'=>'fa fa-user','color'=>'success'];
  207. $this->index_statistic[] = ['label'=>'Total Mahasiswa yang ikut Wisuda','count'=>DB::table('wisudawan')->where('status',1)->count(),'icon'=>'fa fa-graduation-cap','color'=>'red'];
  208. $this->index_statistic[] = ['label'=>'Total Wisudawan yang lengkap','count'=>DB::table('wisudawan')->where('status',1)->where('is_toga',1)->where('is_topi',1)->where('is_undangan',1)->where('is_kartu',1)->count(),'icon'=>'fa fa-flag','color'=>'yellow'];
  209. $this->index_statistic[] = ['label'=>'Total wisudawan yang undangan >2','count'=>DB::table('wisudawan')->where('status',1)->where('jumundangan','>',2)->count(),'icon'=>'fa fa-envelope-o','color'=>'blue'];
  210.  
  211.  
  212. /*
  213. | ----------------------------------------------------------------------
  214. | Add javascript at body
  215. | ----------------------------------------------------------------------
  216. | javascript code in the variable
  217. | $this->script_js = "function() { ... }";
  218. |
  219. */
  220. $this->script_js = NULL;
  221.  
  222.  
  223. /*
  224. | ----------------------------------------------------------------------
  225. | Include HTML Code before index table
  226. | ----------------------------------------------------------------------
  227. | html code to display it before index table
  228. | $this->pre_index_html = "<p>test</p>";
  229. |
  230. */
  231. $this->pre_index_html = "<h3> Data Wisudawan Periode: ".explode("|",CRUDBooster::getSetting('periode_wisuda'))[1] ." </h3>";
  232.  
  233.  
  234.  
  235. /*
  236. | ----------------------------------------------------------------------
  237. | Include HTML Code after index table
  238. | ----------------------------------------------------------------------
  239. | html code to display it after index table
  240. | $this->post_index_html = "<p>test</p>";
  241. |
  242. */
  243. $this->post_index_html = "
  244. <div class=\"box\">
  245. <p><b>Keterangan:</b></p>
  246. <ol>
  247. <li> Status menunjukkan status wisudawan yang terdaftar apakah jadi mengikuti acara seremonial wisuda periode tersebut </li>
  248. <li> 'Topi ?' menunjukkan apakah wisudawan sudah mengambil topi atau tidak. <b>Nilai (1)</b> berarti sudah mengambil, <b>Nilai (0)</b> berarti belum mengambil/diambil </li>
  249. <li> 'Toga ?' menunjukkan apakah wisudawan sudah mengambil toga atau tidak. <b>Nilai (1)</b> berarti sudah mengambil, <b>Nilai (0)</b> berarti belum mengambil/diambil </li>
  250. <li> 'Undangan ?' menunjukkan apakah wisudawan sudah mengambil undangan atau tidak. <b>Nilai (1)</b> berarti sudah mengambil, <b>Nilai (0)</b> berarti belum mengambil/diambil </li>
  251. <li> 'Kartu ?' menunjukkan apakah wisudawan sudah mengambil kartu atau tidak. <b>Nilai (1)</b> berarti sudah mengambil, <b>Nilai (0)</b> berarti belum mengambil/diambil </li>
  252.  
  253. </ol>
  254. </div>
  255. ";
  256.  
  257.  
  258.  
  259. /*
  260. | ----------------------------------------------------------------------
  261. | Include Javascript File
  262. | ----------------------------------------------------------------------
  263. | URL of your javascript each array
  264. | $this->load_js[] = asset("myfile.js");
  265. |
  266. */
  267. $this->load_js = array();
  268.  
  269.  
  270.  
  271. /*
  272. | ----------------------------------------------------------------------
  273. | Add css style at body
  274. | ----------------------------------------------------------------------
  275. | css code in the variable
  276. | $this->style_css = ".style{....}";
  277. |
  278. */
  279. $this->style_css = NULL;
  280.  
  281.  
  282.  
  283. /*
  284. | ----------------------------------------------------------------------
  285. | Include css File
  286. | ----------------------------------------------------------------------
  287. | URL of your css each array
  288. | $this->load_css[] = asset("myfile.css");
  289. |
  290. */
  291. $this->load_css = array();
  292.  
  293.  
  294. }
  295.  
  296. private function genTextQR($nrp)
  297. {
  298. return md5($nrp."wisuda18");
  299. }
  300.  
  301. private function actionGenerate($datamahasiswa)
  302. {
  303.  
  304. QrCode::format('png')->encoding('ASCII')->size(300)->generate($this->genTextQR($datamahasiswa->nrp),'../qrcodes/'.$datamahasiswa->nrp.'_'.$datamahasiswa->nama.'.png');
  305. DB::table('wisudawan')->where('nrp', $datamahasiswa->nrp)->update(['encrypt_code' => $this->genTextQR($datamahasiswa->nrp)]);
  306.  
  307. }
  308. public function print()
  309. {
  310. $data = DB::table('wisudawan')->where('status',1)->get();
  311. foreach($data as $d)
  312. {
  313. $this->actionGenerate($d);
  314. }
  315. return redirect('/admin/wisudawan');
  316. }
  317.  
  318. public function getSetQrcode($id) {
  319. //DB::table('products')->where('id',$id)->update(['status'=>$status]);
  320. //dd($status);
  321. //QrCode::format('png')->size(300)->generate($id);
  322.  
  323. $datamahasiswa = DB::table('wisudawan')->where('nrp',$id)->first();
  324. //dd($data);
  325. if (count($datamahasiswa)<=0) echo 'Nothing happened!';
  326. else
  327. echo '<html>
  328. <head></head>
  329. <body>
  330. <a href="'.CRUDBooster::mainpath("").'">BACK</a><br/>
  331. <h3>QR Code untuk nrp='.$datamahasiswa->nrp.' dan nama = '.$datamahasiswa->nama.' </h3>
  332. <p>
  333. Klik QR Code ini untuk download<br/>
  334. <a href="data:image/png;base64, '. base64_encode(QrCode::format('png')->encoding('ASCII')->size(300)->generate($this->genTextQR($datamahasiswa->nrp))) . '" download="'.$datamahasiswa->nrp.'_'.$datamahasiswa->nama.'.png">
  335. <img src="data:image/png;base64, '. base64_encode(QrCode::format('png')->encoding('ASCII')->size(300)->generate($this->genTextQR($datamahasiswa->nrp))) . '" /> </a>
  336. </p>
  337. </body>
  338. </html>';
  339.  
  340. //bisa dibuat: {"name":"Baba","address":"sby"}
  341.  
  342. //This will redirect back and gives a message
  343. //CRUDBooster::redirect($_SERVER['HTTP_REFERER'],"The status product has been updated !","info");
  344. }
  345. /*
  346. | ----------------------------------------------------------------------
  347. | Hook for button selected
  348. | ----------------------------------------------------------------------
  349. | @id_selected = the id selected
  350. | @button_name = the name of button
  351. |
  352. */
  353. public function actionButtonSelected($id_selected,$button_name) {
  354.  
  355. //Your code here
  356. if($button_name == 'set_active') {
  357. DB::table('wisudawan')->whereIn('id',$id_selected)->update(['status'=>1]);
  358. }
  359. if($button_name == 'set_deactive') {
  360. DB::table('wisudawan')->whereIn('id',$id_selected)->update(['status'=>0]);
  361. }
  362. if($button_name =='generate_qrcode')
  363. {
  364. foreach($id_selected as $idd)
  365. {
  366. $this->actionGenerate($d);
  367. }
  368. //dd($id_selected);
  369. }
  370.  
  371. }
  372.  
  373.  
  374. /*
  375. | ----------------------------------------------------------------------
  376. | Hook for manipulate query of index result
  377. | ----------------------------------------------------------------------
  378. | @query = current sql query
  379. |
  380. */
  381. public function hook_query_index(&$query) {
  382. //Your code here
  383. //$query->where('wisudawan.status',1);
  384. $data = explode("|",CRUDBooster::getSetting('periode_wisuda'));
  385.  
  386. $query->where('wisudawan.periode_id',$data[0]);
  387. //$query->where('wisudawan.status',1);
  388.  
  389. }
  390.  
  391. /*
  392. | ----------------------------------------------------------------------
  393. | Hook for manipulate row of index table html
  394. | ----------------------------------------------------------------------
  395. |
  396. */
  397. public function hook_row_index($column_index,&$column_value) {
  398. //Your code here
  399. if ($column_index ==6)
  400. {
  401. if ($column_value >2)
  402. {
  403. $column_value='<span class="label label-warning fa fa-arrow-up" > '.$column_value.' </span>';
  404. }
  405. }
  406.  
  407. if($column_index ==11)
  408. {
  409. if ($column_value == 0)
  410. {
  411. $column_value='<span class="label label-warning" > 0 | Non-Active </span>';
  412. }
  413. else if ($column_value == 1)
  414. {
  415. $column_value='<span class="label label-success" >1 | Active </span>';
  416. }
  417. }
  418. if($column_index ==7 || $column_index ==8|$column_index ==9|$column_index ==10)
  419. {
  420. if ($column_value == 0)
  421. {
  422. $column_value='<span class="label label-danger" > 0 | Belum </span>';
  423. }
  424. else if ($column_value == 1)
  425. {
  426. $column_value='<span class="label label-primary" > 1 | Sudah </span>';
  427. }
  428. }
  429. }
  430.  
  431. /*
  432. | ----------------------------------------------------------------------
  433. | Hook for manipulate data input before add data is execute
  434. | ----------------------------------------------------------------------
  435. | @arr
  436. |
  437. */
  438. public function hook_before_add(&$postdata) {
  439. //Your code here
  440.  
  441. }
  442.  
  443. /*
  444. | ----------------------------------------------------------------------
  445. | Hook for execute command after add public static function called
  446. | ----------------------------------------------------------------------
  447. | @id = last insert id
  448. |
  449. */
  450. public function hook_after_add($id) {
  451. //Your code here
  452.  
  453. }
  454.  
  455. /*
  456. | ----------------------------------------------------------------------
  457. | Hook for manipulate data input before update data is execute
  458. | ----------------------------------------------------------------------
  459. | @postdata = input post data
  460. | @id = current id
  461. |
  462. */
  463. public function hook_before_edit(&$postdata,$id) {
  464. //Your code here
  465.  
  466. }
  467.  
  468. /*
  469. | ----------------------------------------------------------------------
  470. | Hook for execute command after edit public static function called
  471. | ----------------------------------------------------------------------
  472. | @id = current id
  473. |
  474. */
  475. public function hook_after_edit($id) {
  476. //Your code here
  477. $tmbhundangan = Request::get('tambahan_undangan');
  478. DB::table('wisudawan')->where('id', $id)->update(['jumundangan' => 2+$tmbhundangan]);
  479.  
  480. }
  481.  
  482. /*
  483. | ----------------------------------------------------------------------
  484. | Hook for execute command before delete public static function called
  485. | ----------------------------------------------------------------------
  486. | @id = current id
  487. |
  488. */
  489. public function hook_before_delete($id) {
  490. //Your code here
  491.  
  492. }
  493.  
  494. /*
  495. | ----------------------------------------------------------------------
  496. | Hook for execute command after delete public static function called
  497. | ----------------------------------------------------------------------
  498. | @id = current id
  499. |
  500. */
  501. public function hook_after_delete($id) {
  502. //Your code here
  503.  
  504. }
  505.  
  506.  
  507.  
  508. //By the way, you can still create your own method in here... :)
  509.  
  510.  
  511. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement