Example #1
0
 /**
  * Get the table for the current model.
  *
  * @return Table|null
  */
 public static function getTable()
 {
     $class = implode('', array_slice(explode('\\', static::class), -1));
     if (static::$tableName === null) {
         static::$tableName = Str::pluralize(Str::snakeCase($class));
     }
     $alias = Str::pluralize(Str::snakeCase($class));
     return Table::find(static::$tableName, $alias);
 }
Example #2
0
 /**
  * Changes query type to delete, then executes the query.
  *
  * @param array $fields The fields to be deleted
  *
  * @return bool
  */
 public function delete()
 {
     $this->type = self::DELETE;
     // We can't use aliases for columns in a delete query,
     // so we reset the table name here to avoid errors,
     // and re-store it in the cache.
     $this->table = Table::find($this->table->name, $this->table->name, $this->instance);
     return $this->execute();
 }