46 lines
864 B
PHP
46 lines
864 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
|
||
|
|
class JobLocation extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [
|
||
|
|
'city',
|
||
|
|
'state',
|
||
|
|
'country',
|
||
|
|
'country_code',
|
||
|
|
'latitude',
|
||
|
|
'longitude',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'latitude' => 'decimal:7',
|
||
|
|
'longitude' => 'decimal:7',
|
||
|
|
];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the jobs for this location.
|
||
|
|
*/
|
||
|
|
public function jobs(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(Job::class, 'job_location_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the full location string.
|
||
|
|
*/
|
||
|
|
public function getFullLocationAttribute(): string
|
||
|
|
{
|
||
|
|
$parts = array_filter([
|
||
|
|
$this->city,
|
||
|
|
$this->state,
|
||
|
|
$this->country,
|
||
|
|
]);
|
||
|
|
|
||
|
|
return implode(', ', $parts);
|
||
|
|
}
|
||
|
|
}
|