Files
streamline-emr/docker/_streamline-src/app/Models/County.php
T

30 lines
884 B
PHP
Executable File

<?php
namespace Streamline\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use OwenIt\Auditing\Contracts\Auditable;
use Streamline\Models\District;
class County extends Model implements Auditable {
// use laravel-auditing to track database changes
use \OwenIt\Auditing\Auditable;
// use for soft deletes
use SoftDeletes;
// mutate to dates
protected $dates = ['deleted_at'];
/* added this to allow plucking the name + district at once when making a dropdown */
public function getNameWithDistrictAttribute($value)
{
$district_details = District::find($this->district_id);
if (is_null($district_details)) {
return ucfirst($this->name) . ' '.'(District: N/A)';
}
return ucfirst($this->name) . ' '.'(District:'. ucfirst($district_details->name).')';
}
}