FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge branch '4.1' · JavaDevl/framework@872bc11 · GitHub

Commit 872bc11

Browse files
committed
Merge branch '4.1'
2 parents e2e353b + e36c2ab commit 872bc11

33 files changed

Lines changed: 472 additions & 65 deletions

‎src/Illuminate/Auth/Guard.php‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,25 @@ public function user()
143143

144144
if (is_null($user) && ! is_null($recaller))
145145
{
146-
$user = $this->provider->retrieveByID($recaller);
147-
148-
$this->viaRemember = ! is_null($user);
146+
$user = $this->getUserByRecaller($recaller);
149147
}
150148

151149
return $this->user = $user;
152150
}
153151

152+
/**
153+
* Pull a user from the repository by its recaller ID.
154+
*
155+
* @param mixed $id
156+
* @return mixed
157+
*/
158+
protected function getUserByRecaller($id)
159+
{
160+
$this->viaRemember = ! is_null($user = $this->provider->retrieveByID($id));
161+
162+
return $user;
163+
}
164+
154165
/**
155166
* Get the decrypted recaller cookie for the request.
156167
*

‎src/Illuminate/Cache/FileStore.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ public function forever($key, $value)
152152
*/
153153
public function forget($key)
154154
{
155-
$this->files->delete($this->path($key));
155+
$file = $this->path($key);
156+
157+
if ($this->files->exists($file))
158+
{
159+
$this->files->delete($file);
160+
}
156161
}
157162

158163
/**

‎src/Illuminate/Cache/Repository.php‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class Repository implements ArrayAccess {
2121
*/
2222
protected $default = 60;
2323

24+
/**
25+
* An array of registered Cache macros.
26+
*
27+
* @var array
28+
*/
29+
protected $macros = array();
30+
2431
/**
2532
* Create a new cache repository instance.
2633
*
@@ -243,15 +250,35 @@ protected function getMinutes($duration)
243250
}
244251

245252
/**
246-
* Dynamically pass missing methods to the store.
253+
* Register a macro with the Cache class.
254+
*
255+
* @param string $name
256+
* @param callable $callback
257+
* @return void
258+
*/
259+
public function macro($name, $callback)
260+
{
261+
$this->macros[$name] = $callback;
262+
}
263+
264+
/**
265+
* Handle dynamic calls into macros or pass missing methods to the store.
247266
*
248267
* @param string $method
249-
* @param array $parameters
268+
* @param array $parameters
250269
* @return mixed
251270
*/
252271
public function __call($method, $parameters)
253272
{
254-
return call_user_func_array(array($this->store, $method), $parameters);
273+
if (isset($this->macros[$method]))
274+
{
275+
return call_user_func_array($this->macros[$method], $parameters);
276+
}
277+
else
278+
{
279+
return call_user_func_array(array($this->store, $method), $parameters);
280+
}
255281
}
256282

283+
257284
}

‎src/Illuminate/Cache/TaggedCache.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ public function put($key, $value, $minutes)
6969
return $this->store->put($this->taggedItemKey($key), $value, $minutes);
7070
}
7171

72+
/**
73+
* Store an item in the cache if the key does not exist.
74+
*
75+
* @param string $key
76+
* @param mixed $value
77+
* @param Carbon|Datetime|int $minutes
78+
* @return bool
79+
*/
80+
public function add($key, $value, $minutes)
81+
{
82+
if (is_null($this->get($key)))
83+
{
84+
$this->put($key, $value, $minutes); return true;
85+
}
86+
87+
return false;
88+
}
89+
7290
/**
7391
* Increment the value of an item in the cache.
7492
*

‎src/Illuminate/Database/Eloquent/Builder.php‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,46 @@ protected function isNested($name, $relation)
580580
return $dots && starts_with($name, $relation) && $name != $relation;
581581
}
582582

583+
/**
584+
* Add a basic where clause to the query.
585+
*
586+
* @param string $column
587+
* @param string $operator
588+
* @param mixed $value
589+
* @param string $boolean
590+
* @return \Illuminate\Database\Eloquent\Builder|static
591+
*/
592+
public function where($column, $operator = null, $value = null, $boolean = 'and')
593+
{
594+
if ($column instanceof Closure)
595+
{
596+
$query = $this->model->newQuery();
597+
598+
call_user_func($column, $query);
599+
600+
$this->query->addNestedWhereQuery($query->getQuery(), $boolean);
601+
}
602+
else
603+
{
604+
$this->query->where($column, $operator, $value, $boolean);
605+
}
606+
607+
return $this;
608+
}
609+
610+
/**
611+
* Add an "or where" clause to the query.
612+
*
613+
* @param string $column
614+
* @param string $operator
615+
* @param mixed $value
616+
* @return \Illuminate\Database\Eloquent\Builder|static
617+
*/
618+
public function orWhere($column, $operator = null, $value = null)
619+
{
620+
return $this->where($column, $operator, $value, 'or');
621+
}
622+
583623
/**
584624
* Add a relationship count condition to the query.
585625
*

‎src/Illuminate/Database/Eloquent/Model.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ public static function all($columns = array('*'))
503503
*/
504504
public static function find($id, $columns = array('*'))
505505
{
506+
if (is_array($id) && empty($id)) return new Collection;
507+
506508
$instance = new static;
507509

508510
return $instance->newQuery()->find($id, $columns);
@@ -752,8 +754,6 @@ public function belongsToMany($related, $table = null, $foreignKey = null, $othe
752754
if (is_null($relation))
753755
{
754756
$caller = $this->getBelongsToManyCaller();
755-
756-
$name = $caller['function'];
757757
}
758758

759759
// First, we'll need to determine the foreign key and "other key" for the

‎src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ protected function touchingParent()
843843
*/
844844
protected function guessInverseRelation()
845845
{
846-
return strtolower(str_plural(class_basename($this->getParent())));
846+
return camel_case(str_plural(class_basename($this->getParent())));
847847
}
848848

849849
/**

‎src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function log($file, $batch)
8282
*/
8383
public function delete($migration)
8484
{
85-
$query = $this->table()->where('migration', $migration->migration)->delete();
85+
$this->table()->where('migration', $migration->migration)->delete();
8686
}
8787

8888
/**
@@ -178,4 +178,4 @@ public function setSource($name)
178178
$this->connection = $name;
179179
}
180180

181-
}
181+
}

‎src/Illuminate/Database/Query/Builder.php‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,19 +514,28 @@ public function whereNested(Closure $callback, $boolean = 'and')
514514
// To handle nested queries we'll actually create a brand new query instance
515515
// and pass it off to the Closure that we have. The Closure can simply do
516516
// do whatever it wants to a query then we will store it for compiling.
517-
$type = 'Nested';
518-
519517
$query = $this->newQuery();
520518

521519
$query->from($this->from);
522520

523521
call_user_func($callback, $query);
524522

525-
// Once we have let the Closure do its things, we can gather the bindings on
526-
// the nested query builder and merge them into these bindings since they
527-
// need to get extracted out of the children and assigned to the array.
523+
return $this->addNestedWhereQuery($query, $boolean);
524+
}
525+
526+
/**
527+
* Add another query builder as a nested where to the query builder.
528+
*
529+
* @param \Illuminate\Database\Query\Builder|static $query
530+
* @param string $boolean
531+
* @return \Illuminate\Database\Query\Builder|static
532+
*/
533+
public function addNestedWhereQuery($query, $boolean = 'and')
534+
{
528535
if (count($query->wheres))
529536
{
537+
$type = 'Nested';
538+
530539
$this->wheres[] = compact('type', 'query', 'boolean');
531540

532541
$this->mergeBindings($query);

‎src/Illuminate/Database/Query/Grammars/Grammar.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ protected function compileGroups(Builder $query, $groups)
410410
*/
411411
protected function compileHavings(Builder $query, $havings)
412412
{
413-
$me = $this;
414-
415413
$sql = implode(' ', array_map(array($this, 'compileHaving'), $havings));
416414

417415
return 'having '.preg_replace('/and /', '', $sql, 1);
@@ -679,4 +677,4 @@ protected function removeLeadingBoolean($value)
679677
return preg_replace('/and |or /', '', $value, 1);
680678
}
681679

682-
}
680+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL