Illuminate\Database\Eloquent\Builder::forceDelete PHP Method

forceDelete() public method

Run the default delete function on the builder.
public forceDelete ( ) : mixed
return mixed
    public function forceDelete()
    {
        return $this->query->delete();
    }

Usage Example

 /**
  * Either purge all the records at once or loop through them one by one.
  *
  * This is to allow events to get fired for each record if needed.
  *
  * @param Builder $query
  * @param string  $model_name
  *
  * @return int
  */
 protected function purgeRecordsAsConfigured(Builder $query, $model_name)
 {
     if ($this->fire_purge_events !== true) {
         $this->recordMessage("Deleting all the records in a single query statement.");
         return $query->forceDelete();
     }
     $this->recordMessage("Deleting each record separately and firing events.");
     $records = $query->get();
     foreach ($records as $record) {
         $this->firePurgeEvent('purging', $model_name, $record);
         $record->forceDelete();
         $this->firePurgeEvent('purged', $model_name, $record);
     }
     return $records->count();
 }
All Usage Examples Of Illuminate\Database\Eloquent\Builder::forceDelete