How to delete record through page events from detail page from master page

Hi,
I want to delete detail page record which has same protocol _ref as master table. I want to accomplish this through clicking on delete icon in master list.

I have written the below code of master_page events: before delete.

 private function beforeDelete($rec_id, $record){
DB::table('stability_protocol_detail')->where('protocol_ref', '=', $record->protocol_ref)->delete(); }

But it shows the below error:

Please help me to figure it.

Thanks

@phrmst this is a bug, which has been reported to the dev. The error there is that the second parameter of the beforeDelete and other similar Page Event functions are not being parsed by the app when it calls the function. You can remove the error by setting the $record to null.

private function beforeDelete($rec_id, $record=null){

OR

You could locate where the function is being called and parse the second parameter to the function. It would look something similar to this, but might not be exactly, in terms of the variable name.
from this

beforeDelete($rec_id);

to this

beforeDelete($rec_id, $record);

I have solved my problem. The main problem was in controller.

I have changed the code in respective controller through addition of $record variable.

function delete(Request $request, $rec_id = null){
        $arr_id = explode(",", $rec_id);
        $query = Stability_Protocol_Header::query();
        $this->beforeDelete($rec_id, $record);
        $query->whereIn("id", $arr_id);
        $query->delete();
        return $this->respond($arr_id);
    }

to

function delete(Request $request, $rec_id = null){
        $arr_id = explode(",", $rec_id);
        $query = Stability_Protocol_Header::query();
        $record = $query->findOrFail($rec_id, Stability_Protocol_Header::editFields());
        $this->beforeDelete($rec_id, $record);
        $query->whereIn("id", $arr_id);
        $query->delete();
        return $this->respond($arr_id);
    }

Thanks