App下載

詞條

大約有 7,000 項(xiàng)符合查詢結(jié)果 ,庫內(nèi)數(shù)據(jù)總量為 78,250 項(xiàng)。(搜索耗時(shí):0.0048秒)

5431.Laravel 8 應(yīng)用全局作用域

...需要重寫模型的 booted 方法并使用 addGlobalScope 方法:<?php namespace App\Models; use App\Scopes\AgeScope; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 模型的 "booted" 方法 * * @return void */ protected static function booted() { static::addGlobalSc...

http://www.o2fo.com/laravel_8/laravel_8-9ar63i4k.html

5432.Laravel 8 匿名全局作用域

...就不需要為一個(gè)簡單的作用域而編寫一個(gè)單獨(dú)的類:<?php namespace App\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 模型的 "booted" 方法 * * @return void */ protected static function booted() { st...

http://www.o2fo.com/laravel_8/laravel_8-wcnr3i4l.html

5433.Laravel 8 編寫全局作用域

...據(jù)你的需求,在 apply 方法中加入查詢的 where 條件:<?php namespace App\Scopes; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Scope; class AgeScope implements Scope { /** * 把約束加到 Eloquent 查詢構(gòu)造...

http://www.o2fo.com/laravel_8/laravel_8-a8tp3i4o.html

5434.Laravel 8 動態(tài)作用域

...以達(dá)到此目的。作用域參數(shù)要放在 $query 參數(shù)之后:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** *將查詢作用域限制為僅包含給定類型的用戶 * * @param \Illuminate\Database\Eloquent\Builder $query * @param mix...

http://www.o2fo.com/laravel_8/laravel_8-lryw3i4p.html

5435.Laravel 8 事件

...nt 模型生命周期的幾個(gè)節(jié)點(diǎn)映射到你自己的 event 類:<?php namespace App\Models; use App\Events\UserDeleted; use App\Events\UserSaved; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * 模型的事件映射 * * @var...

http://www.o2fo.com/laravel_8/laravel_8-qzdu3i4q.html

5436.Laravel 8 使用閉包

... 通常,你應(yīng)該在模型的 booted 方法中注冊這些閉包:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 模型的 "booted" 方法 * * @return void */ protected static function booted() { static::created(function ($user) { // }); } ...

http://www.o2fo.com/laravel_8/laravel_8-89nh3i4r.html

5437.Laravel 8 局部作用域

...加 scope 前綴。作用域總是返回一個(gè)查詢構(gòu)造器實(shí)例:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** *只查詢受歡迎的用戶的作用域 * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Databas...

http://www.o2fo.com/laravel_8/laravel_8-zyva3i4y.html

5438.Laravel 8 一對一

...法。 在 phone 方法內(nèi)部調(diào)用 hasOne 方法并返回其結(jié)果:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 獲取與用戶相關(guān)的電話記錄 */ public function phone() { return $this->hasOne('App\Models\Phone'); } } ha...

http://www.o2fo.com/laravel_8/laravel_8-8k643i51.html

5439.Laravel 8 定義反向關(guān)聯(lián)

...用與 hasOne 方法對應(yīng)的 belongsTo 方法來定義反向關(guān)聯(lián):<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Phone extends Model { /** * 獲取擁有此電話的用戶 */ public function user() { return $this->belongsTo('App\Models\User'); } } 在上...

http://www.o2fo.com/laravel_8/laravel_8-jpu23i53.html

5440.Laravel 8 一對多

...一對多關(guān)聯(lián)的定義也是在 Eloquent 模型中寫一個(gè)方法:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Post extends Model { /** * 獲取博客文章的評論 */ public function comments() { return $this->hasMany('App\Models\Comment'); } } 記住...

http://www.o2fo.com/laravel_8/laravel_8-y1zx3i55.html

抱歉,暫時(shí)沒有相關(guān)的微課

w3cschool 建議您:

  • 檢查輸入的文字是否有誤

抱歉,暫時(shí)沒有相關(guān)的視頻課程

w3cschool 建議您:

  • 檢查輸入的文字是否有誤

抱歉,暫時(shí)沒有相關(guān)的教程

w3cschool 建議您:

  • 檢查輸入的文字是否有誤

5431.Laravel 8 應(yīng)用全局作用域

...需要重寫模型的 booted 方法并使用 addGlobalScope 方法:<?php namespace App\Models; use App\Scopes\AgeScope; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 模型的 "booted" 方法 * * @return void */ protected static function booted() { static::addGlobalSc...

http://www.o2fo.com/laravel_8/laravel_8-9ar63i4k.html

5432.Laravel 8 匿名全局作用域

...就不需要為一個(gè)簡單的作用域而編寫一個(gè)單獨(dú)的類:<?php namespace App\Models; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 模型的 "booted" 方法 * * @return void */ protected static function booted() { st...

http://www.o2fo.com/laravel_8/laravel_8-wcnr3i4l.html

5433.Laravel 8 編寫全局作用域

...據(jù)你的需求,在 apply 方法中加入查詢的 where 條件:<?php namespace App\Scopes; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Scope; class AgeScope implements Scope { /** * 把約束加到 Eloquent 查詢構(gòu)造...

http://www.o2fo.com/laravel_8/laravel_8-a8tp3i4o.html

5434.Laravel 8 動態(tài)作用域

...以達(dá)到此目的。作用域參數(shù)要放在 $query 參數(shù)之后:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** *將查詢作用域限制為僅包含給定類型的用戶 * * @param \Illuminate\Database\Eloquent\Builder $query * @param mix...

http://www.o2fo.com/laravel_8/laravel_8-lryw3i4p.html

5435.Laravel 8 事件

...nt 模型生命周期的幾個(gè)節(jié)點(diǎn)映射到你自己的 event 類:<?php namespace App\Models; use App\Events\UserDeleted; use App\Events\UserSaved; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * 模型的事件映射 * * @var...

http://www.o2fo.com/laravel_8/laravel_8-qzdu3i4q.html

5436.Laravel 8 使用閉包

... 通常,你應(yīng)該在模型的 booted 方法中注冊這些閉包:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 模型的 "booted" 方法 * * @return void */ protected static function booted() { static::created(function ($user) { // }); } ...

http://www.o2fo.com/laravel_8/laravel_8-89nh3i4r.html

5437.Laravel 8 局部作用域

...加 scope 前綴。作用域總是返回一個(gè)查詢構(gòu)造器實(shí)例:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** *只查詢受歡迎的用戶的作用域 * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Databas...

http://www.o2fo.com/laravel_8/laravel_8-zyva3i4y.html

5438.Laravel 8 一對一

...法。 在 phone 方法內(nèi)部調(diào)用 hasOne 方法并返回其結(jié)果:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 獲取與用戶相關(guān)的電話記錄 */ public function phone() { return $this->hasOne('App\Models\Phone'); } } ha...

http://www.o2fo.com/laravel_8/laravel_8-8k643i51.html

5439.Laravel 8 定義反向關(guān)聯(lián)

...用與 hasOne 方法對應(yīng)的 belongsTo 方法來定義反向關(guān)聯(lián):<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Phone extends Model { /** * 獲取擁有此電話的用戶 */ public function user() { return $this->belongsTo('App\Models\User'); } } 在上...

http://www.o2fo.com/laravel_8/laravel_8-jpu23i53.html

5440.Laravel 8 一對多

...一對多關(guān)聯(lián)的定義也是在 Eloquent 模型中寫一個(gè)方法:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Post extends Model { /** * 獲取博客文章的評論 */ public function comments() { return $this->hasMany('App\Models\Comment'); } } 記住...

http://www.o2fo.com/laravel_8/laravel_8-y1zx3i55.html

抱歉,暫時(shí)沒有相關(guān)的文章

w3cschool 建議您:

  • 檢查輸入的文字是否有誤

熱門課程