phase 1 and 2
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user