2019-08-08 06:06:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Pixelfed\Snowflake\HasSnowflakePrimary;
|
|
|
|
|
|
|
|
class Place extends Model
|
|
|
|
{
|
2019-08-13 07:47:15 +00:00
|
|
|
protected $visible = ['id', 'name', 'country', 'slug'];
|
2019-08-08 06:06:31 +00:00
|
|
|
|
|
|
|
public function url()
|
|
|
|
{
|
|
|
|
return url('/discover/places/' . $this->id . '/' . $this->slug);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function posts()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Status::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function postCount()
|
|
|
|
{
|
|
|
|
return $this->posts()->count();
|
|
|
|
}
|
2019-08-13 07:47:15 +00:00
|
|
|
|
|
|
|
public function statuses()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Status::class, 'id', 'place_id');
|
|
|
|
}
|
2019-08-30 00:30:26 +00:00
|
|
|
|
|
|
|
public function countryUrl()
|
|
|
|
{
|
|
|
|
$country = strtolower($this->country);
|
|
|
|
$country = urlencode($country);
|
|
|
|
return url('/discover/location/country/' . $country);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function cityUrl()
|
|
|
|
{
|
|
|
|
return $this->url();
|
|
|
|
}
|
2019-08-08 06:06:31 +00:00
|
|
|
}
|