leftJoin() public method

Add a left join to the query.
public leftJoin ( string $table, string $first, string $operator = null, string $second = null ) : Builder | static
$table string
$first string
$operator string
$second string
return Builder | static
Exemplo n.º 1
0
 /**
  * @param $table
  * @param $key $table.key
  * @param bool $fkey $this->table.key
  * @return $this
  */
 public function leftJoinOn($table, $key, $fkey = false)
 {
     $fkey = $fkey ?: $key;
     $key = starts_with($key, $table . '.') ? $key : $table . '.' . $key;
     $fkey = starts_with($key, $this->table . '.') ? $fkey : $this->table . '.' . $fkey;
     $this->operator = $this->operator->leftJoin($table, $key, '=', $fkey);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Add a left join to the query.
  *
  * @param string $table
  * @param string $first
  * @param string $operator
  * @param string $second
  * @return \Illuminate\Database\Query\Builder|static 
  * @static 
  */
 public static function leftJoin($table, $first, $operator = null, $second = null)
 {
     return \Illuminate\Database\Query\Builder::leftJoin($table, $first, $operator, $second);
 }
Exemplo n.º 3
0
 /**
  * @param \Illuminate\Database\Query\Builder $query
  * @return \Illuminate\Database\Query\Builder
  */
 public function scopeWithAuthor($query)
 {
     return $query->leftJoin('users', 'users.id', '=', "{$this->table}.user_id")->addSelect("users.username as author");
 }
Exemplo n.º 4
0
 /**
  * Load thông tin user
  *
  * @param \Illuminate\Database\Query\Builder $query
  *
  * @return \Illuminate\Database\Query\Builder|static
  */
 public function scopeWithUser($query)
 {
     $query->leftJoin('users', "{$this->table}.user_id", '=', "users.id")->addSelect('users.name as user_name', 'users.username as user_username');
     return $query;
 }
Exemplo n.º 5
0
 /**
  * $query 에 join 된 쿼리를 리턴
  *
  * @param Builder $query query builder
  * @return Builder
  */
 public function joinRevision(Builder $query)
 {
     $config = $this->config;
     $tableName = $query->from;
     $table = $this->handler->getConfigHandler()->getRevisionTableName($config);
     $query->leftJoin($table, function (JoinClause $join) use($tableName, $table, $config) {
         $join->on(sprintf('%s.%s', $tableName, $config->get('joinColumnName')), '=', sprintf('%s.dynamicFieldTargetId', $table))->on(sprintf('%s.revisionId', $tableName), '=', sprintf('%s.revisionId', $table));
     });
     return $query;
 }