App下載

詞條

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

5441.Laravel 8 模型結(jié)構(gòu)

...果來定義,例如,我們在 User 模型中定義 roles 方法:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 用戶擁有的角色 */ public function roles() { return $this->belongsToMany('App\Models\Role'); } } 一旦關(guān)聯(lián)...

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

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

... belongsToMany 方法。我們在 Role 模型中定義 users 方法:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Role extends Model { /** * 擁有此角色的用戶 */ public function users() { return $this->belongsToMany('App\Models\User'); } } 如你所...

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

5443.Laravel 8 模型結(jié)構(gòu)

接下來,再看看建立關(guān)聯(lián)的模型定義:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Image extends Model { /** * 獲取擁有此圖片的模型 */ public function imageable() { return $this->morphTo(); } } class Post extends Model { /** * 獲取文章圖...

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

5444.Laravel 8 模型結(jié)構(gòu)

接下來,看看構(gòu)建這種關(guān)聯(lián)的模型定義:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Comment extends Model { /** * 獲取擁有此評論的模型 */ public function commentable() { return $this->morphTo(); } } class Post extends Model { /** * 獲取...

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

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

...這個示例中,我們將會定義 posts 方法和 videos 方法:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Tag extends Model { /** * 獲取被打上此標(biāo)簽的所有文章 */ public function posts() { return $this->morphedByMany('App\Models\Post', &...

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

5446.Laravel 8 查詢關(guān)聯(lián)

...設(shè)一個博客系統(tǒng)的 User 模型有許多關(guān)聯(lián)的 Post 模型:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 獲取該用戶的所有文章 */ public function posts() { return $this->hasMany('App\Models\Post'); } } 你可以...

http://www.o2fo.com/laravel_8/laravel_8-5ok83i6p.html

5447.Laravel 8 嵌套預(yù)加載 morphTo 關(guān)聯(lián)

...用。 為了幫助說明這種方法,讓我們參考以下模型:<?php use Illuminate\Database\Eloquent\Model; class ActivityFeed extends Model { /** * 獲取活動提要記錄的父級 */ public function parentable() { return $this->morphTo(); } } 在這個例子中,我們假設(shè) Event...

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

5448.Laravel 8 默認(rèn)預(yù)加載

...某些關(guān)聯(lián)。 為此,你可以在模型上定義 $with 屬性:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Book extends Model { /** * 默認(rèn)加載的關(guān)聯(lián) * * @var array */ protected $with = ['author']; /** * 獲取書籍作者 */ public function author...

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

5449.Laravel 8 嵌套延遲預(yù)加載 & morphTo

...。為了幫助說明這個方法,可以看一下以下模型例子:<?php use Illuminate\Database\Eloquent\Model; class ActivityFeed extends Model { /** * 獲取 activity feed 記錄的父級 */ public function parentable() { return $this->morphTo(); } }Copy 在這個例子中,讓我們假...

http://www.o2fo.com/laravel_8/laravel_8-3vea3i73.html

5450.Laravel 8 新增方法

...受一個完整的 Eloquent 模型實(shí)例,而 create 則接受普通的 PHP 數(shù)組:$post = App\Models\Post::find(1); $comment = $post->comments()->create([ 'message' => 'A new comment.', ]); 技巧:在使用 create 方法前,請務(wù)必確保查看過本文檔的 批...

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

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

w3cschool 建議您:

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

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

w3cschool 建議您:

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

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

w3cschool 建議您:

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

5441.Laravel 8 模型結(jié)構(gòu)

...果來定義,例如,我們在 User 模型中定義 roles 方法:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 用戶擁有的角色 */ public function roles() { return $this->belongsToMany('App\Models\Role'); } } 一旦關(guān)聯(lián)...

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

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

... belongsToMany 方法。我們在 Role 模型中定義 users 方法:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Role extends Model { /** * 擁有此角色的用戶 */ public function users() { return $this->belongsToMany('App\Models\User'); } } 如你所...

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

5443.Laravel 8 模型結(jié)構(gòu)

接下來,再看看建立關(guān)聯(lián)的模型定義:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Image extends Model { /** * 獲取擁有此圖片的模型 */ public function imageable() { return $this->morphTo(); } } class Post extends Model { /** * 獲取文章圖...

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

5444.Laravel 8 模型結(jié)構(gòu)

接下來,看看構(gòu)建這種關(guān)聯(lián)的模型定義:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Comment extends Model { /** * 獲取擁有此評論的模型 */ public function commentable() { return $this->morphTo(); } } class Post extends Model { /** * 獲取...

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

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

...這個示例中,我們將會定義 posts 方法和 videos 方法:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Tag extends Model { /** * 獲取被打上此標(biāo)簽的所有文章 */ public function posts() { return $this->morphedByMany('App\Models\Post', &...

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

5446.Laravel 8 查詢關(guān)聯(lián)

...設(shè)一個博客系統(tǒng)的 User 模型有許多關(guān)聯(lián)的 Post 模型:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class User extends Model { /** * 獲取該用戶的所有文章 */ public function posts() { return $this->hasMany('App\Models\Post'); } } 你可以...

http://www.o2fo.com/laravel_8/laravel_8-5ok83i6p.html

5447.Laravel 8 嵌套預(yù)加載 morphTo 關(guān)聯(lián)

...用。 為了幫助說明這種方法,讓我們參考以下模型:<?php use Illuminate\Database\Eloquent\Model; class ActivityFeed extends Model { /** * 獲取活動提要記錄的父級 */ public function parentable() { return $this->morphTo(); } } 在這個例子中,我們假設(shè) Event...

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

5448.Laravel 8 默認(rèn)預(yù)加載

...某些關(guān)聯(lián)。 為此,你可以在模型上定義 $with 屬性:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Book extends Model { /** * 默認(rèn)加載的關(guān)聯(lián) * * @var array */ protected $with = ['author']; /** * 獲取書籍作者 */ public function author...

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

5449.Laravel 8 嵌套延遲預(yù)加載 & morphTo

...。為了幫助說明這個方法,可以看一下以下模型例子:<?php use Illuminate\Database\Eloquent\Model; class ActivityFeed extends Model { /** * 獲取 activity feed 記錄的父級 */ public function parentable() { return $this->morphTo(); } }Copy 在這個例子中,讓我們假...

http://www.o2fo.com/laravel_8/laravel_8-3vea3i73.html

5450.Laravel 8 新增方法

...受一個完整的 Eloquent 模型實(shí)例,而 create 則接受普通的 PHP 數(shù)組:$post = App\Models\Post::find(1); $comment = $post->comments()->create([ 'message' => 'A new comment.', ]); 技巧:在使用 create 方法前,請務(wù)必確保查看過本文檔的 批...

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

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

w3cschool 建議您:

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

熱門課程