예제 #1
0
 /**
  * Returns current database prefix
  *
  * @return string
  */
 public function databasePrefix()
 {
     if ($this->query_type == 'builder') {
         $query = $this->query;
     } else {
         $query = $this->query->getQuery();
     }
     return $query->getGrammar()->getTablePrefix();
 }
예제 #2
0
 /**
  * Date Formate Database
  *
  * @param Builder  $query    Builder
  * @param string   $key      Column
  * @param string   $operator String Operator
  *
  * @return string
  */
 private function dateFormatDb($query, $key, $operator)
 {
     if (!$this->grammar) {
         $this->grammar = $query->getQuery()->getGrammar();
     }
     $key = $this->grammar->wrap($key);
     $formatDb = sprintf("%s %s ?", $key, $operator);
     switch (true) {
         case $this->grammar instanceof \Illuminate\Database\Query\Grammars\MySqlGrammar:
             $formatDb = sprintf("DATE(%s) %s ?", $key, $operator);
             break;
         case $this->grammar instanceof \Illuminate\Database\Query\Grammars\PostgresGrammar:
             $formatDb = sprintf("DATE_TRUNC('day', %s) %s ?", $key, $operator);
             break;
         case $this->grammar instanceof \Illuminate\Database\Query\Grammars\SQLiteGrammar:
             $formatDb = sprintf("strftime('%%Y-%%m-%%d', %s) %s ?", $key, $operator);
             break;
         case $this->grammar instanceof \Illuminate\Database\Query\Grammars\SqlServerGrammar:
             $formatDb = sprintf("CAST(%s AS DATE) %s ?", $key, $operator);
     }
     return $formatDb;
 }
예제 #3
0
 /**
  * Add the force delete extension to the builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @return void
  */
 protected function addForceDelete(Builder $builder)
 {
     $builder->macro('forceDelete', function (Builder $builder) {
         return $builder->getQuery()->delete();
     });
 }
 /**
  * Remove the scope from the given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return void
  */
 public function remove(Builder $builder, Model $model)
 {
     $column = $model->getQualifiedDeletedAtColumn();
     $query = $builder->getQuery();
     $query->wheres = collect($query->wheres)->reject(function ($where) use($column) {
         return $this->isSoftDeleteConstraint($where, $column);
     })->values()->all();
 }