| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- class Member extends Model
- {
- use HasFactory;
- protected $fillable = [
- 'first_name',
- 'last_name',
- 'status',
- 'birth_city_id',
- 'birth_province_id',
- 'birth_nation_id',
- 'birth_date',
- 'gender',
- 'address',
- 'zip_code',
- 'fiscal_code',
- 'nation_id',
- 'province_id',
- 'city_id',
- 'phone',
- 'email',
- 'enabled',
- ];
- public function nation()
- {
- return $this->belongsTo(Nation::class);
- }
- public function province()
- {
- return $this->belongsTo(Province::class);
- }
- public function city()
- {
- return $this->belongsTo(City::class);
- }
- public function birth_nation()
- {
- return $this->belongsTo(Nation::class);
- }
- public function birth_province()
- {
- return $this->belongsTo(Province::class);
- }
- public function birth_city()
- {
- return $this->belongsTo(City::class);
- }
- public function isActive()
- {
- $ret = array('status' => false, 'date' => '');
- $cards = \App\Models\MemberCard::where('member_id', $this->id)->with('card')->orderBy('expire_date')->get();
- foreach($cards as $card)
- {
- if ($card->card->use_for_user_check)
- {
- $ret = array('status' => $card->expire_date > date("Y-m-d"), 'date' => $card->expire_date);
- }
- }
- return $ret;
- }
- }
|