mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-13 03:31:31 +00:00
updated streamline-setup v2
This commit is contained in:
Executable
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Streamline\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use OwenIt\Auditing\Contracts\Auditable;
|
||||
use Streamline\Models\Subcounty;
|
||||
use Streamline\Models\County;
|
||||
use Streamline\Models\District;
|
||||
|
||||
class Parish 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 getNameWithSubcountyAttribute($value)
|
||||
{
|
||||
$subcounty_details = Subcounty::find($this->subcounty_id);
|
||||
if (is_null($subcounty_details)) {
|
||||
return ucfirst($this->name) . ' '.'(Subcounty: N/A, County: N/A, District: N/A)';
|
||||
}
|
||||
|
||||
$county_details = County::find($subcounty_details->county_id);
|
||||
if (is_null($county_details)) {
|
||||
return ucfirst($this->name) . ' '.'(Subcounty:'.ucfirst($subcounty_details->name).', County: N/A, District: N/A)';
|
||||
}
|
||||
|
||||
$district_details = District::find($county_details->district_id);
|
||||
if (is_null($district_details)) {
|
||||
return ucfirst($this->name) . ' '.'(Subcounty:'.ucfirst($subcounty_details->name).', County:'. ucfirst($county_details->name).', District: N/A)';
|
||||
}
|
||||
|
||||
return ucfirst($this->name) . ' '.'(Subcounty:'.ucfirst($subcounty_details->name).', County:'. ucfirst($county_details->name).', District:'.ucfirst($district_details->name).')';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user