|
@@ -0,0 +1,93 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+function dDate($date=NULL, $format='d M Y', $default='N/A'){
|
|
|
+
|
|
|
+ if(empty($format)) $format='d M Y';
|
|
|
+
|
|
|
+ if(empty($date)) return $default;
|
|
|
+ return date($format, strtotime($date));
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function cn($object, $string, $if_false="N/A"){
|
|
|
+
|
|
|
+ $properties=explode('.', $string);
|
|
|
+
|
|
|
+ foreach($properties as $property){
|
|
|
+
|
|
|
+ if(empty($object->$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();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+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')).'00'.$currentId.'R';
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+if(!function_exists('name_initials')){
|
|
|
+ function name_initials($firstName,$lastName){
|
|
|
+ return strtoupper(mb_substr($firstName, 0, 1) . mb_substr($lastName, 0, 1));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|