namespace App\Http\Controllers; class TestController extends Controller { public function push() { $fd = 1; // Find fd by userId from a map [userId=>fd]. /**@var \Swoole\WebSocket\Server $swoole */ $swoole = app('swoole'); $success = $swoole->push($fd, 'Push data to fd#1 ...
You may also specify additional query constraints by customizing the query using the where method. For example, let's add a constraint that verifies the account_id is 1:1'email' => Rule::unique('users')->where(function ($query) { 2 $query->where('account_id', 1); 3})...
The loginAs method accepts a user ID or user model instance:1$this->browse(function ($first, $second) { 2 $first->loginAs(User::find(1)) 3 ->visit('/home'); 4});After using the loginAs method, the user session will be maintained for all tests within the file....
php// Get the article$article=App\Article::find($id);// Get the state machine for this article, and graph called "simple"// Using the facade$stateMachine= StateMachine::get($article,'simple');// Or using the service container with dependency injectionpublicfunctionmethod(SM\Factory\Factory...
分支(1) 提交 管理 管理 master 91699d6 该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。 项目仓库所选许可证以仓库主分支所使用许可证为准 克隆/下载 HTTPSSSHSVNSVN+SSH 该操作需登录 Gitee 帐号,请先登录后再操作。
$users = User::all(['id', 'name', 'email']); 11: Blade 中的 @auth 你可以使用 @auth 指令来代替 if 语句来检查用户是否经过身份验证。 典型的方法: @if(auth->user) // The user is authenticated. @endif @auth // The user is authenticated. ...
slug // 'aut-repellat-commodi-vel-itaque-nihil-id-saepe-nostrum' ipv4 // '109.133.32.252' localIpv4 // '10.242.58.8' ipv6 // '8e65:933d:22ee:a232:f1c1:2741:1f10:117c' macAddress // '43:85:B7:08:10:CA' Faker\Provider\UserAgent ...
->orderBy('id', 'desc') ->offset(10) ->limit(5) ->get(); # 排序分页 $user = User::where('name', '空空')->first(); # 获取单条记录 $user = User::find(1); # 简化↑ # 聚合结果 $num = User::whereNotNull('email_verified_at')->count(); # 计数 ...
Product::find($produce_id)->decrement('stock'); // -1 2. 先执行 X 方法,X 方法执行不成功则执行 Y 方法 Eloquent 有相当一部分函数可以把两个方法结合在一起使用, 例如 『 请先执行 X 方法, X 方法执行不成功则执行 Y 方法 』。 实例1 -- findOrFail: ...
->orderBy('id','desc') ->limit(10) ->offset(0) ->get() ->toArray(); dd($list); }); Route::get('db/test/info',function(){ $id = (int)request()->get('id',0); $info = \Illuminate\Support\Facades\DB::table('db_test')->find($id); ...