You may also call the first method with no arguments to get the first element in the collection. If the collection is empty, null is returned:1collect([1, 2, 3, 4])->first(); 2 3// 1flatMap()The flatMap method
1$collection = collect([1, 2, 3, 4]); 2 3$filtered = $collection->filter(function ($value, $key) { 4 return $value > 2; 5}); 6 7$filtered->all(); 8 9// [3, 4]If no callback is supplied, all entries of the collection that are equivalent to false will be removed...
An array that isnot emptywill override the rules or custom error messages specified by the class for that instance of the method only. Note:the default value for$rulesand$customMessagesis emptyarray(); thus, if you pass anarray()nothing will be overriden. ...
*/ public function getConfig(): PersistentRepository { if ($this->config === null) { if (empty($this->id)) { throw new \InvalidArgumentException('Unable to get config for model without ID.'); } $repository = new Repository($this->defaultConfigData()); $storage = (new StorageDb($...
dependencies: collection-visit "^1.0.0" component-emitter "^1.2.1" get-value "^2.0.6" has-value "^1.0.0" isobject "^3.0.1" set-value "^2.0.0" to-object-path "^0.3.0" union-value "^1.0.0" unset-value "^1.0.0" call-me-maybe@^1.0.1: version "1.0.1" ...
version "1.0.0" resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" dependencies: map-visit "^1.0.0" object-visit "^1.0.0" color-convert@^1.9.0, color-convert@^1.9.1: ...
(用来初始化 vagrant,配置 homestead box 的程序。) a. git clone https://github.com/laravel/homestead.git ~/Homestead b. cd ~/Homestead c. git checkout v7.1.2(切换到稳定版本) d. bash init.sh或者init.bat(生成 Homestead.yaml 文件)配置(配置文件 Homestead.yaml)指定虚拟机...
()->buildClaimsCollection()->toPlainArray()['sub']); //刷新了token,将token存入数据库(防止刚刷新用户在别的地方登录没有拉黑此token) $user = Auth::user(); $user->last_token = $token; $user->save(); } catch (JWTException $exception) { // 异常为token被拉入黑名单 if ($exception ...
如果当前环境与给定值匹配,该方法返回 true: if (App::environment(local)) { // The environment is local } if (App::environment(local, staging)) { // The environment is either local OR staging... } 应用实例也可以通过辅助函数 app 来 : $environment = app()-environment(); 4 、配置缓存 ...
If you need help getting started, check out Laracasts and our great documentation. Tailored for your team: Whether you're a solo developer or a 20 person team, Laravel is a breath of fresh air. Keep everyone in sync using Laravel's database agnostic migrations and schema builder. Modern ...