Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class shGroupReference extends Model {
- protected $table = 'shGroupReference';
- protected $primaryKey = 'groupID';
- public $timestamps = false;
- protected $fillable = ['referenceCode', 'referenceID', 'groupID'];
- public function shGroup() {
- return $this->belongsTo(\App\Models\shGroup::class, 'groupID', 'groupID');
- }
- .....
- class shGroup extends Model {
- protected $table = 'shGroup';
- protected $primaryKey = 'groupID';
- public $timestamps = false;
- protected $fillable = ['groupID', 'orgID', 'name', 'categoryCode'];
- public function shGroupReference() {
- return $this->hasOne(\App\Models\shGroupReference::class, 'groupID', 'groupID');
- }
- .....
- $shGroupReference = App\Models\shGroupReference::create(['referenceCode' => 'caughtya', 'referenceID' => 1005]);
- $shGroup = App\Models\shGroup::create(['orgID' => 1, 'name' => 'blabla', 'categoryCode' => 'blublu']);
- $shGroupReference->shGroup()->associate($shGroup)->save();
- var_dump(shGroupReference->toArray());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement