$property)) return $if_false; else{ $object=$object->$property; } } if(empty($object)) return $if_false; return $object; } function no_img($url='assets/img/placeholder.png'){ return asset($url); } function model($name){ return "\\App\\Models\\{$name}"; } function default_avatar($path="assets/img/avatar-2-64.png"){ return asset($path); } function nf($value, $decimal=2){ if(empty($value)) $value=0.00; return number_format($value, $decimal); } function die_log($value){ die(\Log::info($value)); } function fDate($date, $format='d-m-Y'){ if(empty($date)) return ''; return \Carbon\Carbon::parse($date)->format($format); } // function auth_user(){ // return \Auth::user(); // } function auth_user($guard='teacher'){ return \Auth::guard($guard)->user(); } if(!function_exists('teacherRefNoGenerate')){ function teacherRefNoGenerate(){ $currentId = \DB::table('users')->where('user_type',2)->count(); do{ ++$currentId; $currentIdExist =\DB::table('users')->where('user_type',2)->where('id',$currentId)->exists(); }while($currentIdExist); return date('y').intval(date('m')).str_pad($currentId, 3, "0", STR_PAD_LEFT).'R'; } } if(!function_exists('studentRefNoGenerate')){ function studentRefNoGenerate(){ $currentId = \DB::table('student_proposals')->count(); do{ ++$currentId; $currentIdExist =\DB::table('student_proposals')->where('id',$currentId)->exists(); }while($currentIdExist); return date('y').intval(date('m')).str_pad($currentId, 2, "0", STR_PAD_LEFT); } } if(!function_exists('proposalRefNoGenerate')){ function proposalRefNoGenerate(){ $currentId = \DB::table('proposal')->count(); do{ ++$currentId; $currentIdExist =\DB::table('proposal')->where('id',$currentId)->exists(); }while($currentIdExist); return str_pad($currentId, 3, "10", STR_PAD_LEFT); } } if(!function_exists('name_initials')){ function name_initials($firstName,$lastName){ return strtoupper(mb_substr($firstName, 0, 1) . mb_substr($lastName, 0, 1)); } } if(!function_exists('student_proposal')){ function student_proposal($std_id,$pro_id){ $apply_checked = \App\StudentProposal::where('student_id',$std_id)->where('proposal_id',$pro_id)->exists(); if($apply_checked){ return FALSE; } return TRUE; } } if(!function_exists('profile_permission')){ function profile_permission($std_id){ $apply_checked = \App\StudentProposal::where('student_id',$std_id)->exists(); if($apply_checked){ return FALSE; } return TRUE; } }