File: /mnt/data/ghayatcom/ghayatcom-api/app/InsuranceDetail.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\InsuranceDetail
*
* @property mixed $policy_number
* @property mixed $company_name
* @property mixed $insurance_type
* @property mixed $first_name
* @property mixed $last_name
* @property mixed $passport_number
* @property mixed $country_code
* @property mixed $mobile_number
* @property mixed $email
* @property mixed $post_code
* @property mixed $address
* @property mixed $beneficiary_name
* @property mixed $iban
* @property mixed $bic
*/
class InsuranceDetail extends Model
{
use SoftDeletes;
protected $fillable = ['id', 'user_id', 'insurance_company_id', 'policy_number', 'company_name', 'cover_from', 'cover_to', 'insurance_type', 'first_name', 'last_name', 'passport_number', 'dob', 'country_code', 'mobile_number', 'email', 'country_id', 'post_code', 'address', 'beneficiary_name', 'iban', 'bic', 'created_by', 'updated_by', 'deleted_by'];
protected $hidden = ['created_by', 'updated_by', 'deleted_by', 'deleted_at', 'updated_at'];
protected $appends = ['insurance_company'];
public function insuranceGet():HasOne
{
return $this->hasOne(InsuranceCompany::class, 'id', 'insurance_company_id');
}
public function getInsuranceCompanyAttribute()
{
return $this->insuranceGet->name;
}
public function getCountryIdAttribute($value)
{
return Country::select('id', 'name', 'iso2', 'currency')->where('id', $value)->first();
}
}