Am I able to create a boolean function that returns me for example true if person is a woman and false if person is a man?
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Patient extends Model
{
public $fillable = ['name', 'surname', 'code'];
public function queque(){
return $this->hasMany(Queque::class);
}
public function gender(){
if([GET CODE FROM THIS SPECIFIC USER][8] % 2 == 0){ //in my country 9th number od code is used to differ between genders
return false; //man
} else{
return true; //woman
}
}
}
I want it to be used in view. So when i use it like {{$patient->gender}} it returns 0 or 1. Is it even possible? I know about query scopes but they are useless in view.
Any help would be greatly appreciated.
@if($patient->gender) man @endif