callbackBeforeDelete(callable $callback)

The callback that will be used right before the delete. The only parameter that the state will have is the primary key value.


$crud->callbackBeforeDelete(function ($stateParameters) {
    // Your code here    

    return $stateParameters;

The $stateParameters variable is at the below form:

$stateParameters = (object)[
    'primaryKeyValue' => '1234'

Below there is a working example of the callbackBeforeDelete method.

$crud->setSubject('Office', 'Offices');

$crud->callbackBeforeDelete(function ($stateParameters) {
  // Custom error messages are only available on Grocery CRUD Enterprise
  $errorMessage = new \GroceryCrud\Core\Error\ErrorMessage();
  return $errorMessage->setMessage("You don't have permissions to delete this office\n");

$output = $crud->render();