Level 75
User model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* The roles that belong to the user.
*/
public function profile()
{
return $this->hasOne('App\Profile');
}
public function sponsorapps()
{
return $this->hasMany('App\Sponsorapp');
}
}
Profile model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Profile extends Model
{
protected $table = 'profile';
/**
* Get the post that owns the comment.
*/
public function user()
{
return $this->belongsTo('App\User');
}
}
Sponsorapp model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Sponsorapp extends Model
{
protected $table = 'sponsorapp';
/**
* Get the post that owns the comment.
*/
public function user()
{
return $this->belongsTo('App\User');
}
}
https://laravel.com/docs/7.x/eloquent-relationships#one-to-one
https://laravel.com/docs/7.x/eloquent-relationships#one-to-many