original_string: public function destroy($id)
      {
          $record = $this->modelRepository->findOrFail($id);
  
          if ( ! $this->isModelDeletable($record)) {
              return $this->failureResponse(
                  $this->getLastUnmetDeleteConditionMessage()
              );
          }
  
          event( new Events\DeletingModelInCms($record) );
  
          if ( ! $this->deleteModel($record)) {
              // @codeCoverageIgnoreStart
              return $this->failureResponse(
                  cms_trans('models.delete.failure.unknown')
              );
              // @codeCoverageIgnoreEnd
          }
  
          event( new Events\ModelDeletedInCms($this->getModelInformation()->modelClass(), $id) );
  
          if (request()->ajax()) {
              return response()->json([
                  'success' => true,
              ]);
          }
  
          cms_flash(
              cms_trans(
                  'models.delete.success-message',
                  [ 'record' => $this->getSimpleRecordReference($id, $record) ]
              ),
              FlashLevel::SUCCESS
          );
  
          return redirect()->back();
      }
code: public function destroy($id)
      {
          $record = $this->modelRepository->findOrFail($id);
  
          if ( ! $this->isModelDeletable($record)) {
              return $this->failureResponse(
                  $this->getLastUnmetDeleteConditionMessage()
              );
          }
  
          event( new Events\DeletingModelInCms($record) );
  
          if ( ! $this->deleteModel($record)) {
              // @codeCoverageIgnoreStart
              return $this->failureResponse(
                  cms_trans('models.delete.failure.unknown')
              );
              // @codeCoverageIgnoreEnd
          }
  
          event( new Events\ModelDeletedInCms($this->getModelInformation()->modelClass(), $id) );
  
          if (request()->ajax()) {
              return response()->json([
                  'success' => true,
              ]);
          }
  
          cms_flash(
              cms_trans(
                  'models.delete.success-message',
                  [ 'record' => $this->getSimpleRecordReference($id, $record) ]
              ),
              FlashLevel::SUCCESS
          );
  
          return redirect()->back();
      }
code_tokens: public function destroy ( $ id ) { $ record = $ this -> modelRepository -> findOrFail ( $ id ) ; if ( ! $ this -> isModelDeletable ( $ record ) ) { return $ this -> failureResponse ( $ this -> getLastUnmetDeleteConditionMessage ( ) ) ; } event ( new Events \ DeletingModelInCms ( $ record ) ) ; if ( ! $ this -> deleteModel ( $ record ) ) { // @codeCoverageIgnoreStart return $ this -> failureResponse ( cms_trans ( 'models.delete.failure.unknown' ) ) ; // @codeCoverageIgnoreEnd } event ( new Events \ ModelDeletedInCms ( $ this -> getModelInformation ( ) -> modelClass ( ) , $ id ) ) ; if ( request ( ) -> ajax ( ) ) { return response ( ) -> json ( [ 'success' => true , ] ) ; } cms_flash ( cms_trans ( 'models.delete.success-message' , [ 'record' => $ this -> getSimpleRecordReference ( $ id , $ record ) ] ) , FlashLevel :: SUCCESS ) ; return redirect ( ) -> back ( ) ; }
docstring: Deletes a record, if allowed.
  
  @param mixed $id
  @return mixed
  @event DeletingModelInCms
  @event ModelDeletedInCms
docstring_tokens: Deletes a record if allowed .