2018-04-18 02:17:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Profile extends Model
|
|
|
|
{
|
2018-04-19 05:57:16 +00:00
|
|
|
public function url()
|
|
|
|
{
|
|
|
|
return url('/' . $this->username);
|
|
|
|
}
|
|
|
|
|
2018-04-18 02:17:42 +00:00
|
|
|
public function statuses()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Status::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function following()
|
|
|
|
{
|
|
|
|
return $this->hasManyThrough(
|
|
|
|
Profile::class,
|
|
|
|
Follower::class,
|
|
|
|
'profile_id',
|
|
|
|
'id',
|
|
|
|
'id',
|
|
|
|
'id'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function followers()
|
|
|
|
{
|
|
|
|
return $this->hasManyThrough(
|
|
|
|
Profile::class,
|
|
|
|
Follower::class,
|
|
|
|
'following_id',
|
|
|
|
'id',
|
|
|
|
'id',
|
|
|
|
'id'
|
|
|
|
);
|
|
|
|
}
|
2018-04-19 05:57:16 +00:00
|
|
|
|
|
|
|
public function likes()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Like::class);
|
|
|
|
}
|
2018-04-18 02:17:42 +00:00
|
|
|
}
|