<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ## Auth ### 用戶認證 ``` // 獲取 Auth 對象,等同于 Auth Facade auth(); // 判斷當前用戶是否已認證(是否已登錄) Auth::check(); // 判斷當前用戶是否未登錄,與 check() 相反 Auth::guest(); // 自定義看守器 默認為 `web` Auth::guard(); // 獲取當前的認證用戶 Auth::user(); // 獲取當前的認證用戶的 ID(未登錄情況下會報錯) Auth::id(); // 通過給定的信息來嘗試對用戶進行認證(成功后會自動啟動會話) Auth::attempt(['email' => $email, 'password' => $password]); // 通過 Auth::attempt() 傳入 true 值來開啟 '記住我' 功能 Auth::attempt($credentials, true); // 注冊嘗試登錄的事件監聽器 Auth::attempting($callback); // 只針對一次的請求來認證用戶 Auth::once($credentials); // 使用 ID 登錄,無 Cookie 和會話登錄 Auth::onceUsingId($id); // 登錄一個指定用戶到應用上 Auth::login(User::find(1), $remember = false); // 檢測是否記住了登錄 Auth::viaRemember(); // 登錄指定用戶 ID 的用戶到應用上 Auth::loginUsingId(1, $remember = false); // 使用戶退出登錄(清除會話) Auth::logout(); // 清除當前用戶的其他會話 Auth::logoutOtherDevices('password', $attribute = 'password'); // 驗證用戶憑證 Auth::validate($credentials); // 使用 HTTP 的基本認證方式來認證 Auth::basic('username'); // 執行「HTTP Basic」登錄嘗試,只認證一次 Auth::onceBasic(); // 發送密碼重置提示給用戶 Password::remind($credentials, function($message, $user){}); ``` ### 用戶授權 ``` // 定義權限 Gate::define('update-post', 'Class@method'); Gate::define('update-post', function ($user, $post) {...}); // 傳遞多個參數 Gate::define('delete-comment', function ($user, $post, $comment) {}); // 一次性的定義多個 Gate 方法 Gate::resource('posts', 'App\Policies\PostPolicy'); // 檢測權限是否被定義 Gate::has('update-post'); // 檢查權限 Gate::denies('update-post', $post); Gate::allows('update-post', $post); Gate::check('update-post', $post); // 指定用戶進行檢查 Gate::forUser($user)->allows('update-post', $post); // 在 User 模型下,使用 Authorizable trait User::find(1)->can('update-post', $post); User::find(1)->cannot('update-post', $post); User::find(1)->cant('update-post', $post); // 攔截所有檢查,返回 bool Gate::before(function ($user, $ability) {}); // 設置每一次驗證的回調 Gate::after(function ($user, $ability, $result, $arguments) {}); // Blade 模板語法 @can('update-post', $post) @endcan // 支持 else 表達式 @can('update-post', $post) @else @endcan // 無權限判斷 @cannot @endcannot // 生成一個新的策略 php artisan make:policy PostPolicy php artisan make:policy PostPolicy --model=Post // `policy` 幫助函數 policy($post)->update($user, $post) // 控制器授權 $this->authorize('update', $post); // 指定用戶 $user 授權 $this->authorizeForUser($user, 'update', $post); // 控制器的 __construct 中授權資源控制器 $this->authorizeResource(Post::class, 'post'); // AuthServiceProvider->boot() 里修改策略自動發現的邏輯 Gate::guessPolicyNamesUsing(function ($modelClass) { // 返回模型對應的策略名稱,如:// 'App\Model\User' => 'App\Policies\UserPolicy', return 'App\Policies\\'.class_basename($modelClass).'Policy'; }); // 中間件指定模型實例 Route::put('/post/{post}', function (Post $post) { ... })->middleware('can:update,post'); // 中間件未指定模型實例 Route::post('/post', function () { ... })->middleware('can:create,App\Post'); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看