I have two table : users and profile. A user may have one or multiple profile. I want to access the combined data of both table: 'ID' in user table is foreign key in profile table
User model :
class User extends Authenticatable
{
use Notifiable;
protected $fillable = [
'first_name','last_name', 'email', 'password','phone','user_type',
];
protected $hidden = [
'password', 'remember_token',
];
public function profile()
{
return $this->hasMany(profile::class);
}
}
Profile model is :
class profile extends Model
{
protected $fillable =
['id','relationship_status','dob','height','weight','primary_language'];
protected $primaryKey = 'profile_id';
public function User()
{
return $this->belongsTo(User::class,'id','id');
}}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2u85eQ0
via IFTTT
Aucun commentaire:
Enregistrer un commentaire