IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Traits;
use Carbon\Carbon;
class AdmEntry extends Model {
use Traits\AutoUpdateUserColumns;
protected $primaryKey = 'idStudent';
protected $table = 'students';
protected $fillable = ['isActive','remarks','deactivationDate','admissionNo', 'ecNo', 'firstName', 'middleName', 'lastName', 'gender', 'idClass', 'idSection',
'idFinancialYear', 'idClass', 'idSection', 'photo', 'studentDob', 'studentPob', 'gender', 'aadhaarNo', 'religion', 'studentType',
'studentUID', 'motherTounge', 'grNo', 'saralNo', 'bloodGroup', 'resAddress', 'resCity', 'resPincode', 'landmark', 'resState',
'resTelephone', 'resTelephone', 'lastSchool', 'board', 'percentage', 'lastSchoolAddress', 'lastSchoolCity', 'lastSchoolPhone',
'lastSchoolPincode', 'lastSchoolState', 'reasonForChange', 'contactPerson', 'contactPersonAddress', 'contactPersonRelation', 'contactPersonTel',
'contactPersonMobile', 'food', 'transport', 'learningDisability', 'otherRequirement',
'ralationship_one', 'father_fname', 'father_lname', 'father_dob', 'father_qualification'
, 'father_occupation', 'father_designation', 'father_company', 'father_workloc', 'father_panno', 'father_telephone',
'father_mobile', 'father_aadhaar', 'father_email', 'relationship_two', 'mother_fname', 'mother_lname', 'mother_dob',
'mother_qualification', 'mother_occupation', 'mother_designation', 'mother_company', 'mother_workloc', 'mother_panno','registrationNo',
'mother_telephone', 'mother_mobile', 'mother_aadhaar', 'mother_email','dateOfBan','qid_expiry','qid_expiry_father','remarks_disabilty','passport_expiry_father','qid_expiry_mother','passport_expiry_mother'];
public function setStudentDobAttribute($date) {
if (strlen($date) > 0)
$this->attributes['studentDob'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['studentDob'] = null;
}
public function getStudentDobAttribute($date) {
// dd($date);
try{
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
}catch(\Exception $e){
}
return '';
}
public function setFatherDobAttribute($date) {
if (strlen($date) > 0)
$this->attributes['father_dob'] = Carbon::createFromFormat('d-m-Y', $date)->format('Y-m-d');
else
$this->attributes['father_dob'] = null;
}
public function getFatherDobAttribute($date) {
// dd($date);
try{
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
}catch(\Exception $e){
}
return '';
}
public function setMotherDobAttribute($date) {
if (strlen($date) > 0)
$this->attributes['mother_dob'] = Carbon::createFromFormat('d-m-Y', $date)->format('Y-m-d');
else
$this->attributes['mother_dob'] = null;
}
public function getMotherDobAttribute($date) {
// dd($date);
try{
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
}catch(\Exception $e){
}
return '';
}
public function setDateOfBanAttribute($date) {
if (strlen($date) > 0)
$this->attributes['dateOfBan'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['dateOfBan'] = null;
}
public function getDateOfBanAttribute($date) {
// dd($date);
try{
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
}catch(\Exception $e){
}
return '';
}
public function setDeactivationDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['deactivationDate'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['deactivationDate'] = null;
}
public function getDeactivationDateAttribute($date) {
// dd($date);
try{
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
}catch(\Exception $e){
}
return '';
}
public function classM() {
return $this->belongsTo(ClassM::class, 'idClass', 'idClass');
}
// public function parents() {
// return $this->hasOne(StudentParent::class, 'idStudent', 'idStudent');
// }
public function siblings() {
return $this->hasMany(StudentSibling::class, 'idStudent', 'idStudent');
}
public function section() {
return $this->belongsTo(Section::class, 'idSection', 'idSection');
}
public function state() {
return $this->belongsTo(State::class, 'resState', 'idState');
}
public function stateQatar() {
return $this->belongsTo(StateQatar::class, 'resState', 'idState');
}
public function lastschoolstate(){
return $this->belongsTo(State::class, 'lastSchoolState', 'idState');
}
public function qatarlastschoolstate(){
return $this->belongsTo(StateQatar::class, 'lastSchoolState', 'idState');
}
public function lastschool_state() {
return $this->belongsTo(State::class, 'lastSchoolState', 'idState');
}
public function qatarlastschool_state() {
return $this->belongsTo(StateQatar::class, 'lastSchoolState', 'idState');
}
public function getNameAttribute() {
return $this->firstName . ' ' . $this->lastName . '(' . $this->ecNo . ')';
}
public function attandance() {
return $this->hasMany(Attendance::class, 'Enrollment_Number', 'ecNo');
}
}
Copyright © 2021 -