Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserModel extends Model
- {
- protected $table = 'users';
- protected $fillable = [
- 'username',
- 'email',
- 'phone',
- 'password',
- 'verified'
- ];
- /**
- * The attributes excluded from the model's JSON form.
- *
- * @var array
- */
- protected $hidden = [
- 'password'
- ];
- /**
- * The attributes that should be visible in arrays.
- *
- * @var array
- */
- protected $visible = [
- 'id',
- 'username',
- 'email',
- 'phone',
- 'verified'
- ];
- /**
- *
- */
- public function interest()
- {
- return $this->belongsToMany('App\Model\InterestModel', 'users_interest', 'user_id', 'interest_id');
- }
- }
- class InterestModel extends Model
- {
- protected $table = 'interest';
- protected $fillable = [
- 'name',
- ];
- /**
- *
- */
- public function user()
- {
- return $this->belongsToMany('App\Model\UserModel','users_interest','interest_id','user_id');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement