1 回答

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊
如果您不希望某些內(nèi)容出現(xiàn)在模型的默認(rèn)選擇列表中,請(qǐng)將該屬性添加到$hidden該模型的數(shù)組中,
public class MySecondTable {
? ? // An array of properties that should not appear?
? ? // in the default select-list or JSON output
? ? protected $hidden = ['MyAwesomeTable_ID'];?
? ? public function awesomeTable() {
? ? ? ? // You can just define relation like this, the if you follow Laravel naming-conventions
? ? ? ? return $this->hasOne(MyAwesomeTable::class);?
? ? ? ? // return $this->hasOne('App\Models\MyAwesomeTable', 'id', 'MyAwesomeTable_ID');
? ? }
}
- 1 回答
- 0 關(guān)注
- 149 瀏覽
添加回答
舉報(bào)