Can I use Events on Laravel5.5?

QuestionsCan I use Events on Laravel5.5?
hirohito wada asked 3 years ago

I can't use Events on Laravel5.5.

$e["on_insert"] = array("add_kamoku", null, FALSE);

error messeage.

call_user_func() expects parameter 1 to be a valid callback, function 'add_kamoku' not found or invalid function name

8 Answers
Abu Ghufran answered 3 years ago

It appears that your function add_kamoku is some class method and not global function.
In that case, you need to pass class name as second param. e.g. if your class name is 'Foo' you need to set:

$e["on_insert"] = array("add_kamoku", "Foo", FALSE);

hirohito wada answered 3 years ago

Thank you.

It solved. A little problem remains.

'jqg'+xx(xx is integer) show in Id column(Primary/autoincrement).
When reloading, It change integer.

Abu Ghufran answered 3 years ago

You can set:

$opt["reloadedit"] = true;


It will force reloading after add/edit.

hirohito wada answered 3 years ago

Unfortunately it doesn't work.
My options is follow



protected function opt_edit($param) {

$opt["cellEdit"] = true;
$opt["scroll"] = true;
$opt["autowidth"] = true;
$opt["resizable"] = true;
$opt["viewrecords"] = true;
$opt["caption"] = $param;
$opt["actionicon"] = TRUE;
$opt["reloadedit"] = true;
// $opt["toolbar"] = TRUE;
// $opt["toppager"] = TRUE;
return $opt;

Abu Ghufran answered 3 years ago

Can you check if this issue exist on demo:
If it's working in demo, please compare you code with it.

gianluca answered 4 months ago

Hi Abu,

I need to handle on_insert event in a subgrid (laravel) so I add in my public function index_detail(Request $request) following code:

$e[“on_insert”] = array(“add_prestazione”, “App\Http\Controllers\OrdiniController”, true);


In the same controller I put my custom code with a test query:

public function add_prestazione($input)
global $grid;
$grid->execute_query(“INSERT INTO test VALUES (‘2′,’testo’)”);


but I got this error message in chrome console.

  1. {message: “Call to a member function execute_query() on null”, exception: “Error”,…}
    1. exceptionError
    2. fileC:\xampp\htdocs\sigesc\app\Http\Controllers\OrdiniController.php
    3. line2169
    4. messageCall to a member function execute_query() on null
    5. trace[{file: “C:\xampp\htdocs\sigesc\app\Classes\phpgrid\jqgrid_dist.php”, line: 2594,…},…]
      1. 0{file: “C:\xampp\htdocs\sigesc\app\Classes\phpgrid\jqgrid_dist.php”, line: 2594,…}
        1. classApp\Http\Controllers\OrdiniController
        2. fileC:\xampp\htdocs\sigesc\app\Classes\phpgrid\jqgrid_dist.php
        3. functionadd_prestazione
        4. line2594
        5. type::
      2. 1{file: “C:\xampp\htdocs\sigesc\app\Http\Controllers\OrdiniController.php”, line: 1586,…}
        1. classjqgrid
        2. fileC:\xampp\htdocs\sigesc\app\Http\Controllers\OrdiniController.php
        3. functionrender
        4. line1586
        5. type->
      3. 2{function: “indexDetail”, class: “App\Http\Controllers\OrdiniController”, type: “->”}
        1. classApp\Http\Controllers\OrdiniController
        2. functionindexDetail
        3. type->

Can you help me find where I’m wrong?


Abu Ghufran Staff answered 4 months ago

When you use laravel, inside controller there is no $grid variable which is defined globally. You need to make it controller member variable and access with $this->grid;

Refer this code:

Line 16,47,86

Abu Ghufran - Dev Team
Grid 4 PHP Framework
gianluca answered 4 months ago

Thank You. Now I can fully handle on_insert events

Your Answer

3 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?