diff --git a/.env.example b/.env.example index 8579757..b26ba43 100644 --- a/.env.example +++ b/.env.example @@ -60,6 +60,10 @@ MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS="hello@example.com" MAIL_FROM_NAME="${APP_NAME}" + +MEDIA_GALLEY_THUMB=500x500 +MEDIA_POST_THUMB=500x500 + AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php new file mode 100644 index 0000000..398721f --- /dev/null +++ b/app/Helpers/Helper.php @@ -0,0 +1,86 @@ + "🇿🇦", // Afrikaans + "sq" => "🇦🇱", // Albanian + "am" => "🇪🇹", // Amharic + "ar" => "🇸🇦", // Arabic + "hy" => "🇦🇲", // Armenian + "az" => "🇦🇿", // Azerbaijani + "eu" => "🇪🇸", // Basque + "be" => "🇧🇾", // Belarusian + "bn" => "🇧🇩", // Bengali + "bs" => "🇧🇦", // Bosnian + "bg" => "🇧🇬", // Bulgarian + "ca" => "🇪🇸", // Catalan + "zh" => "🇨🇳", // Chinese + "hr" => "🇭🇷", // Croatian + "cs" => "🇨🇿", // Czech + "da" => "🇩🇰", // Danish + "nl" => "🇳🇱", // Dutch + "en" => "🇺🇸", // English + "et" => "🇪🇪", // Estonian + "fi" => "🇫🇮", // Finnish + "fr" => "🇫🇷", // French + "gl" => "🇪🇸", // Galician + "ka" => "🇬🇪", // Georgian + "de" => "🇩🇪", // German + "el" => "🇬🇷", // Greek + "gu" => "🇮🇳", // Gujarati + "ht" => "🇭🇹", // Haitian + "he" => "🇮🇱", // Hebrew + "hi" => "🇮🇳", // Hindi + "hu" => "🇭🇺", // Hungarian + "is" => "🇮🇸", // Icelandic + "id" => "🇮🇩", // Indonesian + "ga" => "🇮🇪", // Irish + "it" => "🇮🇹", // Italian + "ja" => "🇯🇵", // Japanese + "kk" => "🇰🇿", // Kazakh + "ko" => "🇰🇷", // Korean + "lv" => "🇱🇻", // Latvian + "lt" => "🇱🇹", // Lithuanian + "mk" => "🇲🇰", // Macedonian + "ms" => "🇲🇾", // Malay + "ml" => "🇮🇳", // Malayalam + "mt" => "🇲🇹", // Maltese + "mn" => "🇲🇳", // Mongolian + "no" => "🇳🇴", // Norwegian + "ps" => "🇦🇫", // Pashto + "fa" => "🇮🇷", // Persian + "pl" => "🇵🇱", // Polish + "pt" => "🇵🇹", // Portuguese + "ro" => "🇷🇴", // Romanian + "ru" => "🇷🇺", // Russian + "sr" => "🇷🇸", // Serbian + "sk" => "🇸🇰", // Slovak + "sl" => "🇸🇮", // Slovenian + "es" => "🇪🇸", // Spanish + "sw" => "🇰🇪", // Swahili + "sv" => "🇸🇪", // Swedish + "ta" => "🇮🇳", // Tamil + "te" => "🇮🇳", // Telugu + "th" => "🇹🇭", // Thai + "tr" => "🇹🇷", // Turkish + "uk" => "🇺🇦", // Ukrainian + "ur" => "🇵🇰", // Urdu + "uz" => "🇺🇿", // Uzbek + "vi" => "🇻🇳", // Vietnamese + "cy" => "🇬🇧" // Welsh + ); + $lang = strtolower($lang); + if (array_key_exists($lang, $languages)) { + return $languages[$lang]; + } else { + return "❓"; + } +} diff --git a/app/Helpers/TDate.php b/app/Helpers/TDate.php new file mode 100644 index 0000000..6bc5f2e --- /dev/null +++ b/app/Helpers/TDate.php @@ -0,0 +1,1360 @@ + ["am" => "ص", "pm" => "م"]]; + public $A = ["ar" => ["AM" => "صباحاً", "PM" => "مساءً"]]; + protected static $instance; + + ################################################################################ +# general functions # + ################################################################################ + + public static function GetInstance() + { + if (!isset(self::$instance)) { + self::$instance = new self(); + } + + return self::$instance; + } + + + ################################################################################ +# main functions # + ################################################################################ + + /** + * usual gregurian date + * @param string $format + * @param timestamp $time_stamp + * @return string + */ + public function Date($format, $time_stamp = 'now') + { + + + // Pre hook + + $time_stamp = $this->_makeTime($time_stamp); + + $result = date($format, $time_stamp); + + // result hook + + return $result; + } + + /** + * relative date + * @param string $time + * @return string + * @test need to translate + */ + public function RDate($time = 'now') + { + $format = 'd m Y H:i'; + // Pre hook + + $time = $this->_makeTime($time); + + + $delta = time() - $time; + + if ($delta < 1 * MINUTE) { + return $delta == 1 ? __("one second ago") : $delta . __(" seconds ago"); + } + if ($delta < 2 * MINUTE) { + return __("a minute ago"); + } + if ($delta < 45 * MINUTE) { + return floor($delta / MINUTE) . __(" minutes ago"); + } + if ($delta < 90 * MINUTE) { + return __("an hour ago"); + } + if ($delta < 24 * HOUR) { + return floor($delta / HOUR) . __(" hours ago"); + } + if ($delta < 48 * HOUR) { + return __("yesterday"); + } + if ($delta < 30 * DAY) { + return floor($delta / DAY) . __(" days ago"); + } else { + return $this->PDate($format, $time); + } + + // result hook + } + + + /** + * Persian Date + * @param string $format + * @param string $time + * @param string 'ar' number langs + * @return string + */ + public function PDate($format, $time = "now") + { + + + // Pre hook + + $time_stamp = $this->_makeTime($time); + + $date = getdate($time_stamp); + + $j_days_in_month = [31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 365]; + list($date['year'], $date['mon'], $date['mday']) = self::Ge2Parsi($date['year'], $date['mon'], $date['mday']); + + $out = ''; + for ($i = 0; $i < strlen($format); $i++) { + switch ($format[$i]) { + //day + case 'd': + $out .= (strlen($date['mday']) == 1) ? '0' . $date['mday'] : $date['mday']; + + break; + case 'D': + $out .= $this->persian_day_small[(int)$date['wday']]; + + break; + case'l': + $out .= $this->persian_day_names[(int)$date['wday']]; + + break; + case 'j': + $out .= $date['mday']; + + break; + case'N': + $out .= $date['mday'] + 1; + + break; + case'w': + $x = date('w', $time_stamp) + 1; + if ($x == 7) { + $x = 0; + } + $out .= $x; + + break; + case'z': + $mmm = (int)$date['mon']; + if ($mmm < 8) { + $mmm--; + $o = ($mmm * 31) + $date['mday']; + } elseif ($mmm == 12) { + $o = 336 + $date['mday']; + } else { + $mmm -= 6; + $o = ($mmm * 30) + $date['mday'] + 186; + } + $out .= $o; + + break; + //week + case'W': + $yday = $this->j_days_sum_month[(int)($date['mon'] - 1)] + $date['mday']; + $out .= ((int)$yday / 7); + + break; + //month + case'f': + $mon = $date['mon']; + switch ($mon) { + case($mon < 4): + $out .= $this->sesson[0]; + + break; + case($mon < 7): + $out .= $this->sesson[1]; + + break; + case($mon < 10): + $out .= $this->sesson[2]; + + break; + case($mon > 9): + $out .= $this->sesson[3]; + + break; + } + + break; + case'F': + $out .= $this->persian_month_names[((int)$date['mon'])]; + + break; + case'm': + $out .= (strlen($date['mon']) == 1) ? '0' . $date['mon'] : $date['mon']; + + break; + case'M': + $out .= $this->persian_short_month_names[((int)$date['mon'])]; + + break; + case'n': + $out .= $date['mon']; + + break; + case'S': + $out .= 'ام'; + + break; + case't': + $out .= $this->j_days_in_month[((int)$date['mon'])]; + + break; + //year + case'L': + $out .= (($date['year'] % 4) == 0) ? 1 : 0; + + break; + case'o': + case'Y': + $out .= $date['year']; + + break; + case'y': + $out .= substr($date['year'], 2, 2); + + break; + //time + case'a': + $out .= ($date['hours'] < 12) ? 'ق.ظ' : 'ب.ظ'; + + break; + case'A': + $out .= ($date['hours'] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'; + + break; + case'B': + $out .= (int)(1 + ($date['mon'] / 3)); + + break; + case'g': + $out .= ($date['hours'] > 12) ? $date['hours'] - 12 : $date['hours']; + + break; + case'G': + $out .= $date['hours']; + + break; + case'h': + $hour = ($date['hours'] > 12) ? $date['hours'] - 12 : $date['hours']; + $out .= ($hour < 10) ? "0$hour" : $hour; + + break; + case'H': + $out .= (strlen($date['hours']) == 1) ? '0' . $date['hours'] : $date['hours']; + + break; + case'i': + $out .= (strlen($date['minutes']) == 1) ? '0' . $date['minutes'] : $date['minutes']; + + break; + case's': + $out .= (strlen($date['seconds']) == 1) ? '0' . $date['seconds'] : $date['seconds']; + + break; + //full date time + case'c': + $out = $date['year'] . '/' . $date['mon'] . '/' . $date['mday'] . ' ' . $date['hours'] . ':' . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':' . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']); //2004-02-12T15:19:21+00:00 + + break; + case'r': + $out = $this->persian_day_names[(int)$date['wday']] . ',' . $date['mday'] . ' ' . $this->persian_month_names[((int)$date['mon'])] . ' ' . $date['year'] . ' ' . $date['hours'] . ':' . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':' . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']); //Thu, 21 Dec 2000 16:01:07 + + break; + case'U': + $out = $time_stamp; + + break; + //others + case'e': + case'I': + case'O': + case'P': + case'T': + case'Z': + case'u': + break; + default: + $out .= $format[$i]; + } + } + + $result = $out; + + // result hook + + return $result; + } + +// private function _ard_int($float) { +// return ($float < -0.0000001) ? ceil($float - 0.0000001) : floor($float + 0.0000001); +// } + + /** + * arabic date + * @param string $format + * @param string $time_stamp + * @return string + */ + public function ADate($format, $time_stamp = "now") + { + + // Pre hook + + + $time_stamp = $this->_makeTime($time_stamp); + $result = $this->_arabicDate('ar:' . $format, $time_stamp); + // result hook + + + return $result; + } + + /** + * Islamic hijri ghamari date + * returns a string formatted according to the given format string using the given + * integer timestamp or the current time if no timestamp is given. In other words, timestamp + * is optional and defaults to the value of time(). + * + * @param $format String date format (see http://php.net/manual/en/function.date.php) + * @param $time_stamp Integer time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) + * + * @return String Returns the Hijri islamic date according to format and timestamp in Arabic/English + * + */ + public function IDate($format, $time_stamp = 'now') + { + + // Pre hook + + + $time_stamp = $this->_makeTime($time_stamp); + + list($d, $D, $j, $l, $S, $F, $m, $M, $n, $t, $L, $o, $Y, $y, $w, $a, $A, $H, $i, $s, $O) = explode("/", date("d/D/j/l/S/F/m/M/n/t/L/o/Y/y/w/a/A/H/i/s/O", $time_stamp)); + extract($this->Ge2Ism($d, $m, $Y)); + $j = $day; + $t = $ml; + $L = $ln; + $d = sprintf("%02d", $day); + $m = sprintf("%02d", $month); + $n = $month; + $Y = $year; + $y = substr($year, 2); + $S = substr($j, -1) == 1 ? "st" : (substr($j, -1) == 2 ? "nd" : (substr($j, -1) == 3 ? "rd" : "th")); + $F = $this->_getIslamicMonthName($n); + $M = $this->_getIslamicMonthName($n, true); + + + $D = $this->_getIslamicDayName($w, true); + $l = $this->_getIslamicDayName($w); + if ('ar' == "ar") { + $S = ""; + $a = $this->a['ar'][$a]; + $A = $this->A['ar'][$A]; + } + $r = "$D, $j $M $Y $H:$i:$s $O"; + $davars = ["d", "D", "j", "l", "S", "F", "m", "M", "n", "t", "L", "o", "Y", "y", "a", "A", "r"]; + $myvars = [$d, "¢", $j, "£", "ç", "¥", $m, "©", $n, $t, $L, $Y, $Y, $y, "ï", "â", "®"]; + $format = str_replace($davars, $myvars, $format); + $date = date($format, $time_stamp); + $date = str_replace(["¢", "£", "ç", "¥", "©", "ï", "â", "®"], [$D, $l, $S, $F, $M, $a, $A, $r], $date); + + // result hook + + return $date; + } + + + /** + * Returns True if is an islamic Leap Year + * @param $ayear : a year !==0. + */ + + public function IslamicLeapYear($year) + { + if ((((11 * $year) + 14) % 30) < 11) { + return true; + } else { + return false; + } + } + + /** + * is leap year + * @param int $year + * @return bool + */ + private function IsLeapYear($year) + { + if ((($year % 4) == 0 && ($year % 100) != 0) || (($year % 400) == 0) && ($year % 100) == 0) { + return true; + } else { + return false; + } + } + + + ################################################################################ +# private functions # + ################################################################################ + + + /** + * make timestamp and add offset to it. + * @param string|timestamp $time + * @return timestamp + */ + private function _makeTime($time) + { + + // pre hook + + $time_stamp = is_numeric($time) && (int)$time == $time ? $time : strtotime($time); + + // result hook + + return $time_stamp; + } + + + /** + * returns the month full name or shorting version + * @param Integer $month the month number + * @param Boolean $shorten defualt false + * @return String Month name + */ + private function _getIslamicMonthName($month, $shorten = false) + { + $longMonth = ["en" => [1 => "Muharram", "Safar", "Rabi' I", "Rabi' II", "Jumada I", "Jumada II", "Rajab", "Sha'aban", "Ramadan", "Shawwal", "Dhu al-Qi'dah", "Dhu al-Hijjah"], "ar" => [1 => "محرّم", "صفر", "ربيع الأول", "ربيع الآخر", "جمادى الأول", "جمادى الآخر", "رجب", "شعبان", "رمضان", "شوّال", "ذو القعدة", "ذو الحجة"]]; + $shortMonth = ["en" => [1 => "Muh", "Saf", "Rb1", "Rb2", "Jm1", "Jm2", "Raj", "Shb", "Rmd", "Shw", "DhQ", "DhH"], "ar" => [1 => "مح", "صف", "ر1", "ر2", "ج1", "ج2", "رج", "شع", "رم", "شو", "ذق", "ذح"]]; + $_lmonth = ($shorten) ? $shortMonth : $longMonth; + $ret = $_lmonth['ar'][$month]; + + return $ret; + } + + /** + * returns the day full name or shorting version + * @param Integer $day the day number + * @param Boolean $shorten defualt false + * @return String Day name + */ + private function _getIslamicDayName($day, $shorten = false) + { + $daySingle = [ + "en" => [1 => "Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"], + "ar" => [1 => "اثنين", "ثلاثاء", "أربعاء", "خميس", "جمعة", "سبت", "احد"], + ]; + $dayPlural = [ + "en" => [1 => "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], + "ar" => [1 => "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت", "الأحد",], + ]; + $_lmonth = ($shorten) ? $daySingle : $dayPlural; + if ($day == 0) { + $day++; + } + $ret = $_lmonth['ar'][$day]; + + return $ret; + } + + + /** + * make arabic and islamic date + * @param string $format + * @param timestamp $time_stamp + * @return string + */ + private function _arabicDate($format, $time_stamp) + { + /* + $format: [*]hj|ar|en:[jdl][Fmn][Yy][Aa] (php.date function handles the rest chars) + examples: + echo arabicDate('hj:l d-F-Y هـ', time()); + echo arabicDate('ar:l d/F - h:iA', time()); + */ + $format = trim($format); + if (substr($format, 0, 1) == '*') { + $use_span = true; + $format = substr($format, 1); + } else { + $use_span = false; + } + $type = substr($format, 0, 3); + + $arDay = ["Sat" => "السبت", "Sun" => "الأحد", "Mon" => "الإثنين", "Tue" => "الثلاثاء", + "Wed" => "الأربعاء", "Thu" => "الخميس", "Fri" => "الجمعة",]; + $ampm = ['am' => 'صباحا', 'pm' => 'مساء']; + list($d, $m, $y, $dayname, $monthname, $am) = explode(' ', date('d m Y D M a', $time_stamp)); + + if ($type == 'hj:') { +// if (($y > 1582) || (($y == 1582) && ($m > 10)) || (($y == 1582) && ($m == 10) && ($d > 14))) { +// $jd = $this->_ard_int((1461 * ($y + 4800 + $this->_ard_int(($m - 14) / 12))) / 4); +// $jd+=$this->_ard_int((367 * ($m - 2 - 12 * ($this->_ard_int(($m - 14) / 12)))) / 12); +// $jd-=$this->_ard_int((3 * ($this->_ard_int(($y + 4900 + $this->_ard_int(($m - 14) / 12)) / 100))) / 4); +// $jd+=$d - 32075; +// } else { +// $jd = 367 * $y - $this->_ard_int((7 * ($y + 5001 + $this->_ard_int(($m - 9) / 7))) / 4) + $this->_ard_int((275 * $m) / 9) + $d + 1729777; +// } +// $l = $jd - 1948440 + 10632; +// $n = $this->_ard_int(($l - 1) / 10631); +// $l = $l - 10631 * $n + 355; // Correction: 355 instead of 354 +// $j = ($this->_ard_int((10985 - $l) / 5316)) * ($this->_ard_int((50 * $l) / 17719)) + ($this->_ard_int($l / 5670)) * ($this->_ard_int((43 * $l) / 15238)); +// $l = $l - ($this->_ard_int((30 - $j) / 15)) * ($this->_ard_int((17719 * $j) / 50)) - ($this->_ard_int($j / 16)) * ($this->_ard_int((15238 * $j) / 43)) + 29; +// $m = $this->_ard_int((24 * $l) / 709); +// $d = $l - $this->_ard_int((709 * $m) / 24); +// $y = 30 * $n + $j - 30; +// +// +// $format = substr($format, 3); +// $hjMonth = array("محرم", "صفر", "ربيع أول", "ربيع ثاني", +// "جماد أول", "جماد ثاني", "رجب", "شعبان", "رمضان", "شوال", "ذو القعدة", "ذو الحجة"); +// +// $format = str_replace('j', $d, $format); +// $format = str_replace('d', str_pad($d, 2, 0, STR_PAD_LEFT), $format); +// $format = str_replace('l', $arDay[$dayname], $format); +// $format = str_replace('F', $hjMonth[$m - 1], $format); +// $format = str_replace('m', str_pad($m, 2, 0, STR_PAD_LEFT), $format); +// $format = str_replace('n', $m, $format); +// $format = str_replace('Y', $y, $format); +// $format = str_replace('y', substr($y, 2), $format); +// $format = str_replace('a', substr($ampm[$am], 0, 1), $format); +// $format = str_replace('A', $ampm[$am], $format); + } elseif ($type == 'ar:') { + $format = substr($format, 3); + $arMonth = ["Jan" => "يناير", "Feb" => "فبراير", "Mar" => "مارس", "Apr" => "ابريل", "May" => "مايو", + "Jun" => "يونيو", "Jul" => "يوليو", "Aug" => "اغسطس", "Sep" => "سبتمبر", "Oct" => "اكتوبر", + "Nov" => "نوفمبر", "Dec" => "ديسمبر",]; + $format = str_replace('l', $arDay[$dayname], $format); + $format = str_replace('F', $arMonth[$monthname], $format); + $format = str_replace('a', substr($ampm[$am], 0, 1), $format); + $format = str_replace('A', $ampm[$am], $format); + } + $date = date($format, $time_stamp); + + return $date; + } + + + /** + * convert latin numbers to hindis + * @param string $num + * @param char $sp + * @return string + */ + private function _trimNumber($num, $sp = '٫') + { + $eng = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.']; + $per = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $sp]; + $number = filter_var($num, FILTER_SANITIZE_NUMBER_INT); + + return empty($number) ? str_replace($per, $eng, $num) : str_replace($eng, $per, $num); + } + + + /** + * persian get month day count + * @param int $month + * @param int $year + * @return int + */ + private function _pGetMonthDayCount($month, $year = 0) + { + $month = (int)$month; + $year = (int)$year; + + if ($month < 7) { + return 31; + } + + // Meher and after + if ($month != 12) { + $last_day = 30; + } elseif ($month == 12) { + $last_day = 29; + // 30 days espand + if ($this->IsLeapYear($year)) { + $last_day = 30; + } + } + + return $last_day; + } + + + + + ################################################################################ +# convert functions # + ################################################################################ + + + /** + * Parse about any English textual datetime description into a Ism format + * if no format the date returned will be Ism d-m-Y + * @param String $strDate English textual datetime + * @param String $format The date format needed + * @param String $sep separator + * @return String Date in Ism as formated or like d-m-Y + */ + public function Str2Ism($strDate, $format = "d-m-Y") + { + // Pre hook + + if ($format == "d-m-Y") { + list($d, $m, $Y) = explode("/", date("d/m/Y", strtotime($strDate))); + extract($this->Ge2Ism($d, $m, $Y)); + $date = "$day-$month-$year"; + } else { + $date = $this->date($format, strtotime($strDate)); + } + + // result hook + + return $date; + } + + + /** + * Returns an array of month, day, year, ln: which is "Islamic lunation number + * (Births of New Moons)", int: The length of current month. + * + * @param $day Integer Gregorian day of the month + * @param $month Integer Gregorian month number + * @param $year Integer Gregorian year in full (1999) + * @return Array Islamic hijri date[int month, int day, int year, int ln, int ml] + * @see Robert Gent method maker (http://www.phys.uu.nl/~vgent/islam/ummalqura.htm) + */ + public function Ge2Ism($day = 20, $month = 02, $year = 1976) + { + + // Pre hook + + $jd = GregorianToJD($month, $day, $year); + $mjd = $jd - 2400000; + foreach ($this->jdl as $i => $v) { + if ($v > ($mjd - 1)) { + break; + } + } + $iln = $i + 15588; // Islamic lunation number (Births of New Moons) + $ii = floor(($i - 1) / 12); + $year = 1300 + $ii; // year + $month = $i - 12 * $ii; // month + $day = $mjd - $this->jdl[$i - 1]; //day + $ml = $this->jdl[$i] - $this->jdl[$i - 1]; // Month Length + list($_Date["month"], $_Date["day"], $_Date["year"], $_Date["ln"], $_Date["ml"]) = [$month, $day, $year, $iln, $ml]; + // result hook + + return ($_Date); + } + + /* + Convert from Islamic date to Georgian date. + @param IYear a year !== 0 + @param IMonth a month between 1 and 12 + @param IDate a date between 1 and 31 + */ + + public function Ism2Ge($IYear, $IMonth, $IDay) + { + + + // Pre hook + + $y = $IYear; + $m = $IMonth; + $d = $IDay; + + $jd = (int)((11 * $y + 3) / 30) + 354 * $y + 30 * $m - (int)(($m - 1) / 2) + $d + 1948440 - 385; + // $jd = (int)((11*$y+3)/30)+354*y+30*$m-(int)(($m-1)/2)+$d+1948440-385; + $this->julianday = $jd; + + if ($jd > 2299160) { + $l = $jd + 68569; + $n = (int)((4 * $l) / 146097); + $l = $l - (int)((146097 * $n + 3) / 4); + $i = (int)((4000 * ($l + 1)) / 1461001); + $l = $l - (int)((1461 * $i) / 4) + 31; + $j = (int)((80 * $l) / 2447); + $d = $l - (int)((2447 * $j) / 80); + $l = (int)($j / 11); + $m = $j + 2 - 12 * $l; + $y = 100 * ($n - 49) + $i + $l; + } else { + $j = $jd + 1402; + $k = (int)(($j - 1) / 1461); + $l = $j - 1461 * $k; + $n = (int)(($l - 1) / 365) - (int)($l / 1461); + $i = $l - 365 * $n + 30; + $j = (int)((80 * $i) / 2447); + $d = $i - (int)((2447 * $j) / 80); + $i = (int)($j / 11); + $m = $j + 2 - 12 * $i; + $y = 4 * $k + $n + $i - 4716; + } + + $date_g[2] = $d; + $date_g[1] = $m; + $date_g[0] = $y; + + + // result hook + + return $date_g; + } + + + /** + * Persian date to Gregorian + * @param int $jy year + * @param int $jm month 1-12 + * @param int $jd day 1-31 + * @return string + */ + public function Parsi2Ge($jy, $jm, $jd) + { + + // Pre hook + + $gd = ($jm - 2 > -1 ? $this->j_days_sum_month[((int)$jm)] + $jd : $jd); + $gy = $jy + 621; + if ($gd > 286) { + $gy++; + } + if (self::IsLeapYear($gy - 1) && 286 < $gd) { + $gd--; + } + if ($gd > 286) { + $gd -= 286; + } else { + $gd += 79; + } + if (self::IsLeapYear($gy)) { + for ($gm = 0; $gd > $this->g_days_leap_month[$gm]; $gm++) { + $gd -= $this->g_days_leap_month[$gm]; + } + } else { + for ($gm = 0; $gd > $this->g_days_in_month[$gm]; $gm++) { + $gd -= $this->g_days_in_month[$gm]; + } + } + $gm++; + + $result = [$gy, $gm, $gd]; + // result hook + + + return $result; + } + + /** + * Gregorian date to Persian date + * @param int $gy year + * @param int $gm month 1-12 + * @param int $gd day 1-31 + * @return string + */ + public function Ge2Parsi($gy, $gm, $gd) + { + + // Pre hook + $dayofyear = $this->g_days_sum_month[$gm] + $gd; + if (self::IsLeapYear($gy) and $gm > 2) { + $dayofyear++; + } + $d_33 = (int)((($gy - 16) % 132) * 0.0305); + $leap = $gy % 4; + $a = (($d_33 == 1 or $d_33 == 2) and ($d_33 == $leap or $leap == 1)) ? 78 : (($d_33 == 3 and $leap == 0) ? 80 : 79); + $b = ($d_33 == 3 or $d_33 < ($leap - 1) or $leap == 0) ? 286 : 287; + if ((int)(($gy - 10) / 63) == 30) { + $b--; + $a++; + } + if ($dayofyear > $a) { + $jy = $gy - 621; + $jd = $dayofyear - $a; + } else { + $jy = $gy - 622; + $jd = $dayofyear + $b; + } + for ($i = 0; $i < 11 and $jd > $this->j_days_in_month[$i]; $i++) { + $jd -= $this->j_days_in_month[$i]; + } + $jm = ++$i; + + $result = [$jy, strlen($jm) == 1 ? "0$jm" : $jm, strlen($jd) == 1 ? "0$jd" : $jd]; + + // result hook + + return $result; + } + + /** + * persian date to time stamp + * @param string $date date + * @param string $time time clock + * @return type + */ + public function Parsi2Timestamp($date = null, $time = '00:00:00') + { + + // Pre hook + + if ($date != null) { + list($jy, $jm, $jd) = explode('/', $date); + } else { + list($jy, $jm, $jd) = [0, 0, 0]; + } + + $arr = $this->Parsi2Ge($jy, $jm, $jd); + $result = strtotime($arr[0] . '/' . $arr[1] . '/' . $arr[2] . ' ' . $time); + + // result hook + + + return $result; + } + + /** + * hijri date to time stamp + * @param string $date date + * @param string $time time clock + * @return type + */ + public function Ism2Timestamp($date = null, $time = '00:00:00') + { + + + // Pre hook + + if ($date != null) { + list($jy, $jm, $jd) = explode('/', $date); + } else { + list($jy, $jm, $jd) = [0, 0, 0]; + } + + $arr = $this->Ism2Ge($jy, $jm, $jd); + $result = strtotime($arr[0] . '/' . $arr[1] . '/' . $arr[2] . ' ' . $time); + + // result hook + + return $result; + } + + + + + ################################################################################ +# interval functions # + ################################################################################ + + + /** + * get time stamp gregorian system + */ + + /** + * gregorian strat today + * @return int + */ + public function Today() + { + return strtotime('today'); + } + + /** + * gregorian strat yesterday + * @return int + */ + public function Yesterday() + { + return strtotime('yesterday'); + } + + /** + * gregorian this week start + * @return int + */ + public function ThisWeekStart() + { + return (strtotime('this week 00:00:00')); + } + + /** + * gregorian this week end + * @return int + */ + public function ThisWeekEnd() + { + return (strtotime('next week 00:00:00')) - 1; + } + + /** + * gregorian last week start + * @return int + */ + public function LastWeekStart() + { + return (strtotime('last week 00:00:00')); + } + + /** + * gregorian last week end + * @return int + */ + public function LastWeekEnd() + { + return ($this->ThisWeekStart() - 1); + } + + /** + * gregorian this month start + * @return int + */ + public function ThisMonthStart() + { + return mktime(0, 0, 0, date("n"), 1); + } + + /** + * gregorian this month end + * @return int + */ + public function ThisMonthEnd() + { + return mktime(23, 59, 59, date("n"), date("t")); + } + + /** + * gregorian last month start + * @return int + */ + public function LastMonthStart() + { + return mktime(0, 0, 0, date("n", strtotime('last month')), 1); + } + + /** + * gregorian last month end + * @return int + */ + public function LastMonthEnd() + { + return $this->ThisMonthStart() - 1; + } + + /** + * gregorian this year start + * @return int + */ + public function ThisYearStart() + { + return mktime(0, 0, 0, date("n", strtotime("first day of january " . + date('Y'))), 1); + } + + /** + * gregorian this year end + * @return int + */ + public function ThisYearEnd() + { + return mktime(23, 59, 59, date("n", strtotime("last day of december " . + date('Y'))), date("n", strtotime("last day of december " . + date('t')))); + } + + /** + * gregorian last year start + * @return int + */ + public function LastYearStart() + { + return mktime(0, 0, 0, date("n", strtotime("first day of january " . + (date('Y') - 1))), 1); + } + + /** + * gregorian last year end + * @return int + */ + public function LastYearEnd() + { + return mktime(23, 59, 59, date("n", strtotime("last day of december " . + (date('Y') - 1))), date("n", strtotime("last day of december " + . (date('Y') - 1)))); + } + + + ################################################################################ + /** + * get time stamp arabic islamic system + */ + + /** + * arabic islamic strat today + * @return int + */ + public function IToday() + { + return strtotime('today'); + } + + /** + * arabic islamic strat yesterday + * @return int + */ + public function IYesterday() + { + return strtotime('yesterday'); + } + + /** + * arabic islamic this week start + * @return int + */ + public function IThisWeekStart() + { + return (strtotime('last sat 00:00:00')); + } + + /** + * arabic islamic this week end + * @return int + */ + public function IThisWeekEnd() + { + return (strtotime('next sat 00:00:00')) - 1; + } + + /** + * arabic islamic last week start + * @return int + */ + public function ILastWeekStart() + { + return ($this->PThisWeekStart() - (86400 * 7));; + } + + /** + * arabic islamic last week end + * @return int + */ + public function ILastWeekEnd() + { + return ($this->PThisWeekStart() - 1); + } + + /** + * arabic islamic this month start + * @return int + */ + public function IThisMonthStart() + { + $today = (int)$this->IDate('d'); + $today--; + + return $this->Today() - ($today * 86400); + } + + /** + * arabic islamic this month end + * @return int + */ + public function IThisMonthEnd() + { + $today = (int)$this->IDate('d', time() + (30 * 86400)); + $today--; + + return ($this->Today() + (30 * 86400)) - ($today * 86400) - 1; + } + + /** + * arabic islamic last month start + * @return int + */ + public function ILastMonthStart() + { + $today = (int)$this->IDate('d', $this->ILastMonthEnd()); + $today--; + + return ($this->ILastMonthEnd() - ($today * 86400)) - 86399; + } + + /** + * arabic islamic last month end + * @return int + */ + public function ILastMonthEnd() + { + return $this->IThisMonthStart() - 1; + } + + /** + * arabic islamic this year start + * @return int + */ + public function IThisYearStart() + { + $past_day = $this->IDate('z', strtotime('yesterday')); + $result = strtotime('today') - (86400 * $past_day); + if ((int)$this->PDate('n') < 7) { + $result += 3600; + } + + return $result; + } + + /** + * arabic islamic this year end + * @return int + */ + public function IThisYearEnd() + { + if ($this->IslamicLeapYear((int)$this->IDate('Y'))) { + return $this->IThisYearStart() + (86400 * 355) - 1; + } else { + return $this->IThisYearStart() + (86400 * 354) - 1; + } + } + + /** + * arabic islamic last year start + * @return int + */ + public function ILastYearStart() + { + if ($this->IslamicLeapYear((int)$this->IDate('Y') - 1)) { + return $this->IThisYearStart() - (86400 * 354); + } else { + return $this->IThisYearStart() - (86400 * 353); + } + } + + /** + * arabic islamic this last year end + * @return int + */ + public function ILastYearEnd() + { + return $this->IThisYearStart() - 1; + } + + ################################################################################ + /** + * get time stamp persian system + */ + + /** + * persian today start + * @return int + */ + public function PToday() + { + return strtotime('today'); + } + + /** + * persian yesterday start + * @return int + */ + public function PYesterday() + { + return strtotime('yesterday'); + } + + /** + * persian this week start + * @return int + */ + public function PThisWeekStart() + { + return (strtotime('last sat 00:00:00')); + } + + /** + * persian this week end + * @return int + */ + public function PThisWeekEnd() + { + return (strtotime('next sat 00:00:00')) - 1; + } + + /** + * persian last week start + * @return int + */ + public function PLastWeekStart() + { + return ($this->PThisWeekStart() - (86400 * 7));; + } + + /** + * persian last week end + * @return int + */ + public function PLastWeekEnd() + { + return ($this->PThisWeekStart() - 1); + } + + /** + * persian last month start + * @return int + */ + public function PThisMonthStart() + { + // get this month + $this_month = $this->PDate('Y/n/') . '1'; + $result = $this->Parsi2Timestamp($this_month); + + return $result; + } + + /** + * persian last month start + * @return int + */ + public function PThisMonthStartEx($time) + { + // get this month + $this_month = $this->PDate('Y/n/', $time) . '1'; + $result = $this->Parsi2Timestamp($this_month); + + return $result; + } + + /** + * persian this month end + * @return int + */ + public function PThisMonthEnd() + { + $last_day = $this->_pGetMonthDayCount($this->PDate('n'), $this->PDate('Y')); + + $this_month = $this->PDate('Y/n/' . $last_day); + $result = $this->Parsi2Timestamp($this_month, '23:59:59'); + + return $result; + } + + /** + * persian this month end + * @return int + */ + public function PThisMonthEndEx($time) + { + $last_day = $this->_pGetMonthDayCount($this->PDate('n', $time), $this->PDate('Y', $time)); + + $this_month = $this->PDate('Y/n/' . $last_day, $time); + $result = $this->Parsi2Timestamp($this_month, '23:59:59'); + + return $result; + } + + /** + * persian last month start + * @return int + */ + public function PLastMonthStart() + { + $tmp = $this->PThisMonthStart(); + $last_month_day_count = $this->_pGetMonthDayCount($this->PDate('n', $tmp - 1), $this->PDate('Y', $tmp - 1)); + + return $tmp - ($last_month_day_count * 86400); + } + + /** + * persian last month end + * @return int + */ + public function PLastMonthEnd() + { + return $this->PThisMonthStart() - 1; + } + + /** + * persian this year start + * @return int + */ + public function PThisYearStart() + { + $past_day = $this->PDate('z', strtotime('yesterday')); + $result = strtotime('today') - (86400 * $past_day); + if ((int)$this->PDate('n') < 7) { + $result += 3600; + } + + return $result; + } + + /** + * persian this year end + * @return int + */ + public function PThisYearEnd() + { + if ($this->IsLeapYear((int)$this->PDate('Y'))) { + return $this->PThisYearStart() + (86400 * 366) - 1; + } else { + return $this->PThisYearStart() + (86400 * 365) - 1; + } + } + + /** + * persian last year start + * @return int + */ + public function PLastYearStart() + { + if ($this->IsLeapYear((int)$this->PDate('Y') - 1)) { + return $this->PThisYearStart() - (86400 * 365); + } else { + return $this->PThisYearStart() - (86400 * 364); + } + } + + /** + * persian this last year end + * @return int + */ + public function PLastYearEnd() + { + return $this->PThisYearStart() - 1; + } +} diff --git a/app/Http/Middleware/Acl.php b/app/Http/Middleware/Acl.php new file mode 100644 index 0000000..11deca3 --- /dev/null +++ b/app/Http/Middleware/Acl.php @@ -0,0 +1,20 @@ +belongsTo(User::class); + } } diff --git a/app/Models/Adv.php b/app/Models/Adv.php index 0be1574..ee495ce 100644 --- a/app/Models/Adv.php +++ b/app/Models/Adv.php @@ -2,10 +2,19 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class Adv extends Model { - use HasFactory; + use SoftDeletes; + + public function imgUrl() + { + if ($this->image == null) { + return null; + } + + return \Storage::url('advs/' . $this->image); + } } diff --git a/app/Models/Clip.php b/app/Models/Clip.php index a869180..3040cfb 100644 --- a/app/Models/Clip.php +++ b/app/Models/Clip.php @@ -4,8 +4,40 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; +use Spatie\Translatable\HasTranslations; class Clip extends Model { - use HasFactory; + use HasFactory, SoftDeletes, HasTranslations; + + public $translatable = ['title','body']; + + public function getRouteKeyName() + { + return 'slug'; + } + + public function coverUrl() + { + if ($this->cover == null) { + return null; + } + + return \Storage::url('clips/' . $this->cover); + } + + public function fileUrl() + { + if ($this->file == null) { + return null; + } + + return \Storage::url('clips/' . $this->file); + } + + public function author() + { + return $this->belongsTo(\App\Models\User::class); + } } diff --git a/app/Models/Comment.php b/app/Models/Comment.php index 0d9ecbd..3068e53 100644 --- a/app/Models/Comment.php +++ b/app/Models/Comment.php @@ -8,4 +8,19 @@ use Illuminate\Database\Eloquent\Model; class Comment extends Model { use HasFactory; + + public function commentable() + { + return $this->morphTo(); + } + + public function children() + { + return $this->hasMany(Comment::class, 'sub_comment_id'); + } + + public function approved_children() + { + return $this->hasMany(Comment::class, 'sub_comment_id')->where('status', 1); + } } diff --git a/app/Models/Gallery.php b/app/Models/Gallery.php index 8229be1..6f790ca 100644 --- a/app/Models/Gallery.php +++ b/app/Models/Gallery.php @@ -4,8 +4,58 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Spatie\MediaLibrary\Conversions\Manipulations; +use Spatie\MediaLibrary\HasMedia; +use Spatie\MediaLibrary\InteractsWithMedia; +use Spatie\MediaLibrary\MediaCollections\Models\Media; +use Spatie\Translatable\HasTranslations; -class Gallery extends Model +class Gallery extends Model implements HasMedia { - use HasFactory; + use HasFactory,InteractsWithMedia,HasTranslations; + + + public $translatable = ['title','description']; + public function images() + { + return $this->hasMany(Images::class, 'gallery_id', 'id')->orderBy('sort')->orderByDesc('id'); + } + + public function registerMediaConversions(Media $media = null): void + { + $this->addMediaConversion('gallery-image')->optimize(); + + $t = explode('x',config('app.media.gallery_thumb')); + + if (config('starter-kit.gallery_thumb') == null || config('starter-kit.gallery_thumb') == ''){ + $t[0] = 500 ; + $t[1] = 500 ; + } + + + $this->addMediaConversion('gthumb')->width($t[0]) + ->height($t[1]) + ->crop(Manipulations::CROP_CENTER, $t[0], $t[1])->optimize(); +// ->watermark(public_path('images/logo.png'))->watermarkOpacity(50); +// ->withResponsiveImages(); + } + + public function getRouteKeyName() + { + return 'slug'; + } + + public function imgurl() + { + if ($this->getMedia()->count() > 0) { + return $this->getMedia()->first()->getUrl('gthumb'); + } else { + return "no image"; + } + } + + public function author() + { + return $this->belongsTo(\App\Models\User::class); + } } diff --git a/app/Models/Group.php b/app/Models/Group.php index 88fbee2..00274a8 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -4,8 +4,39 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; +use Spatie\Translatable\HasTranslations; +use Xmen\StarterKit\Models\Category; +use Xmen\StarterKit\Models\Post; class Group extends Model { - use HasFactory; + use HasFactory, SoftDeletes,HasTranslations; + + public $translatable = ['name','description']; + public function posts() + { + return $this->belongsToMany(Post::class); + } + + // + public function parent() + { + return $this->belongsTo(Category::class, 'parent_id'); + } + + public function children() + { + return $this->hasMany(Category::class, 'parent_id'); + } + + public function getRouteKeyName() + { + return 'slug'; + } + + public function author() + { + return $this->belongsTo(\App\Models\User::class); + } } diff --git a/app/Models/Images.php b/app/Models/Images.php index 35c482f..3f58e63 100644 --- a/app/Models/Images.php +++ b/app/Models/Images.php @@ -4,8 +4,46 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Spatie\Image\Manipulations; +use Spatie\MediaLibrary\HasMedia; +use Spatie\MediaLibrary\InteractsWithMedia; +use Spatie\MediaLibrary\MediaCollections\Models\Media; +use Spatie\Translatable\HasTranslations; -class Images extends Model +class Images extends Model implements HasMedia { - use HasFactory; + use HasFactory,InteractsWithMedia, HasTranslations; + public $translatable = ['title']; + + public function gallery() + { + return $this->belongsTo(Gallery::class, 'gallery_id'); + } + + public function registerMediaConversions(Media $media = null): void + { + + $t = explode('x', config('starter-kit.post_thumb')); + if (config('starter-kit.gallery_thumb') == null || config('starter-kit.gallery_thumb') == '') { + $t[0] = 500; + $t[1] = 500; + } + + $this->addMediaConversion('image-image')->optimize(); + + $this->addMediaConversion('gthumb')->width($t[0]) + ->height($t[1]) + ->crop(Manipulations::CROP_CENTER, $t[0], $t[1])->optimize(); +// ->watermark(public_path('images/logo.png'))->watermarkOpacity(50); +// ->withResponsiveImages(); + } + + public function imgurl() + { + if ($this->getMedia()->count() > 0) { + return $this->getMedia()->first()->getUrl('gthumb'); + } else { + return "no image"; + } + } } diff --git a/app/Models/Menu.php b/app/Models/Menu.php index 17f7ad2..fb8b774 100644 --- a/app/Models/Menu.php +++ b/app/Models/Menu.php @@ -4,8 +4,14 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class Menu extends Model { - use HasFactory; + use HasFactory,SoftDeletes; + + public function menuItems() + { + return $this->hasMany(MenuItem::class, 'menu_id', 'id'); + }; } diff --git a/app/Models/MenuItem.php b/app/Models/MenuItem.php index a563ab4..b623448 100644 --- a/app/Models/MenuItem.php +++ b/app/Models/MenuItem.php @@ -4,8 +4,26 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Spatie\Translatable\HasTranslations; class MenuItem extends Model { - use HasFactory; + use HasFactory,HasTranslations; + + public $translatable = ['title']; + + public function menu() + { + return $this->belongsTo(Menu::class, 'menu_id', 'id'); + } + + public function parent() + { + return $this->belongsTo(MenuItem::class, 'parent'); + } + + public function children() + { + return $this->hasMany(MenuItem::class, 'parent'); + } } diff --git a/app/Models/Post.php b/app/Models/Post.php index 089656b..490ba65 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -4,8 +4,101 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; +use Spatie\Image\Manipulations; +use Spatie\MediaLibrary\HasMedia; +use Spatie\MediaLibrary\InteractsWithMedia; +use Spatie\MediaLibrary\MediaCollections\Models\Media; +use Spatie\Translatable\HasTranslations; -class Post extends Model +class Post extends Model implements HasMedia { - use HasFactory; + use HasFactory,SoftDeletes, InteractsWithMedia,HasTranslations; + public $translatable = ['title','subtitle','body']; + + public function categories() + { + return $this->belongsToMany(Category::class); + } + + public function author() + { + return $this->belongsTo(\App\Models\User::class); + } + + public function getRouteKeyName() + { + return 'slug'; + } + + + public function registerMediaConversions(Media $media = null): void + { + $t = explode('x',config('app.media.post_thumb')); + + if (config('app.media.post_thumb') == null || config('app.media.post_thumb') == ''){ + $t[0] = 500 ; + $t[1] = 500 ; + } + + + $this->addMediaConversion('posts-image') + ->width($t[0]) + ->height($t[1]) + ->crop(Manipulations::CROP_CENTER, $t[0], $t[1]) + ->optimize() + ->sharpen(10); + } + + public function imgurl() + { + if ($this->getMedia()->count() > 0) { + return $this->getMedia()->first()->getUrl('posts-image'); + } else { + return "no image"; + } + } + + public function orgurl() + { + if ($this->getMedia()->count() > 0) { + return $this->getMedia()[$this->image_index]->getUrl(); + } else { + return asset('/images/logo.png'); + + } + } + + + public function spendTime() + { + $word = strlen(strip_tags($this->body)); + $m = ceil($word / 1350); + + return $m . ' ' . __('minute'); + } + + + public function comments() + { + return $this->morphMany(Comment::class, 'commentable'); + } + + public function approved_comments() + { + return $this->morphMany(Comment::class, 'commentable')->where('status', 1); + } + + public function toArray() + { + return [ + 'id' => $this->id, + 'title' => $this->title, + 'subtitle' => $this->subtitle, + 'body' => $this->body, + 'categories' => $this->categories->implode(' ') ?? null, + 'author' => $this->author->name ?? null, + 'tags' => $this->tags->implode(' ') ?? null, + ]; + } } diff --git a/app/Models/Slider.php b/app/Models/Slider.php index 5000acf..ee1b871 100644 --- a/app/Models/Slider.php +++ b/app/Models/Slider.php @@ -4,8 +4,24 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Spatie\Translatable\HasTranslations; class Slider extends Model { - use HasFactory; + use HasFactory,HasTranslations; + public $translatable = ['body']; + + public function imgUrl() + { + if ($this->image == null) { + return null; + } + + return \Storage::url('sliders/' . $this->image); + } + + public function author() + { + return $this->belongsTo(User::class); + } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..7852b8f 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,10 @@ namespace App\Providers; +use App\Helpers\TDate; +use App\Http\Middleware\Acl; +use Carbon\Carbon; +use Illuminate\Pagination\Paginator; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -19,6 +23,14 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + /** @var Router $router */ + $router = $this->app['router']; + $router->pushMiddlewareToGroup('web', Acl::class); + + Paginator::useBootstrap(); + Carbon::macro('jdate', function ($format, $tr_num = 'fa') { + $dt = TDate::GetInstance(); + return $dt->PDate($format, self::this()->timestamp); + }); } } diff --git a/composer.json b/composer.json index 1fb6b82..5c1ed76 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,10 @@ "spatie/laravel-ignition": "^2.4" }, "autoload": { + "files": [ + "app/Helpers/Helper.php", + "app/Helpers/TDate.php" + ], "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", diff --git a/config/app.php b/config/app.php index 44fd5b6..cfa026b 100644 --- a/config/app.php +++ b/config/app.php @@ -135,6 +135,17 @@ return [ 'prefix' => env('PANEL_PREFIX','dashboard'), 'page_count' => env('PANEL_PAGE_COUNT',30), ], + /* + |-------------------------------------------------------------------------- + | Media + |-------------------------------------------------------------------------- + | These configuration options of medias + */ + + 'media' => [ + 'gallery_thumb' => env('MEDIA_GALLEY_THUMB','500x500'), + 'post_thumb' => env('MEDIA_POST_THUMB','500x500'), + ], ]; diff --git a/database/factories/AdvFactory.php b/database/factories/AdvFactory.php deleted file mode 100644 index 018e28f..0000000 --- a/database/factories/AdvFactory.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ -class AdvFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - // - ]; - } -} diff --git a/database/factories/CreditFactory.php b/database/factories/CreditFactory.php deleted file mode 100644 index 92c98fc..0000000 --- a/database/factories/CreditFactory.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ -class CreditFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - // - ]; - } -}