Hook Method is a method on a controller class that you can use as a bridge as before, while and after the process of an action (CRUD).

Example Hook After Edit :

I have the invoice module. I want after changing the status of the payment on the invoice of Pay become Lunas yet, then at the same time send a confirmation email is paid to the member concerned.

In the example above case that we need to underline is that when changing the payment status, meaning it refers to a method of data EDIT. And Hook method you can use is hook_after_edit.

public function hook_after_edit($id) {
    if(Request::get('status') == 'Paid') {
        $row = CRUDBooster::first($this->table,$id);
        $member = CRUDBooster::first('member',$row->member_id);
        $data = ['name'=>$member->name ];

In the above example of a simple script will send an email to the member if the selected status is Paid.

If you are using hook_after_edit you will get the return value of the ID data storage results in the table. So you can process the data returned by ID forth obtained.

email_after_paid is a template from the Email Template slug that has been made, it should be noted that prior to sending an email with your sendEmail CRUDBooster must be possessed her email template beforehand.

In addition you can also apply on the hook method such as:

  1. hook_before_add(&$postdata)
  2. hook_after_add($id)
  3. hook_before_edit(&$postdata,$id)
  4. hook_after_edit($id)
  5. hook_before_delete($id)
  6. hook_after_delete($id)

Example Hook Query Index :

I would like to ask the invoicing data which only has the status of Lunas.

By default module on CRUDBooster do not have a certain condition alias displays all data that is sorted newest to oldest. Therefore, we need to do a little modification to conditions such as the case of the above can be applied to our invoice module, the use Hook Query Index.

public function hook_query_index(&$query) {

It turned out that his pace is very easy, you simply apply a congenital condition DB Query laravel on hook_query_index method.

Example Hook Row Index : 

I want to see the status column of the invoice module has the color of each - each in accordance with the type of status

From the example above case you meant to manipulate the HTML output in the table invoice module. You do not need to find and dismantle html tables. Hook because it provided a special method to manipulate the display table module.

public function hook_row_index($index,&$value) {
        if($value == 'Lunas') {
            $value = '< span class="label label-success" >Lunas< / span >';
            $value = '< span class="label label-warning" >Belum Lunas< / span >';

In the simple example above, we have to find out the status column of the order of columns keberapa, suppose the example above 5.