Файловый менеджер - Редактировать - /home/vielwcom/www3.vielw.com/app/Bitwise/Models.tar
Назад
HomePageStatistic.php 0000644 00000001331 15102516312 0010624 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class HomePageStatistic extends Model implements TranslatableContract { use Translatable; protected $table = 'home_page_statistics'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } } CourseForumAnswer.php 0000644 00000000507 15102516312 0010704 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class CourseForumAnswer extends Model { protected $table = 'course_forum_answers'; protected $guarded = ['id']; public $timestamps = false; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } WebinarExtraDescription.php 0000644 00000001427 15102516312 0012054 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class WebinarExtraDescription extends Model implements TranslatableContract { use Translatable; protected $table = 'webinar_extra_descriptions'; public $timestamps = false; protected $guarded = ['id']; static $types = ['learning_materials', 'company_logos', 'requirements']; static $LEARNING_MATERIALS = 'learning_materials'; static $COMPANY_LOGOS = 'company_logos'; static $REQUIREMENTS = 'requirements'; public $translatedAttributes = ['value']; public function getValueAttribute() { return getTranslateAttributeValue($this, 'value'); } } BecomeInstructor.php 0000644 00000001731 15102516312 0010542 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class BecomeInstructor extends Model { protected $table = 'become_instructors'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function registrationPackage() { return $this->belongsTo('App\Models\RegistrationPackage', 'package_id', 'id'); } public function sendNotificationToUser($status) { $notifyOptions = [ '[u.role]' => $this->role == 'teacher' ? trans('admin/main.instructor') : trans('admin/main.organization') ]; if ($status == 'reject') { sendNotification("become_instructor_request_rejected", $notifyOptions, $this->user_id); } else { sendNotification("become_instructor_request_approved", $notifyOptions, $this->user_id); } } } UserSelectedBank.php 0000644 00000001317 15102516312 0010436 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class UserSelectedBank extends Model { protected $table = "user_selected_banks"; public $timestamps = false; protected $guarded = ['id']; public function bank() { return $this->belongsTo('App\Models\UserBank', 'user_bank_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function specifications() { return $this->hasMany('App\Models\UserSelectedBankSpecification', 'user_selected_bank_id', 'id'); } } WebinarAssignmentHistory.php 0000644 00000001772 15102516312 0012262 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class WebinarAssignmentHistory extends Model { protected $table = 'webinar_assignment_history'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $assignmentHistoryStatus = ['pending', 'passed', 'not_passed', 'not_submitted']; static $pending = 'pending'; static $passed = 'passed'; static $notPassed = 'not_passed'; static $notSubmitted = 'not_submitted'; public function instructor() { return $this->belongsTo('App\User', 'instructor_id', 'id'); } public function student() { return $this->belongsTo('App\User', 'student_id', 'id'); } public function assignment() { return $this->belongsTo('App\Models\WebinarAssignment', 'assignment_id', 'id'); } public function messages() { return $this->hasMany('App\Models\WebinarAssignmentHistoryMessage', 'assignment_history_id', 'id'); } } NoticeboardStatus.php 0000644 00000000403 15102516312 0010703 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class NoticeboardStatus extends Model { protected $table = 'noticeboards_status'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id'];// } ForumTopicLike.php 0000644 00000000374 15102516312 0010151 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ForumTopicLike extends Model { protected $table = 'forum_topic_likes'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } ProductReview.php 0000644 00000001127 15102516312 0010054 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ProductReview extends Model { protected $table = 'product_reviews'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Comment', 'product_review_id', 'id'); } } Product.php 0000644 00000025074 15102516312 0006701 0 ustar 00 <?php namespace App\Models; use App\User; use Cviebrock\EloquentSluggable\Services\SlugService; use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Support\Facades\DB; use Jorenvh\Share\ShareFacade; class Product extends Model implements TranslatableContract { use Translatable; use Sluggable; protected $table = 'products'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $productTypes = ['virtual', 'physical']; static $productStatus = ['active', 'pending', 'draft', 'inactive']; static $physical = 'physical'; static $virtual = 'virtual'; static $active = 'active'; static $pending = 'pending'; static $draft = 'draft'; static $inactive = 'inactive'; public $translatedAttributes = ['title', 'seo_description', 'summary', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getSeoDescriptionAttribute() { return getTranslateAttributeValue($this, 'seo_description'); } public function getSummaryAttribute() { return getTranslateAttributeValue($this, 'summary'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function getThumbnailAttribute() { $media = $this->media()->where('type', ProductMedia::$thumbnail)->first(); return !empty($media) ? $media->path : null; } public function getImagesAttribute() { return $this->media()->where('type', ProductMedia::$image)->get(); } public function getVideoDemoAttribute() { $media = $this->media()->where('type', ProductMedia::$video)->first(); return !empty($media) ? $media->path : null; } public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public static function makeSlug($title) { return SlugService::createSlug(self::class, 'slug', $title); } /* * Relations * */ public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function files() { return $this->hasMany('App\Models\ProductFile', 'product_id', 'id'); } public function media() { return $this->hasMany('App\Models\ProductMedia', 'product_id', 'id'); } public function category() { return $this->belongsTo('App\Models\ProductCategory', 'category_id', 'id'); } public function selectedFilterOptions() { return $this->hasMany('App\Models\ProductSelectedFilterOption', 'product_id', 'id'); } public function selectedSpecifications() { return $this->hasMany('App\Models\ProductSelectedSpecification', 'product_id', 'id'); } public function faqs() { return $this->hasMany('App\Models\ProductFaq', 'product_id', 'id'); } public function discounts() { return $this->hasMany('App\Models\ProductDiscount', 'product_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Comment', 'product_id', 'id'); } public function reviews() { return $this->hasMany('App\Models\ProductReview', 'product_id', 'id'); } public function productOrders() { return $this->hasMany('App\Models\ProductOrder', 'product_id', 'id'); } public function sales($withoutRefunds = true) { if (empty($this->salesCache)) { $ordersIds = $this->productOrders->pluck('id')->toArray(); $query = Sale::whereIn('product_order_id', $ordersIds); if ($withoutRefunds) { $query->whereNull('refund_at'); } $query->orderBy('created_at', 'desc'); $this->salesCache = $query->get(); } return $this->salesCache; } public function salesCount($inventoryUpdatedAt = false) { if (empty($this->salesCountCache)) { $query = $this->productOrders() ->whereNotNull('sale_id') ->whereHas('sale', function ($query) { $query->whereNull('refund_at'); }) ->whereNotIn('status', [ProductOrder::$canceled, ProductOrder::$pending]); if ($inventoryUpdatedAt and !empty($this->inventory_updated_at)) { $query->where('created_at', '>=', $this->inventory_updated_at); } $this->salesCountCache = $query->sum('quantity'); } return $this->salesCountCache; } /* * .\ Relations * */ public function isVirtual(): bool { return ($this->type == self::$virtual); } public function isPhysical(): bool { return ($this->type == self::$physical); } public function getActiveDiscount() { $activeDiscount = ProductDiscount::where('product_id', $this->id) ->where('status', 'active') ->where('start_date', '<', time()) ->where('end_date', '>', time()) ->first(); if (!empty($activeDiscount) and !empty($activeDiscount->count)) { $usedCount = ProductOrder::where('product_id', $this->id) ->where('discount_id', $activeDiscount->id) ->whereHas('sale', function ($query) { $query->whereNull('refund_at'); }) ->count(); if ($usedCount >= $activeDiscount->count) { return false; } } return $activeDiscount ?? false; } public function getPriceWithActiveDiscountPrice() { $activeDiscount = $this->getActiveDiscount(); $price = $this->price ?? 0; if (!empty($activeDiscount)) { $price = $price - ($price * $activeDiscount->percent / 100); } return $price; } public function getDiscountPrice() { $price = 0; $activeDiscount = $this->getActiveDiscount(); if (!empty($activeDiscount)) { $price = $this->price * $activeDiscount->percent / 100; } return $price; } public function getPrice() { // this method used in installment return $this->getPriceWithActiveDiscountPrice(); } public function getAvailability() { if (empty($this->availabilityCount)) { if ($this->unlimited_inventory) { $this->availabilityCount = 99999; } else { $availabilityCount = $this->inventory - $this->salesCount(true); if ($availabilityCount < 0) { $availabilityCount = 0; } $this->availabilityCount = $availabilityCount; } } return $this->availabilityCount; } public function getUrl() { return url('/products/' . $this->slug); } public function getShareLink($social) { $link = ShareFacade::page($this->getUrl(), $this->title) ->facebook() ->twitter() ->whatsapp() ->telegram() ->getRawLinks(); return !empty($link[$social]) ? $link[$social] : ''; } public function getRate() { $rate = 0; $reviews = $this->reviews() ->where('status', 'active') ->get(); if (!empty($reviews) and $reviews->count() > 0) { $rate = number_format($reviews->avg('rates'), 2); } if ($rate > 5) { $rate = 5; } return $rate > 0 ? number_format($rate, 2) : 0; } public function getCommission() { $commission = 0; if (!empty($this->commission)) { $commission = $this->commission; } else { $getStoreSettings = getStoreSettings(); if ($this->type == self::$virtual and !empty($getStoreSettings) and !empty($getStoreSettings['virtual_product_commission'])) { $commission = $getStoreSettings['virtual_product_commission']; } elseif ($this->type == self::$physical and !empty($getStoreSettings) and !empty($getStoreSettings['physical_product_commission'])) { $commission = $getStoreSettings['physical_product_commission']; } else { $financialSettings = getFinancialSettings(); if (!empty($financialSettings['commission'])) { $commission = $financialSettings['commission']; } } } return $commission; } public function getTax() { $tax = 0; if (!empty($this->tax)) { $tax = $this->tax; } else { $getStoreSettings = getStoreSettings(); if (!empty($getStoreSettings) and isset($getStoreSettings['store_tax'])) { $tax = $getStoreSettings['store_tax']; } else { $financialSettings = getFinancialSettings(); if (!empty($financialSettings['tax'])) { $tax = $financialSettings['tax']; } } } return $tax; } public function checkUserHasBought($user = null): bool { $hasBought = false; if (empty($user)) { $user = auth()->user(); } if (!empty($user)) { $giftsIds = Gift::query()->where('email', $user->email) ->where('status', 'active') ->whereNotNull('product_id') ->where(function ($query) { $query->whereNull('date'); $query->orWhere('date', '<', time()); }) ->whereHas('sale') ->pluck('id') ->toArray(); $order = ProductOrder::query()->where('product_id', $this->id) ->where(function ($query) use ($user, $giftsIds) { $query->where('buyer_id', $user->id); $query->orWhereIn('gift_id', $giftsIds); }) ->whereHas('sale', function ($query) use ($user) { $query->whereIn('type', ['product', 'gift']) ->where('access_to_purchased_item', true) ->whereNull('refund_at'); })->first(); $hasBought = !empty($order); } return $hasBought; } } Setting.php 0000644 00000037320 15102516312 0006673 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Setting extends Model implements TranslatableContract { use Translatable; //TODO:: To use the site settings, please use the functions of the helper.php file. // If you have created new settings, please use the same structure to optimize // the number of requests to the database, because this system does not use cache. protected $table = 'settings'; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['value']; public function getValueAttribute() { return getTranslateAttributeValue($this, 'value'); } // The result is stored in these variables // If you use each function more than once per page, the database will be requested only once. static $seoMetas, $socials, $footer, $general, $homeSections, $features, $financial, $offlineBanks, $referral, $currencySettings, $homeHero, $homeHero2, $homeVideoOrImage, $pageBackground, $customCssJs, $reportReasons, $notificationTemplates, $contactPage, $Error404Page, $navbarLink, $panelSidebar, $findInstructors, $rewardProgram, $rewardsSettings, $storeSettings, $registrationPackagesGeneral, $registrationPackagesInstructors, $registrationPackagesOrganizations, $becomeInstructorSection, $themeColors, $themeFonts, $forumHomeSection, $cookieSettings, $mobileAppSettings, $remindersSettings, $generalSecuritySettings, $advertisingModal, $othersPersonalization, $installmentsSettings, $installmentsTermsSettings, $registrationBonusSettings, $registrationBonusTermsSettings, $statisticsSettings, $maintenanceSettings, $generalOptions, $giftsGeneralSettings; // settings name , Using these keys, values are taken from the settings table static $seoMetasName = 'seo_metas'; static $socialsName = 'socials'; static $footerName = 'footer'; static $generalName = 'general'; static $featuresName = 'features'; static $homeSectionsName = 'home_sections'; static $financialName = 'financial'; static $offlineBanksName = 'offline_banks'; static $referralName = 'referral'; static $currencySettingsName = 'currency_settings'; static $homeHeroName = 'home_hero'; static $homeHeroName2 = 'home_hero2'; static $homeVideoOrImageName = 'home_video_or_image_box'; static $pageBackgroundName = 'page_background'; static $customCssJsName = 'custom_css_js'; static $reportReasonsName = 'report_reasons'; static $notificationTemplatesName = 'notifications'; static $contactPageName = 'contact_us'; static $Error404PageName = '404'; static $navbarLinkName = 'navbar_links'; static $panelSidebarName = 'panel_sidebar'; static $findInstructorsName = 'find_instructors'; static $rewardProgramName = 'reward_program'; static $rewardsSettingsName = 'rewards_settings'; static $storeSettingsName = 'store_settings'; static $registrationPackagesGeneralName = 'registration_packages_general'; static $registrationPackagesInstructorsName = 'registration_packages_instructors'; static $registrationPackagesOrganizationsName = 'registration_packages_organizations'; static $becomeInstructorSectionName = 'become_instructor_section'; static $themeColorsName = 'theme_colors'; static $themeFontsName = 'theme_fonts'; static $forumHomeSectionName = 'forums_section'; static $cookieSettingsName = 'cookie_settings'; static $mobileAppSettingsName = 'mobile_app'; static $remindersSettingsName = 'reminders'; static $generalSecuritySettingsName = 'security'; static $advertisingModalName = 'advertising_modal'; static $othersPersonalizationName = 'others_personalization'; static $installmentsSettingsName = 'installments_settings'; static $installmentsTermsSettingsName = 'installments_terms_settings'; static $registrationBonusSettingsName = 'registration_bonus_settings'; static $registrationBonusTermsSettingsName = 'registration_bonus_terms_settings'; static $statisticsSettingsName = 'statistics'; static $maintenanceSettingsName = 'maintenance_settings'; static $generalOptionsName = 'general_options'; static $giftsGeneralSettingsName = 'gifts_general_settings'; //statics static $pagesSeoMetas = ['home', 'search', 'categories', 'classes', 'login', 'register', 'contact', 'blog', 'certificate_validation', 'instructors', 'organizations', 'instructor_finder_wizard', 'instructor_finder', 'reward_courses', 'products_lists', 'reward_products', 'forum', 'upcoming_courses_lists' ]; static $mainSettingSections = ['general', 'financial', 'payment', 'home_hero', 'home_hero2', 'page_background', 'home_video_or_image_box']; static $mainSettingPages = ['general', 'financial', 'personalization', 'notifications', 'seo', 'customization', 'other']; static $defaultSettingsLocale = 'en'; // Because the settings table uses translation and some settings do not need to be translated, so we save them with a default locale static $rootColors = ['primary', "primary-border", "primary-hover", "primary-border-hover", "primary-btn-shadow", "primary-btn-shadow-hover", "primary-btn-color", "primary-btn-color-hover", 'secondary', "secondary-border", "secondary-hover", "secondary-border-hover", "secondary-btn-shadow", "secondary-btn-shadow-hover", "secondary-btn-color", "secondary-btn-color-hover"]; static $rootAdminColors = ['primary']; static function getSettingsWithDefaultLocal(): array { return [ self::$seoMetasName, self::$socialsName, self::$generalName, self::$financialName, self::$offlineBanksName, self::$referralName, self::$pageBackgroundName, self::$homeSectionsName, self::$notificationTemplatesName, self::$customCssJsName, self::$Error404PageName, self::$contactPageName, ]; } // functions static function getSetting(&$static, $name, $key = null) { if (!isset($static)) { $static = cache()->remember('settings.' . $name, 24 * 60 * 60, function () use ($name) { return self::where('name', $name)->first(); }); } $value = []; if (!empty($static) and !empty($static->value) and isset($static->value)) { $value = json_decode($static->value, true); } if (!empty($value) and !empty($key)) { if (isset($value[$key])) { return $value[$key]; } else { return null; } } if (!empty($key) and (empty($value) or count($value) < 1)) { return ''; } return $value; } /** * @param null $page => home, search, categories, login, register, about, contact * @return array => [title, description] */ static function getSeoMetas($page = null) { return self::getSetting(self::$seoMetas, self::$seoMetasName, $page); } /** * @return array [title, image, link] */ static function getSocials() { return self::getSetting(self::$socials, self::$socialsName); } /** * @return array [title, items => [title, link]] */ static function getFooterColumns() { return self::getSetting(self::$footer, self::$footerName); } /** * @return array [site_name, site_email, site_language, user_languages, rtl_languages, fav_icon, logo, footer_logo, rtl_layout, home hero1 is active, home hero2 is active, content_translate ] */ static function getGeneralSettings($key = null) { return self::getSetting(self::$general, self::$generalName, $key); } /** * @return array [] */ static function getFeaturesSettings($key = null) { return self::getSetting(self::$features, self::$featuresName, $key); } /** * @return array [] */ static function getCookieSettings($key = null) { return self::getSetting(self::$cookieSettings, self::$cookieSettingsName, $key); } /** * @param $key * @return array|[commission, tax, minimum_payout, currency] */ static function getFinancialSettings($key = null) { return self::getSetting(self::$financial, self::$financialName, $key); } /** * @param $key * * @return array|string */ static function getFinancialCurrencySettings($key = null) { return self::getSetting(self::$currencySettings, self::$currencySettingsName, $key); } /** * @param string $section * @return array|[title, description, hero_background] */ static function getHomeHeroSettings($section = '1') { if ($section == "2") { return self::getSetting(self::$homeHero2, self::$homeHeroName2); } return self::getSetting(self::$homeHero, self::$homeHeroName); } /** * @return array|[title, description, background] */ static function getHomeVideoOrImageBoxSettings() { return self::getSetting(self::$homeVideoOrImage, self::$homeVideoOrImageName); } /** * @param null $page => login, register, remember_pass, search, categories, become_instructor, blog, instructors, user_avatar, user_cover * @return string|array => [all pages] */ static function getPageBackgroundSettings($page = null) { return self::getSetting(self::$pageBackground, self::$pageBackgroundName, $page); } /** * @param null $key => css, js * @return string|array => {css, js} */ static function getCustomCssAndJs($key = null) { return self::getSetting(self::$customCssJs, self::$customCssJsName, $key); } /** * @return array */ static function getReportReasons() { return self::getSetting(self::$reportReasons, self::$reportReasonsName); } /** * @param $template {String|nullable} * @return array */ static function getNotificationTemplates($template = null) { return self::getSetting(self::$notificationTemplates, self::$notificationTemplatesName, $template); } /** * @return array */ static function getOfflineBankSettings($key = null) { return self::getSetting(self::$offlineBanks, self::$offlineBanksName, $key); } /** * @return array */ static function getReferralSettings() { return self::getSetting(self::$referral, self::$referralName); } /** * @param $key * @return array */ static function getContactPageSettings($key = null) { return self::getSetting(self::$contactPage, self::$contactPageName, $key); } /** * @param $key * @return array */ static function get404ErrorPageSettings($key = null) { return self::getSetting(self::$Error404Page, self::$Error404PageName, $key); } /** * @param $key * @return array */ static function getHomeSectionsSettings($key = null) { return self::getSetting(self::$homeSections, self::$homeSectionsName, $key); } /** * @param $key * @return array */ static function getNavbarLinksSettings($key = null) { return self::getSetting(self::$navbarLink, self::$navbarLinkName, $key); } /** * @return array */ static function getPanelSidebarSettings() { return self::getSetting(self::$panelSidebar, self::$panelSidebarName); } /** * @return array */ static function getFindInstructorsSettings() { return self::getSetting(self::$findInstructors, self::$findInstructorsName); } /** * @return array */ static function getRewardProgramSettings() { return self::getSetting(self::$rewardProgram, self::$rewardProgramName); } /** * @return array */ static function getRewardsSettings() { return self::getSetting(self::$rewardsSettings, self::$rewardsSettingsName); } /** * @return array */ static function getStoreSettings($key = null) { return self::getSetting(self::$storeSettings, self::$storeSettingsName, $key); } static function getBecomeInstructorSectionSettings() { return self::getSetting(self::$becomeInstructorSection, self::$becomeInstructorSectionName); } static function getForumSectionSettings() { return self::getSetting(self::$forumHomeSection, self::$forumHomeSectionName); } static function getRegistrationPackagesGeneralSettings($key = null) { return self::getSetting(self::$registrationPackagesGeneral, self::$registrationPackagesGeneralName, $key); } static function getRegistrationPackagesInstructorsSettings($key = null) { return self::getSetting(self::$registrationPackagesInstructors, self::$registrationPackagesInstructorsName, $key); } static function getRegistrationPackagesOrganizationsSettings($key = null) { return self::getSetting(self::$registrationPackagesOrganizations, self::$registrationPackagesOrganizationsName, $key); } static function getThemeColorsSettings() { return self::getSetting(self::$themeColors, self::$themeColorsName); } static function getThemeFontsSettings() { return self::getSetting(self::$themeFonts, self::$themeFontsName); } static function getMobileAppSettings($key = null) { return self::getSetting(self::$mobileAppSettings, self::$mobileAppSettingsName, $key); } static function getRemindersSettings($key = null) { return self::getSetting(self::$remindersSettings, self::$remindersSettingsName, $key); } static function getGeneralSecuritySettings($key = null) { return self::getSetting(self::$generalSecuritySettings, self::$generalSecuritySettingsName, $key); } static function getAdvertisingModalSettings($key = null) { return self::getSetting(self::$advertisingModal, self::$advertisingModalName, $key); } static function getOthersPersonalizationSettings($key = null) { return self::getSetting(self::$othersPersonalization, self::$othersPersonalizationName, $key); } static function getInstallmentsSettings($key = null) { return self::getSetting(self::$installmentsSettings, self::$installmentsSettingsName, $key); } static function getInstallmentsTermsSettings($key = null) { return self::getSetting(self::$installmentsTermsSettings, self::$installmentsTermsSettingsName, $key); } static function getRegistrationBonusSettings($key = null) { return self::getSetting(self::$registrationBonusSettings, self::$registrationBonusSettingsName, $key); } static function getRegistrationBonusTermsSettings($key = null) { return self::getSetting(self::$registrationBonusTermsSettings, self::$registrationBonusTermsSettingsName, $key); } static function getStatisticsSettings($key = null) { return self::getSetting(self::$statisticsSettings, self::$statisticsSettingsName, $key); } static function getMaintenanceSettings($key = null) { return self::getSetting(self::$maintenanceSettings, self::$maintenanceSettingsName, $key); } static function getGeneralOptionsSettings($key = null) { return self::getSetting(self::$generalOptions, self::$generalOptionsName, $key); } static function getGiftsGeneralSettings($key = null) { return self::getSetting(self::$giftsGeneralSettings, self::$giftsGeneralSettingsName, $key); } } Order.php 0000644 00000002405 15102516312 0006325 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Order extends Model { //status public static $pending = 'pending'; public static $paying = 'paying'; public static $paid = 'paid'; public static $fail = 'fail'; //types public static $webinar = 'webinar'; public static $meeting = 'meeting'; public static $charge = 'charge'; public static $subscribe = 'subscribe'; public static $promotion = 'promotion'; public static $registrationPackage = 'registration_package'; public static $product = 'product'; public static $bundle = 'bundle'; public static $installmentPayment = 'installment_payment'; public static $gift = 'gift'; public static $addiction = 'addiction'; public static $deduction = 'deduction'; public static $income = 'income'; public static $asset = 'asset'; //paymentMethod public static $credit = 'credit'; public static $paymentChannel = 'payment_channel'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function orderItems() { return $this->hasMany('App\Models\OrderItem', 'order_id', 'id'); } } CashbackRuleSpecificationItem.php 0000644 00000000562 15102516312 0013123 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class CashbackRuleSpecificationItem extends Model { protected $table = 'cashback_rule_specification_items'; public $timestamps = false; protected $guarded = ['id']; } CourseLearning.php 0000644 00000000374 15102516312 0010175 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class CourseLearning extends Model { protected $table = 'course_learning'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } ProductFilter.php 0000644 00000001536 15102516312 0010044 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class ProductFilter extends Model implements TranslatableContract { use Translatable; protected $table = 'product_filters'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function category() { return $this->belongsTo('App\Models\ProductCategory', 'category_id', 'id'); } public function options() { return $this->hasMany('App\Models\ProductFilterOption', 'filter_id', 'id')->orderBy('order', 'asc'); } } InstallmentOrderAttachment.php 0000644 00000000553 15102516312 0012553 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class InstallmentOrderAttachment extends Model { protected $table = 'installment_order_attachments'; public $timestamps = false; protected $guarded = ['id']; } Role.php 0000644 00000003066 15102516312 0006157 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Role extends Model { public $timestamps = false; static $admin = 'admin'; static $user = 'user'; static $teacher = 'teacher'; static $organization = 'organization'; protected $guarded = ['id']; public function canDelete() { switch ($this->name) { case self::$admin: case self::$user: case self::$organization: case self::$teacher: return false; break; default: return true; } } public function users() { return $this->hasMany('App\User', 'role_id', 'id'); } public function isDefaultRole() { return in_array($this->name, [self::$admin, self::$user, self::$organization, self::$teacher]); } public function isMainAdminRole() { return $this->name == self::$admin; } public static function getUserRoleId() { $id = 1; // user role id $role = self::where('name', self::$user)->first(); return !empty($role) ? $role->id : $id; } public static function getTeacherRoleId() { $id = 4; // teacher role id $role = self::where('name', self::$teacher)->first(); return !empty($role) ? $role->id : $id; } public static function getOrganizationRoleId() { $id = 3; // teacher role id $role = self::where('name', self::$organization)->first(); return !empty($role) ? $role->id : $id; } } QuizzesQuestionsAnswer.php 0000644 00000001067 15102516312 0012022 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class QuizzesQuestionsAnswer extends Model implements TranslatableContract { use Translatable; protected $table = 'quizzes_questions_answers'; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } } ForumTopicPost.php 0000644 00000002643 15102516312 0010213 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ForumTopicPost extends Model { protected $table = 'forum_topic_posts'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function topic() { return $this->belongsTo('App\Models\ForumTopic', 'topic_id', 'id'); } public function likes() { return $this->hasMany('App\Models\ForumTopicLike', 'topic_post_id', 'id'); } public function parent() { return $this->belongsTo('App\Models\ForumTopicPost', 'parent_id', 'id'); } public function getLikeUrl($forumSlug, $topicSlug) { return "/forums/{$forumSlug}/topics/{$topicSlug}/posts/{$this->id}/likeToggle"; } public function getEditUrl($forumSlug, $topicSlug) { return "/forums/{$forumSlug}/topics/{$topicSlug}/posts/{$this->id}/edit"; } public function getAttachmentUrl($forumSlug, $topicSlug) { return "/forums/{$forumSlug}/topics/{$topicSlug}/posts/{$this->id}/downloadAttachment"; } public function getAttachmentName() { $name = ""; if (!empty($this->attach)) { $attach = explode('/',$this->attach); $name = $attach[array_key_last($attach)]; } return $name; } } Region.php 0000644 00000003502 15102516312 0006474 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Region extends Model { protected $table = 'regions'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $country = 'country'; static $province = 'province'; static $city = 'city'; static $district = 'district'; static $types = [ 'country', 'province', 'city', 'district', ]; public function country() { return $this->belongsTo($this, 'country_id', 'id')->where('type', self::$country); } public function countryProvinces() { return $this->hasMany($this, 'country_id', 'id')->where('type', self::$province); } public function countryCities() { return $this->hasMany($this, 'country_id', 'id')->where('type', self::$city); } public function provinceCities() { return $this->hasMany($this, 'province_id', 'id')->where('type', self::$city); } public function cityDistricts() { return $this->hasMany($this, 'city_id', 'id')->where('type', self::$district); } public function province() { return $this->belongsTo($this, 'province_id', 'id')->where('type', self::$province); } public function city() { return $this->belongsTo($this, 'city_id', 'id')->where('type', self::$city); } public function countryUsers() { return $this->hasMany('App\User', 'country_id', 'id'); } public function provinceUsers() { return $this->hasMany('App\User', 'province_id', 'id'); } public function cityUsers() { return $this->hasMany('App\User', 'city_id', 'id'); } public function districtUsers() { return $this->hasMany('App\User', 'district_id', 'id'); } } UpcomingCourseFilterOption.php 0000644 00000000364 15102516312 0012555 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UpcomingCourseFilterOption extends Model { protected $table = 'upcoming_course_filter_option'; public $timestamps = false; protected $guarded = ['id']; } Translation/SupportDepartmentTranslation.php 0000644 00000000444 15102516312 0015470 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class SupportDepartmentTranslation extends Model { protected $table = 'support_department_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/WebinarChapterTranslation.php 0000644 00000000436 15102516312 0014667 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class WebinarChapterTranslation extends Model { protected $table = 'webinar_chapter_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductSpecificationMultiValueTranslation.php 0000644 00000000500 15102516312 0020112 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductSpecificationMultiValueTranslation extends Model { protected $table = 'product_specification_multi_value_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/WebinarExtraDescriptionTranslation.php 0000644 00000000461 15102516312 0016566 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class WebinarExtraDescriptionTranslation extends Model { protected $table = 'webinar_extra_description_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/UpcomingCourseTranslation.php 0000644 00000000436 15102516312 0014733 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class UpcomingCourseTranslation extends Model { protected $table = 'upcoming_course_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/TextLessonTranslation.php 0000644 00000000426 15102516312 0014100 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class TextLessonTranslation extends Model { protected $table = 'text_lesson_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/QuizzesQuestionTranslation.php 0000644 00000000435 15102516312 0015172 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class QuizzesQuestionTranslation extends Model { protected $table = 'quiz_question_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/OfflineBankTranslation.php 0000644 00000000432 15102516312 0014143 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class OfflineBankTranslation extends Model { protected $table = 'offline_bank_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductTranslation.php 0000644 00000000417 15102516312 0013410 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductTranslation extends Model { protected $table = 'product_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/WebinarTranslation.php 0000644 00000000417 15102516312 0013357 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class WebinarTranslation extends Model { protected $table = 'webinar_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/CashbackRuleTranslation.php 0000644 00000000434 15102516312 0014316 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class CashbackRuleTranslation extends Model { protected $table = 'cashback_rule_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/WebinarAssignmentTranslation.php 0000644 00000000444 15102516312 0015410 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class WebinarAssignmentTranslation extends Model { protected $table = 'webinar_assignment_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/BadgeTranslation.php 0000644 00000000413 15102516312 0012766 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class BadgeTranslation extends Model { protected $table = 'badge_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/FileTranslation.php 0000644 00000000411 15102516312 0012641 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class FileTranslation extends Model { protected $table = 'file_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/AdvertisingBannerTranslation.php 0000644 00000000445 15102516312 0015376 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class AdvertisingBannerTranslation extends Model { protected $table = 'advertising_banners_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ForumTranslation.php 0000644 00000000413 15102516312 0013054 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ForumTranslation extends Model { protected $table = 'forum_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/RegistrationPackageTranslation.php 0000644 00000000451 15102516312 0015714 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class RegistrationPackageTranslation extends Model { protected $table = 'registration_packages_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/OfflineBankSpecificationTranslation.php 0000644 00000000465 15102516312 0016652 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class OfflineBankSpecificationTranslation extends Model { protected $table = 'offline_bank_specification_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/BundleTranslation.php 0000644 00000000415 15102516312 0013177 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class BundleTranslation extends Model { protected $table = 'bundle_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/TestimonialTranslation.php 0000644 00000000427 15102516312 0014261 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class TestimonialTranslation extends Model { protected $table = 'testimonial_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/InstallmentStepTranslation.php 0000644 00000000442 15102516312 0015114 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class InstallmentStepTranslation extends Model { protected $table = 'installment_step_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/TicketTranslation.php 0000644 00000000354 15102516312 0013213 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class TicketTranslation extends Model { public $timestamps = false; protected $table = 'ticket_translations'; protected $guarded = ['id']; } Translation/CertificateTemplateTranslation.php 0000644 00000000450 15102516312 0015703 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class CertificateTemplateTranslation extends Model { protected $table = 'certificate_template_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductFilterOptionTranslation.php 0000644 00000000451 15102516312 0015745 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductFilterOptionTranslation extends Model { protected $table = 'product_filter_option_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/FilterTranslation.php 0000644 00000000415 15102516312 0013213 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class FilterTranslation extends Model { protected $table = 'filter_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/FaqTranslation.php 0000644 00000000407 15102516312 0012476 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class FaqTranslation extends Model { protected $table = 'faq_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductSpecificationTranslation.php 0000644 00000000452 15102516312 0016110 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductSpecificationTranslation extends Model { protected $table = 'product_specification_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/HomePageStatisticTranslation.php 0000644 00000000447 15102516312 0015350 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class HomePageStatisticTranslation extends Model { protected $table = 'home_page_statistic_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/UserBankSpecificationTranslation.php 0000644 00000000457 15102516312 0016207 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class UserBankSpecificationTranslation extends Model { protected $table = 'user_bank_specification_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductFileTranslation.php 0000644 00000000430 15102516312 0014203 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductFileTranslation extends Model { protected $table = 'product_file_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/FloatingBarTranslation.php 0000644 00000000432 15102516312 0014155 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class FloatingBarTranslation extends Model { protected $table = 'floating_bar_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/UserBankTranslation.php 0000644 00000000424 15102516312 0013500 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class UserBankTranslation extends Model { protected $table = 'user_bank_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/NavbarButtonTranslation.php 0000644 00000000432 15102516312 0014372 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class NavbarButtonTranslation extends Model { protected $table = 'navbar_button_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductFilterTranslation.php 0000644 00000000434 15102516312 0014555 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductFilterTranslation extends Model { protected $table = 'product_filter_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/BlogTranslation.php 0000644 00000000413 15102516312 0012647 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class BlogTranslation extends Model { protected $table = 'blog_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/SessionTranslation.php 0000644 00000000417 15102516312 0013413 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class SessionTranslation extends Model { protected $table = 'session_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/FeatureWebinarTranslation.php 0000644 00000000436 15102516312 0014674 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class FeatureWebinarTranslation extends Model { protected $table = 'feature_webinar_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductFaqTranslation.php 0000644 00000000426 15102516312 0014040 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductFaqTranslation extends Model { protected $table = 'product_faq_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/InstallmentTranslation.php 0000644 00000000431 15102516312 0014256 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class InstallmentTranslation extends Model { protected $table = 'installment_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/FilterOptionTranslation.php 0000644 00000000432 15102516312 0014403 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class FilterOptionTranslation extends Model { protected $table = 'filter_option_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/SubscribeTranslation.php 0000644 00000000423 15102516312 0013706 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class SubscribeTranslation extends Model { protected $table = 'subscribe_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/PageTranslation.php 0000644 00000000411 15102516312 0012636 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class PageTranslation extends Model { protected $table = 'page_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/PromotionTranslation.php 0000644 00000000423 15102516312 0013753 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class PromotionTranslation extends Model { protected $table = 'promotion_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductSelectedSpecificationTranslation.php 0000644 00000000473 15102516312 0017564 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductSelectedSpecificationTranslation extends Model { protected $table = 'product_selected_specification_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/SettingTranslation.php 0000644 00000000417 15102516312 0013405 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class SettingTranslation extends Model { protected $table = 'setting_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/QuizTranslation.php 0000644 00000000411 15102516312 0012712 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class QuizTranslation extends Model { protected $table = 'quiz_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/ProductCategoryTranslation.php 0000644 00000000440 15102516312 0015102 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class ProductCategoryTranslation extends Model { protected $table = 'product_category_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/QuizzesQuestionsAnswerTranslation.php 0000644 00000000457 15102516312 0016541 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class QuizzesQuestionsAnswerTranslation extends Model { protected $table = 'quizzes_questions_answer_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Translation/error_log 0000644 00000001756 15102516312 0010764 0 ustar 00 [04-Nov-2025 21:35:12 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Translation/ProductSelectedSpecificationTranslation.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Translation/ProductSelectedSpecificationTranslation.php on line 7 [04-Nov-2025 21:58:00 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Translation/OfflineBankTranslation.php:8 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Translation/OfflineBankTranslation.php on line 8 [04-Nov-2025 22:02:57 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Translation/ProductFileTranslation.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Translation/ProductFileTranslation.php on line 7 Translation/CategoryTranslation.php 0000644 00000000421 15102516312 0013540 0 ustar 00 <?php namespace App\Models\Translation; use Illuminate\Database\Eloquent\Model; class CategoryTranslation extends Model { protected $table = 'category_translations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } SubscribeRemind.php 0000644 00000000334 15102516312 0010331 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class SubscribeRemind extends Model { protected $table = 'subscribe_reminds'; public $timestamps = false; protected $guarded = ['id']; } SpecialOffer.php 0000644 00000002212 15102516312 0007610 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class SpecialOffer extends Model { protected $table = 'special_offers'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public static $active = 'active'; public static $inactive = 'inactive'; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function subscribe() { return $this->belongsTo('App\Models\Subscribe', 'subscribe_id', 'id'); } public function registrationPackage() { return $this->belongsTo('App\Models\RegistrationPackage', 'registration_package_id', 'id'); } public function getRemainingTimes() { $current_time = time(); $date = $this->to_date; $difference = $date - $current_time; return time2string($difference); } } UserCookieSecurity.php 0000644 00000000514 15102516312 0011051 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UserCookieSecurity extends Model { protected $table = 'users_cookie_security'; public $timestamps = false; protected $guarded = ['id']; static $types = ['all', 'customize']; static $ALL = 'all'; static $CUSTOMIZE = 'customize'; } CourseNoticeboard.php 0000644 00000001765 15102516312 0010674 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class CourseNoticeboard extends Model { protected $table = 'course_noticeboards'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $colors = ['warning', 'danger', 'neutral', 'info', 'success']; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function noticeboardStatus() { return $this->hasOne('App\Models\CourseNoticeboardStatus', 'noticeboard_id', 'id'); } public function getIcon() { $icons = [ 'warning' => 'alert-triangle', 'danger' => 'alert-octagon', 'neutral' => 'shield', 'info' => 'message-square', 'success' => 'check-circle' ]; return $icons[$this->color]; } } NotificationTemplate.php 0000644 00000012642 15102516312 0011400 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class NotificationTemplate extends Model { protected $table = 'notification_templates'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $templateKeys = [ 'email' => '[u.email]', 'mobile' => '[u.mobile]', 'real_name' => '[u.name]', 'real_name_2' => '[u.name.2]', 'user_role' => '[u.role]', 'instructor_name' => '[instructor.name]', 'organization_name' => '[organization.name]', 'student_name' => '[student.name]', 'item_title' => '[item_title]', 'group_title' => '[u.g.title]', 'badge_title' => '[u.b.title]', 'course_title' => '[c.title]', 'quiz_title' => '[q.title]', 'quiz_result' => '[q.result]', 'support_ticket_title' => '[s.t.title]', 'contact_us_title' => '[c.u.title]', 'contact_us_message' => '[c.u.message]', 'time_and_date' => '[time.date]', 'time_and_date_2' => '[time.date.2]', 'link' => '[link]', 'rate_count' => '[rate.count]', 'amount' => '[amount]', 'payout_account' => '[payout.account]', 'financial_doc_desc' => '[f.d.description]', 'financial_doc_type' => '[f.d.type]', 'subscribe_plan_name' => '[s.p.name]', 'promotion_plan_name' => '[p.p.name]', 'product_title' => '[p.title]', 'assignment_grade' => '[assignment_grade]', 'topic_title' => '[topic_title]', 'forum_title' => '[forum_title]', 'blog_title' => '[blog_title]', 'installment_title' => '[installment_title]', 'gift_title' => '[gift_title]', 'gift_type' => '[gift_type]', 'gift_message' => '[gift_message]', 'content_type' => '[content_type]', 'points' => '[points]', ]; static $notificationTemplateAssignSetting = [ 'admin' => ['new_comment_admin', 'support_message_admin', 'support_message_replied_admin', 'promotion_plan_admin', 'payout_request_admin', 'new_registration', 'new_become_instructor_request', 'new_course_enrollment', 'new_forum_topic', 'new_report_item_for_admin', 'new_item_created', 'new_store_order', 'subscription_plan_activated', 'content_review_request', 'new_user_blog_post', 'new_user_item_rating', 'new_organization_user', 'user_wallet_charge', 'new_user_payout_request', 'new_offline_payment_request' ], 'user' => ['new_badge', 'change_user_group', 'user_access_to_content', 'new_referral_user', 'user_role_change', 'add_to_user_group', 'become_instructor_request_approved', 'become_instructor_request_rejected'], 'course' => ['course_created', 'course_approve', 'course_reject', 'new_comment', 'support_message', 'support_message_replied', 'new_rating', 'new_question_in_forum', 'new_answer_in_forum'], 'financial' => ['new_financial_document', 'payout_request', 'payout_proceed', 'offline_payment_request', 'offline_payment_approved', 'offline_payment_rejected', 'user_get_cashback', 'user_get_cashback_notification_for_admin'], 'sale_purchase' => ['new_sales', 'new_purchase'], 'plans' => ['new_subscribe_plan', 'promotion_plan'], 'appointment' => ['new_appointment', 'new_appointment_link', 'appointment_reminder', 'meeting_finished', 'new_appointment_session'], 'quiz' => ['new_certificate', 'waiting_quiz', 'waiting_quiz_result', 'new_quiz'], 'store' => ['product_new_sale', 'product_new_purchase', 'product_new_comment', 'product_tracking_code', 'product_new_rating', 'product_receive_shipment', 'product_out_of_stock'], 'assignment' => ['student_send_message', 'instructor_send_message', 'instructor_set_grade'], 'topic' => ['send_post_in_topic'], 'blog' => ['publish_instructor_blog_post', 'new_comment_for_instructor_blog_post'], 'reminders' => ['webinar_reminder', 'meeting_reserve_reminder', 'subscribe_reminder'], 'installments' => ['reminder_installments_before_overdue', 'installment_due_reminder', 'reminder_installments_after_overdue', 'approve_installment_verification_request', 'reject_installment_verification_request', 'paid_installment_step', 'paid_installment_step_for_admin', 'paid_installment_upfront', 'installment_verification_request_sent', 'admin_installment_verification_request_sent', 'instalment_request_submitted', 'instalment_request_submitted_for_admin'], 'gifts' => ['reminder_gift_to_receipt', "gift_sender_confirmation", 'gift_sender_notification', 'admin_gift_submission', 'admin_gift_sending_confirmation'], 'upcoming' => ['upcoming_course_submission', 'upcoming_course_submission_for_admin', 'upcoming_course_approved', 'upcoming_course_rejected', 'upcoming_course_published', 'upcoming_course_followed', 'upcoming_course_published_for_followers'], 'bundles' => ['bundle_submission', 'bundle_submission_for_admin', 'bundle_approved', 'bundle_rejected', 'new_review_for_bundle'], 'registration_bonus' => ['registration_bonus_achieved', 'registration_bonus_unlocked', 'registration_bonus_unlocked_for_admin'], 'registration_package' => ['registration_package_activated', 'registration_package_activated_for_admin', 'registration_package_expired'], 'misc' => ['contact_message_submission', 'contact_message_submission_for_admin', 'waitlist_submission', 'waitlist_submission_for_admin', 'user_get_new_point', 'new_course_notice'], ]; } UserBankSpecification.php 0000644 00000001063 15102516312 0011464 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class UserBankSpecification extends Model implements TranslatableContract { use Translatable; protected $table = "user_bank_specifications"; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['name']; public function getNameAttribute() { return getTranslateAttributeValue($this, 'name'); } } InstallmentUserGroup.php 0000644 00000000537 15102516312 0011424 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class InstallmentUserGroup extends Model { protected $table = 'installment_user_groups'; public $timestamps = false; protected $guarded = ['id']; } DiscountCategory.php 0000644 00000000722 15102516312 0010540 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class DiscountCategory extends Model { protected $table = 'discount_categories'; public $timestamps = false; protected $guarded = ['id']; public function discount() { return $this->belongsTo('App\Models\Discount', 'discount_id', 'id'); } public function category() { return $this->belongsTo('App\Models\Category', 'category_id', 'id'); } } RewardAccounting.php 0000644 00000005662 15102516312 0010521 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class RewardAccounting extends Model { protected $table = 'rewards_accounting'; public $timestamps = false; protected $guarded = ['id']; const ADDICTION = 'addiction'; const DEDUCTION = 'deduction'; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public static function makeRewardAccounting($userId, $score, $type, $itemId = null, $checkDuplicate = false, $status = self::ADDICTION) { $rewardsSettings = getRewardsSettings(); if ($score and $score > 0 and !empty($rewardsSettings) and !empty($rewardsSettings['status'])) { $create = true; if ($checkDuplicate) { $check = self::where('user_id', $userId) ->where('item_id', $itemId) ->where('type', $type) ->where('status', $status) ->first(); $create = empty($check); } if ($create) { self::createAccounting($userId, $itemId, $type, $score, $status); } } return true; } private static function createAccounting($userId, $itemId, $type, $score, $status): bool { self::create([ 'user_id' => $userId, 'item_id' => $itemId ?? null, 'type' => $type, 'score' => $score, 'status' => $status, 'created_at' => time() ]); $notifyOptions = [ '[points]' => $score, '[item_title]' => trans('update.reward_type_' . $type), '[time.date]' => dateTimeFormat(time(), 'j M Y H:i') ]; sendNotification("user_get_new_point", $notifyOptions, $userId); return true; } public static function calculateScore($type, $extra = null) { $score = 0; $reward = Reward::where('type', $type)->first(); if (!empty($reward)) { switch ($reward->type) { case Reward::BUY: case Reward::ACCOUNT_CHARGE: case Reward::BUY_STORE_PRODUCT: if (!empty($extra)) { // for this type $extra is amount $score = $reward->score * ($extra / $reward->condition); } break; case Reward::CHARGE_WALLET: if (!empty($extra) and $extra > $reward->condition) { // for this type $extra is total_amount $score = $reward->score; } break; case Reward::BADGE: if (!empty($extra)) { $score = $extra; // for this type $extra is $badge->score } break; default: $score = $reward->score; } } return $score; } } Permission.php 0000644 00000000531 15102516312 0007400 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Permission extends Model { public $timestamps = false; protected $guarded = ['id']; /** * Get the sections for the permission. */ public function sections() { return $this->belongsTo('App\Models\Section', 'section_id'); } } UpcomingCourseFollower.php 0000644 00000000523 15102516312 0011725 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UpcomingCourseFollower extends Model { protected $table = 'upcoming_course_followers'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } Accounting.php 0000644 00000071066 15102516312 0007355 0 ustar 00 <?php namespace App\Models; use App\Mixins\Cashback\CashbackRules; use App\User; use Illuminate\Database\Eloquent\Model; class Accounting extends Model { protected $table = "accounting"; public static $addiction = 'addiction'; public static $deduction = 'deduction'; public static $asset = 'asset'; public static $income = 'income'; public static $subscribe = 'subscribe'; public static $promotion = 'promotion'; public static $storeManual = 'manual'; public static $storeAutomatic = 'automatic'; public static $registrationPackage = 'registration_package'; public static $installmentPayment = 'installment_payment'; public $timestamps = false; protected $guarded = ['id']; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function promotion() { return $this->belongsTo('App\Models\Promotion', 'promotion_id', 'id'); } public function registrationPackage() { return $this->belongsTo('App\Models\RegistrationPackage', 'registration_package_id', 'id'); } public function subscribe() { return $this->belongsTo('App\Models\Subscribe', 'subscribe_id', 'id'); } public function meetingTime() { return $this->belongsTo('App\Models\MeetingTime', 'meeting_time_id', 'id'); } public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function orderItem() { return $this->belongsTo('App\Models\OrderItem', 'order_item_id', 'id'); } public function installmentOrderPayment() { return $this->belongsTo('App\Models\InstallmentOrderPayment', 'installment_payment_id', 'id'); } public function gift() { return $this->belongsTo(Gift::class, 'gift_id', 'id'); } public static function createAccounting($orderItem, $type = null) { self::createAccountingBuyer($orderItem, $type); if ($orderItem->tax_price and $orderItem->tax_price > 0) { self::createAccountingTax($orderItem); } self::createAccountingSeller($orderItem); if ($orderItem->commission_price) { self::createAccountingCommission($orderItem); } } public static function createAccountingBuyer($orderItem, $type = null) { if ($type !== 'credit') { Accounting::create([ 'user_id' => $orderItem->user_id, 'order_item_id' => $orderItem->id, 'amount' => $orderItem->total_amount, 'webinar_id' => !empty($orderItem->webinar_id) ? $orderItem->webinar_id : null, 'bundle_id' => !empty($orderItem->bundle_id) ? $orderItem->bundle_id : null, 'meeting_time_id' => $orderItem->reserveMeeting ? $orderItem->reserveMeeting->meeting_time_id : null, 'subscribe_id' => $orderItem->subscribe_id ?? null, 'promotion_id' => $orderItem->promotion_id ?? null, 'registration_package_id' => $orderItem->registration_package_id ?? null, 'installment_payment_id' => $orderItem->installment_payment_id ?? null, 'product_id' => $orderItem->product_id ?? null, 'gift_id' => $orderItem->gift_id ?? null, 'type' => Accounting::$addiction, 'type_account' => Accounting::$asset, 'description' => trans('public.paid_for_sale'), 'created_at' => time() ]); } $deductionDescription = trans('public.paid_form_online_payment'); if (!empty($orderItem->reserveMeeting)) { $time = $orderItem->reserveMeeting->meetingTime->time; $explodeTime = explode('-', $time); $minute = (strtotime($explodeTime[1]) - strtotime($explodeTime[0])) / 60; $deductionDescription = trans('meeting.paid_for_x_hour', ['hours' => convertMinutesToHourAndMinute($minute)]); } elseif ($type == 'credit') { $deductionDescription = trans('public.paid_form_credit'); } Accounting::create([ 'user_id' => $orderItem->user_id, 'order_item_id' => $orderItem->id, 'amount' => $orderItem->total_amount, 'webinar_id' => !empty($orderItem->webinar_id) ? $orderItem->webinar_id : null, 'bundle_id' => !empty($orderItem->bundle_id) ? $orderItem->bundle_id : null, 'meeting_time_id' => $orderItem->reserveMeeting ? $orderItem->reserveMeeting->meeting_time_id : null, 'subscribe_id' => $orderItem->subscribe_id ?? null, 'promotion_id' => $orderItem->promotion_id ?? null, 'registration_package_id' => $orderItem->registration_package_id ?? null, 'installment_payment_id' => $orderItem->installment_payment_id ?? null, 'product_id' => $orderItem->product_id ?? null, 'gift_id' => $orderItem->gift_id ?? null, 'type' => Accounting::$deduction, 'type_account' => Accounting::$asset, 'description' => $deductionDescription, 'created_at' => time() ]); $notifyOptions = [ '[f.d.type]' => Accounting::$deduction, '[amount]' => handlePrice($orderItem->total_amount, true, true, false, $orderItem->user), ]; if (!empty($orderItem->webinar_id)) { $notifyOptions['[c.title]'] = $orderItem->webinar->title; } elseif (!empty($orderItem->bundle_id)) { $notifyOptions['[c.title]'] = $orderItem->bundle->title; } elseif (!empty($orderItem->reserve_meeting_id)) { $notifyOptions['[c.title]'] = trans('meeting.reservation_appointment'); } elseif (!empty($orderItem->product_id)) { $notifyOptions['[c.title]'] = $orderItem->product->title; } elseif (!empty($orderItem->installment_payment_id)) { $notifyOptions['[c.title]'] = ($orderItem->installmentPayment->type == 'upfront') ? trans('update.installment_upfront') : trans('update.installment'); } else if (!empty($orderItem->subscribe_id)) { $notifyOptions['[c.title]'] = $orderItem->subscribe->title . ' ' . trans('financial.subscribe'); } else if (!empty($orderItem->promotion_id)) { $notifyOptions['[c.title]'] = $orderItem->promotion->title . ' ' . trans('panel.promotion'); } else if (!empty($orderItem->registration_package_id)) { $notifyOptions['[c.title]'] = $orderItem->registrationPackage->title . ' ' . trans('update.registration_package'); } if (!empty($orderItem->gift_id) and !empty($orderItem->gift)) { $notifyOptions['[c.title]'] .= ' (' . trans('update.a_gift_for_name_on_date_without_bold', ['name' => $orderItem->gift->name, 'date' => dateTimeFormat($orderItem->gift->date, 'j M Y H:i')]) . ')'; } sendNotification('new_financial_document', $notifyOptions, $orderItem->user_id); } public static function createAccountingTax($orderItem) { Accounting::create([ 'user_id' => $orderItem->user_id, 'order_item_id' => $orderItem->id, 'tax' => true, 'amount' => $orderItem->tax_price, 'webinar_id' => $orderItem->webinar_id, 'bundle_id' => $orderItem->bundle_id, 'meeting_time_id' => $orderItem->reserveMeeting ? $orderItem->reserveMeeting->meeting_time_id : null, 'subscribe_id' => $orderItem->subscribe_id ?? null, 'promotion_id' => $orderItem->promotion_id ?? null, 'registration_package_id' => $orderItem->registration_package_id ?? null, 'installment_payment_id' => $orderItem->installment_payment_id ?? null, 'product_id' => $orderItem->product_id ?? null, 'gift_id' => $orderItem->gift_id ?? null, 'type_account' => Accounting::$asset, 'type' => Accounting::$addiction, 'description' => trans('public.tax_get_form_buyer'), 'created_at' => time() ]); return true; } public static function createAccountingSeller($orderItem) { $sellerId = OrderItem::getSeller($orderItem); Accounting::create([ 'user_id' => $sellerId, 'order_item_id' => $orderItem->id, 'installment_order_id' => $orderItem->installment_order_id ?? null, 'amount' => $orderItem->total_amount - $orderItem->tax_price - $orderItem->commission_price, 'webinar_id' => $orderItem->webinar_id, 'bundle_id' => $orderItem->bundle_id, 'meeting_time_id' => $orderItem->reserveMeeting ? $orderItem->reserveMeeting->meeting_time_id : null, 'subscribe_id' => $orderItem->subscribe_id ?? null, 'promotion_id' => $orderItem->promotion_id ?? null, 'product_id' => $orderItem->product_id ?? null, 'type_account' => Accounting::$income, 'type' => Accounting::$addiction, 'description' => trans('public.income_sale'), 'created_at' => time() ]); return true; } public static function createAccountingSystemForSubscribe($orderItem) { $sellerId = OrderItem::getSeller($orderItem); Accounting::create([ 'user_id' => $sellerId, 'order_item_id' => $orderItem->id, 'system' => true, 'amount' => $orderItem->total_amount - $orderItem->tax_price, 'subscribe_id' => $orderItem->subscribe_id, 'type_account' => Accounting::$subscribe, 'type' => Accounting::$addiction, 'description' => trans('public.income_for_subscribe'), 'created_at' => time() ]); return true; } public static function createAccountingCommission($orderItem) { $authId = $orderItem->user_id; $sellerId = OrderItem::getSeller($orderItem); $commissionPrice = $orderItem->commission_price; $affiliateCommissionPrice = 0; $referralSettings = getReferralSettings(); $affiliateStatus = (!empty($referralSettings) and !empty($referralSettings['status'])); $affiliateUser = null; if ($affiliateStatus) { $affiliate = Affiliate::where('referred_user_id', $authId)->first(); if (!empty($affiliate)) { $affiliateUser = $affiliate->affiliateUser; if (!empty($affiliateUser) and $affiliateUser->affiliate) { if (!empty($affiliate)) { if (!empty($orderItem->product_id) and !empty($referralSettings['store_affiliate_user_commission']) and $referralSettings['store_affiliate_user_commission'] > 0) { $affiliateCommission = $referralSettings['store_affiliate_user_commission']; $commission = $affiliateUser->getCommission(); if ($commission > 0) { $affiliateCommissionPrice = ($affiliateCommission * $commissionPrice) / $commission; $commissionPrice = $commissionPrice - $affiliateCommissionPrice; } } elseif (empty($orderItem->product_id) and !empty($referralSettings['affiliate_user_commission']) and $referralSettings['affiliate_user_commission'] > 0) { $affiliateCommission = $referralSettings['affiliate_user_commission']; $commission = $affiliateUser->getCommission(); if ($commission > 0) { $affiliateCommissionPrice = ($affiliateCommission * $commissionPrice) / $commission; $commissionPrice = $commissionPrice - $affiliateCommissionPrice; } } } } } } Accounting::create([ 'user_id' => !empty($sellerId) ? $sellerId : 1, 'order_item_id' => $orderItem->id, 'system' => true, 'amount' => $commissionPrice, 'webinar_id' => $orderItem->webinar_id ?? null, 'bundle_id' => $orderItem->bundle_id ?? null, 'product_id' => $orderItem->product_id ?? null, 'meeting_time_id' => $orderItem->reserveMeeting ? $orderItem->reserveMeeting->meeting_time_id : null, 'subscribe_id' => $orderItem->subscribe_id ?? null, 'promotion_id' => $orderItem->promotion_id ?? null, 'type_account' => Accounting::$income, 'type' => Accounting::$addiction, 'description' => trans('public.get_commission_from_seller'), 'created_at' => time() ]); if (!empty($affiliateUser) and $affiliateCommissionPrice > 0) { Accounting::create([ 'user_id' => $affiliateUser->id, 'order_item_id' => $orderItem->id, 'system' => false, 'referred_user_id' => $authId, 'is_affiliate_commission' => true, 'amount' => $affiliateCommissionPrice, 'webinar_id' => $orderItem->webinar_id ?? null, 'bundle_id' => $orderItem->bundle_id ?? null, 'product_id' => $orderItem->product_id ?? null, 'meeting_time_id' => $orderItem->reserveMeeting ? $orderItem->reserveMeeting->meeting_time_id : null, 'subscribe_id' => null, 'promotion_id' => null, 'type_account' => Accounting::$income, 'type' => Accounting::$addiction, 'description' => trans('public.get_commission_from_referral'), 'created_at' => time() ]); } return true; } public static function createAffiliateUserAmountAccounting($userId, $referredUserId, $amount) { if ($amount) { Accounting::create([ 'user_id' => $userId, 'referred_user_id' => $referredUserId, 'is_affiliate_amount' => true, 'system' => false, 'amount' => $amount, 'webinar_id' => null, 'bundle_id' => null, 'meeting_time_id' => null, 'subscribe_id' => null, 'promotion_id' => null, 'type_account' => Accounting::$income, 'type' => Accounting::$addiction, 'description' => trans('public.get_amount_from_referral'), 'created_at' => time() ]); Accounting::create([ 'user_id' => $userId, 'referred_user_id' => $referredUserId, 'is_affiliate_amount' => true, 'system' => true, 'amount' => $amount, 'webinar_id' => null, 'bundle_id' => null, 'meeting_time_id' => null, 'subscribe_id' => null, 'promotion_id' => null, 'type_account' => Accounting::$income, 'type' => Accounting::$deduction, 'description' => trans('public.get_amount_from_referral'), 'created_at' => time() ]); } } public static function refundAccounting($sale, $productOrderId = null) { self::refundAccountingBuyer($sale); if ($sale->tax) { self::refundAccountingTax($sale); } self::refundAccountingSeller($sale); if ($sale->commission) { self::refundAccountingCommission($sale); } } public static function refundAccountingBuyer($sale) { Accounting::create([ 'user_id' => $sale->buyer_id, 'amount' => $sale->total_amount, 'webinar_id' => $sale->webinar_id, 'bundle_id' => $sale->bundle_id, 'meeting_time_id' => $sale->meeting_time_id, 'subscribe_id' => $sale->subscribe_id ?? null, 'promotion_id' => $sale->promotion_id ?? null, 'product_id' => !empty($sale->productOrder) ? $sale->productOrder->product_id : null, 'type' => Accounting::$addiction, 'type_account' => Accounting::$asset, 'description' => trans('public.refund_money_to_buyer'), 'created_at' => time() ]); return true; } public static function refundAccountingTax($sale) { if (!empty($sale->tax) and $sale->tax > 0) { Accounting::create([ 'tax' => true, 'amount' => $sale->tax, 'webinar_id' => $sale->webinar_id, 'bundle_id' => $sale->bundle_id, 'meeting_time_id' => $sale->meeting_time_id, 'subscribe_id' => $sale->subscribe_id ?? null, 'promotion_id' => $sale->promotion_id ?? null, 'product_id' => !empty($sale->productOrder) ? $sale->productOrder->product_id : null, 'type_account' => Accounting::$asset, 'type' => Accounting::$deduction, 'description' => trans('public.refund_tax'), 'created_at' => time() ]); } return true; } public static function refundAccountingCommission($sale) { if (!empty($sale->commission) and $sale->commission > 0) { Accounting::create([ 'system' => true, 'user_id' => $sale->seller_id, 'amount' => $sale->commission, 'webinar_id' => $sale->webinar_id, 'bundle_id' => $sale->bundle_id, 'meeting_time_id' => $sale->meeting_time_id, 'subscribe_id' => $sale->subscribe_id ?? null, 'promotion_id' => $sale->promotion_id ?? null, 'product_id' => !empty($sale->productOrder) ? $sale->productOrder->product_id : null, 'type_account' => Accounting::$income, 'type' => Accounting::$deduction, 'description' => trans('public.refund_commission'), 'created_at' => time() ]); } return true; } public static function refundAccountingSeller($sale) { $amount = $sale->total_amount; if (!empty($sale->tax) and $sale->tax > 0) { $amount = $amount - $sale->tax; } if (!empty($sale->commission) and $sale->commission > 0) { $amount = $amount - $sale->commission; } Accounting::create([ 'user_id' => $sale->seller_id, 'amount' => $amount, 'webinar_id' => $sale->webinar_id, 'bundle_id' => $sale->bundle_id, 'meeting_time_id' => $sale->meeting_time_id, 'subscribe_id' => $sale->subscribe_id ?? null, 'promotion_id' => $sale->promotion_id ?? null, 'product_id' => !empty($sale->productOrder) ? $sale->productOrder->product_id : null, 'type_account' => Accounting::$income, 'type' => Accounting::$deduction, 'description' => trans('public.refund_income'), 'created_at' => time() ]); return true; } public static function charge($order) { Accounting::create([ 'user_id' => $order->user_id, 'amount' => $order->total_amount, 'type_account' => Order::$asset, 'type' => Order::$addiction, 'description' => trans('public.charge_account'), 'created_at' => time() ]); $accountChargeReward = RewardAccounting::calculateScore(Reward::ACCOUNT_CHARGE, $order->total_amount); RewardAccounting::makeRewardAccounting($order->user_id, $accountChargeReward, Reward::ACCOUNT_CHARGE); $chargeWalletReward = RewardAccounting::calculateScore(Reward::CHARGE_WALLET, $order->total_amount); RewardAccounting::makeRewardAccounting($order->user_id, $chargeWalletReward, Reward::CHARGE_WALLET); $notifyOptions = [ '[u.name]' => $order->user->full_name, '[amount]' => handlePrice($order->total_amount), ]; sendNotification('user_wallet_charge', $notifyOptions, 1); return true; } public static function createAccountingForSubscribe($orderItem, $type = null) { self::createAccountingBuyer($orderItem, $type); if ($orderItem->tax_price and $orderItem->tax_price > 0) { self::createAccountingTax($orderItem); } self::createAccountingSystemForSubscribe($orderItem); $notifyOptions = [ '[u.name]' => $orderItem->user->full_name, '[s.p.name]' => $orderItem->subscribe->title, ]; sendNotification('new_subscribe_plan', $notifyOptions, $orderItem->user_id); } public static function createAccountingForPromotion($orderItem, $type = null) { self::createAccountingBuyer($orderItem, $type); if ($orderItem->tax_price and $orderItem->tax_price > 0) { self::createAccountingTax($orderItem); } self::createAccountingSystemForPromotion($orderItem); $notifyOptions = [ '[c.title]' => $orderItem->webinar->title, '[p.p.name]' => $orderItem->promotion->title, ]; sendNotification('promotion_plan', $notifyOptions, $orderItem->user_id); } public static function createAccountingSystemForPromotion($orderItem) { Accounting::create([ 'user_id' => $orderItem->webinar_id ? $orderItem->webinar->creator_id : (!empty($orderItem->reserve_meeting_id) ? $orderItem->reserveMeeting->meeting->creator_id : 1), 'order_item_id' => $orderItem->id, 'system' => true, 'amount' => $orderItem->total_amount - $orderItem->tax_price, 'promotion_id' => $orderItem->promotion_id, 'type_account' => Accounting::$promotion, 'type' => Accounting::$addiction, 'description' => trans('public.income_for_promotion'), 'created_at' => time() ]); } public static function createAccountingForRegistrationPackage($orderItem, $type = null) { self::createAccountingBuyer($orderItem, $type); if ($orderItem->tax_price and $orderItem->tax_price > 0) { self::createAccountingTax($orderItem); } self::createAccountingSystemForRegistrationPackage($orderItem); $registrationPackage = $orderItem->registrationPackage; $registrationPackageExpire = time() + ($registrationPackage->days * 24 * 60 * 60); $notifyOptions = [ '[u.name]' => $orderItem->user->full_name, '[item_title]' => $registrationPackage->title, '[amount]' => handlePrice($orderItem->total_amount), '[time.date]' => dateTimeFormat($registrationPackageExpire, 'j M Y') ]; sendNotification("registration_package_activated", $notifyOptions, $orderItem->user_id); sendNotification("registration_package_activated_for_admin", $notifyOptions, 1); } public static function createAccountingSystemForRegistrationPackage($orderItem) { Accounting::create([ 'user_id' => 1, 'order_item_id' => $orderItem->id, 'system' => true, 'amount' => $orderItem->total_amount - $orderItem->tax_price, 'registration_package_id' => $orderItem->registration_package_id, 'type_account' => Accounting::$registrationPackage, 'type' => Accounting::$addiction, 'description' => trans('update.paid_for_registration_package'), 'created_at' => time() ]); } public static function createAccountingForSaleWithSubscribe($item, $subscribe, $itemName) { $admin = User::getAdmin(); $commission = $item->creator->getCommission(); $pricePerSubscribe = $subscribe->price / $subscribe->usable_count; $commissionPrice = $commission ? ($pricePerSubscribe * $commission / 100) : 0; $totalAmount = $pricePerSubscribe - $commissionPrice; Accounting::create([ 'user_id' => $item->creator_id, 'amount' => $totalAmount, $itemName => $item->id, 'type' => Accounting::$addiction, 'type_account' => Accounting::$income, 'description' => trans('public.paid_form_subscribe'), 'created_at' => time() ]); Accounting::create([ 'system' => true, 'user_id' => $admin->id, 'amount' => $totalAmount, $itemName => $item->id, 'type' => Accounting::$deduction, 'type_account' => Accounting::$asset, 'description' => trans('public.paid_form_subscribe'), 'created_at' => time() ]); } public static function refundAccountingForSaleWithSubscribe($webinar, $subscribe) { $admin = User::getAdmin(); $financialSettings = getFinancialSettings(); $commission = $financialSettings['commission'] ?? 0; $pricePerSubscribe = $subscribe->price / $subscribe->usable_count; $commissionPrice = $commission ? $pricePerSubscribe * $commission / 100 : 0; $totalAmount = $pricePerSubscribe - $commissionPrice; Accounting::create([ 'user_id' => $webinar->creator_id, 'amount' => $totalAmount, 'webinar_id' => $webinar->id, 'type' => Accounting::$deduction, 'type_account' => Accounting::$income, 'description' => trans('public.paid_form_subscribe'), 'created_at' => time() ]); Accounting::create([ 'system' => true, 'user_id' => $admin->id, 'amount' => $totalAmount, 'webinar_id' => $webinar->id, 'type' => Accounting::$addiction, 'type_account' => Accounting::$asset, 'description' => trans('public.paid_form_subscribe'), 'created_at' => time() ]); } public static function createAccountingForInstallmentPayment($orderItem, $type = null) { self::createAccountingBuyer($orderItem, $type); if ($orderItem->tax_price and $orderItem->tax_price > 0) { self::createAccountingTax($orderItem); } self::createAccountingSystemForInstallmentPayment($orderItem); } public static function createAccountingSystemForInstallmentPayment($orderItem) { Accounting::create([ 'user_id' => 1, 'order_item_id' => $orderItem->id, 'system' => true, 'amount' => $orderItem->total_amount - $orderItem->tax_price, 'installment_payment_id' => $orderItem->installment_payment_id, 'type_account' => Accounting::$installmentPayment, 'type' => Accounting::$addiction, 'description' => ($orderItem->installmentPayment->type == 'upfront') ? trans('update.installment_upfront') : trans('update.installment'), 'created_at' => time() ]); } public static function createRegistrationBonusUserAmountAccounting($userId, $amount, $typeAccount) { $check = Accounting::query()->where('user_id', $userId) ->where('is_registration_bonus', true) ->first(); if (!empty($amount) and empty($check)) { // Accounting::updateOrCreate([ 'user_id' => $userId, 'is_registration_bonus' => true, 'system' => false, 'type_account' => $typeAccount, 'type' => Accounting::$addiction, ], [ 'amount' => $amount, 'description' => trans('update.get_amount_from_registration_bonus'), 'created_at' => time() ]); Accounting::updateOrCreate([ 'user_id' => $userId, 'is_registration_bonus' => true, 'system' => true, 'type_account' => Accounting::$income, 'type' => Accounting::$deduction, ], [ 'amount' => $amount, 'description' => trans('update.get_amount_from_registration_bonus'), 'created_at' => time() ]); $notifyOptions = [ '[amount]' => handlePrice($amount), ]; sendNotification("registration_bonus_achieved", $notifyOptions, $userId); } } } AgoraHistory.php 0000644 00000000554 15102516312 0007670 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class AgoraHistory extends Model { protected $table = 'agora_history'; public $timestamps = false; protected $dateFormat = "U"; protected $guarded = ['id']; public function session() { return $this->belongsTo('App\Models\Session', 'session_id', 'id'); } } SubscribeUse.php 0000644 00000001160 15102516312 0007645 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class SubscribeUse extends Model { protected $table = 'subscribe_uses'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function subscribe() { return $this->belongsTo('App\Models\Subscribe', 'subscribe_id', 'id'); } public function sale() { return $this->hasOne('App\Models\Sale', 'id', 'sale_id'); } public function installmentOrder() { return $this->belongsTo('App\Models\InstallmentOrder', 'installment_order_id', 'id'); } } Cart.php 0000644 00000006012 15102516312 0006141 0 ustar 00 <?php namespace App\Models; use App\Mixins\Cart\CartItemInfo; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; class Cart extends Model { protected $table = "cart"; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } public function reserveMeeting() { return $this->belongsTo('App\Models\ReserveMeeting', 'reserve_meeting_id', 'id'); } public function ticket() { return $this->belongsTo('App\Models\Ticket', 'ticket_id', 'id'); } public function productOrder() { return $this->belongsTo('App\Models\ProductOrder', 'product_order_id', 'id'); } public function subscribe() { return $this->belongsTo('App\Models\Subscribe', 'subscribe_id', 'id'); } public function promotion() { return $this->belongsTo('App\Models\Promotion', 'promotion_id', 'id'); } public function installmentPayment() { return $this->belongsTo(InstallmentOrderPayment::class, 'installment_payment_id', 'id'); } public function gift() { return $this->belongsTo(Gift::class, 'gift_id', 'id'); } public static function emptyCart($userId) { Cart::where('creator_id', $userId)->delete(); } public static function getCartsTotalPrice($carts) { $totalPrice = 0; if (!empty($carts) and count($carts)) { foreach ($carts as $cart) { if ((!empty($cart->ticket_id) or !empty($cart->special_offer_id)) and !empty($cart->webinar)) { $totalPrice += $cart->webinar->price - $cart->webinar->getDiscount($cart->ticket); } else if (!empty($cart->webinar_id) and !empty($cart->webinar)) { $totalPrice += $cart->webinar->price; } else if (!empty($cart->bundle_id) and !empty($cart->bundle)) { $totalPrice += $cart->bundle->price; } else if (!empty($cart->reserve_meeting_id) and !empty($cart->reserveMeeting)) { $totalPrice += $cart->reserveMeeting->paid_amount; } else if (!empty($cart->product_order_id) and !empty($cart->productOrder) and !empty($cart->productOrder->product)) { $product = $cart->productOrder->product; $totalPrice += (($product->price * $cart->productOrder->quantity) - $product->getDiscountPrice()); } } } return $totalPrice; } public function getItemInfo() { if (empty($this->itemInfo)) { $cartItemInfo = new CartItemInfo(); $this->itemInfo = $cartItemInfo->getItemInfo($this); } return $this->itemInfo; } } DiscountUser.php 0000644 00000000666 15102516312 0007710 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class DiscountUser extends Model { protected $table = 'discount_users'; public $timestamps = false; protected $guarded = ['id']; public function discount() { return $this->belongsTo('App\Models\Discount', 'discount_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } WebinarReport.php 0000644 00000000725 15102516312 0010040 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class WebinarReport extends Model { protected $table = 'webinar_reports'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } } Purchase.php 0000644 00000000252 15102516312 0007022 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Purchase extends Model { public $timestamps = false; protected $guarded = ['id']; } Filter.php 0000644 00000001440 15102516312 0006475 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Filter extends Model implements TranslatableContract { use Translatable; protected $table = 'filters'; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function category() { return $this->belongsTo('App\Models\Category', 'category_id', 'id'); } public function options() { return $this->hasMany('App\Models\FilterOption', 'filter_id', 'id')->orderBy('order', 'asc'); } } Tag.php 0000644 00000000245 15102516312 0005765 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Tag extends Model { public $timestamps = false; protected $guarded = ['id']; } WebinarPartnerTeacher.php 0000644 00000000703 15102516312 0011470 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class WebinarPartnerTeacher extends Model { protected $table = 'webinar_partner_teacher'; public $timestamps = false; protected $guarded = ['id']; public function teacher() { return $this->belongsTo('App\User', 'teacher_id', 'id'); } public function webinar() { return $this->belongsTo('App\User', 'webinar_id', 'id'); } } ForumTopicAttachment.php 0000644 00000001220 15102516312 0011344 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ForumTopicAttachment extends Model { protected $table = 'forum_topic_attachments'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function getDownloadUrl($forumSlug, $topicSlug) { return "/forums/{$forumSlug}/topics/{$topicSlug}/downloadAttachment/{$this->id}"; } public function getName() { $name = ""; if (!empty($this->path)) { $path = explode('/',$this->path); $name = $path[array_key_last($path)]; } return $name; } } Prerequisite.php 0000644 00000000465 15102516312 0007737 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Prerequisite extends Model { public $timestamps = false; protected $guarded = ['id']; public function prerequisiteWebinar() { return $this->belongsTo('App\Models\Webinar', 'prerequisite_id', 'id'); } } UserOccupation.php 0000644 00000000733 15102516312 0010217 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UserOccupation extends Model { protected $table = 'users_occupations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function category() { return $this->belongsTo('App\Models\Category', 'category_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } WebinarFilterOption.php 0000644 00000000345 15102516312 0011201 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class WebinarFilterOption extends Model { protected $table = 'webinar_filter_option'; public $timestamps = false; protected $guarded = ['id']; } Group.php 0000644 00000001044 15102516312 0006344 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Group extends Model { public $timestamps = false; protected $guarded = ['id']; public function groupUsers() { return $this->hasMany('App\Models\GroupUser', 'group_id', 'id'); } public function users() { return $this->hasMany('App\Models\GroupUser', 'id', 'group_id'); } public function groupRegistrationPackage() { return $this->hasOne('App\Models\GroupRegistrationPackage', 'group_id', 'id'); } } QuizzesResult.php 0000644 00000002243 15102516312 0010123 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class QuizzesResult extends Model { static $passed = 'passed'; static $failed = 'failed'; static $waiting = 'waiting'; public $timestamps = false; protected $guarded = ['id']; public function quiz() { return $this->belongsTo('App\Models\Quiz', 'quiz_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function getQuestions() { $quiz = $this->quiz; if ($quiz->display_limited_questions and !empty($quiz->display_number_of_questions)) { $results = json_decode($this->results, true); $quizQuestionIds = []; if (!empty($results)) { foreach ($results as $id => $v) { if (is_numeric($id)) { $quizQuestionIds[] = $id; } } } $quizQuestions = $quiz->quizQuestions()->whereIn('id',$quizQuestionIds)->get(); } else { $quizQuestions = $quiz->quizQuestions; } return $quizQuestions; } } SupportDepartment.php 0000644 00000001306 15102516312 0010751 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class SupportDepartment extends Model implements TranslatableContract { use Translatable; protected $table = 'support_departments'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function supports() { return $this->hasMany('App\Models\Support', 'department_id', 'id'); } } UpcomingCourseReport.php 0000644 00000000772 15102516312 0011415 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UpcomingCourseReport extends Model { protected $table = 'upcoming_course_reports'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function upcomingCourse() { return $this->belongsTo('App\Models\UpcomingCourse', 'upcoming_course_id', 'id'); } } UserBadge.php 0000644 00000000575 15102516312 0007121 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UserBadge extends Model { // custom user badges protected $table = 'users_badges'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function badge() { return $this->belongsTo('App\Models\Badge', 'badge_id', 'id'); } } OrderItem.php 0000644 00000004522 15102516312 0007146 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class OrderItem extends Model { public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function order() { return $this->belongsTo('App\Models\Order', 'order_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } public function subscribe() { return $this->belongsTo('App\Models\Subscribe', 'subscribe_id', 'id'); } public function promotion() { return $this->belongsTo('App\Models\Promotion', 'promotion_id', 'id'); } public function reserveMeeting() { return $this->belongsTo('App\Models\ReserveMeeting', 'reserve_meeting_id', 'id'); } public function registrationPackage() { return $this->belongsTo('App\Models\RegistrationPackage', 'registration_package_id', 'id'); } public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function productOrder() { return $this->belongsTo('App\Models\ProductOrder', 'product_order_id', 'id'); } public function installmentPayment() { return $this->belongsTo(InstallmentOrderPayment::class, 'installment_payment_id', 'id'); } public function ticket() { return $this->belongsTo('App\Models\Ticket', 'ticket_id', 'id'); } public function gift() { return $this->belongsTo(Gift::class, 'gift_id', 'id'); } public static function getSeller($orderItem) { $seller = null; if (!empty($orderItem->webinar_id) and empty($orderItem->promotion_id)) { $seller = $orderItem->webinar->creator_id; } elseif (!empty($orderItem->reserve_meeting_id)) { $seller = $orderItem->reserveMeeting->meeting->creator_id; } elseif (!empty($orderItem->product_id)) { $seller = $orderItem->product->creator_id; } elseif (!empty($orderItem->bundle_id)) { $seller = $orderItem->bundle->creator_id; } return $seller; } } UserBank.php 0000644 00000001247 15102516312 0006767 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class UserBank extends Model implements TranslatableContract { use Translatable; protected $table = "user_banks"; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function specifications() { return $this->hasMany('App\Models\UserBankSpecification', 'user_bank_id', 'id'); } } BlogCategory.php 0000644 00000001402 15102516312 0007627 0 ustar 00 <?php namespace App\Models; use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Model; class BlogCategory extends Model { protected $table = 'blog_categories'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; use Sluggable; /** * Return the sluggable configuration array for this model. * * @return array */ public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public function blog() { return $this->hasMany('App\Models\Blog', 'category_id', 'id'); } public function getUrl() { return '/blog/categories/' . $this->slug; } } ProductSpecificationCategory.php 0000644 00000000631 15102516312 0013070 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ProductSpecificationCategory extends Model { protected $table = 'product_specification_categories'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function category() { return $this->belongsTo('App\Models\ProductCategory', 'category_id', 'id'); } } NavbarButton.php 0000644 00000001403 15102516312 0007654 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class NavbarButton extends Model implements TranslatableContract { use Translatable; protected $table = 'navbar_buttons'; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title', 'url']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getUrlAttribute() { return getTranslateAttributeValue($this, 'url'); } public function role() { return $this->belongsTo('App\Models\Role', 'role_id', 'id'); } } HomeSection.php 0000644 00000003527 15102516312 0007475 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class HomeSection extends Model { protected $table = 'home_sections'; public $timestamps = false; protected $guarded = ['id']; static $names = [ 'featured_classes', 'latest_bundles', 'latest_classes', 'best_rates', 'trend_categories', 'full_advertising_banner', 'best_sellers', 'discount_classes', 'free_classes', 'store_products', 'testimonials', 'subscribes', 'find_instructors', 'reward_program', 'become_instructor', 'forum_section', 'video_or_image_section', 'instructors', 'half_advertising_banner', 'organizations', 'blog', 'upcoming_courses', ]; static $featured_classes = 'featured_classes'; static $latest_bundles = 'latest_bundles'; static $latest_classes = 'latest_classes'; static $best_rates = 'best_rates'; static $trend_categories = 'trend_categories'; static $full_advertising_banner = 'full_advertising_banner'; static $best_sellers = 'best_sellers'; static $discount_classes = 'discount_classes'; static $free_classes = 'free_classes'; static $store_products = 'store_products'; static $testimonials = 'testimonials'; static $subscribes = 'subscribes'; static $find_instructors = 'find_instructors'; static $reward_program = 'reward_program'; static $become_instructor = 'become_instructor'; static $forum_section = 'forum_section'; static $video_or_image_section = 'video_or_image_section'; static $instructors = 'instructors'; static $half_advertising_banner = 'half_advertising_banner'; static $organizations = 'organizations'; static $blog = 'blog'; static $upcoming_courses = 'upcoming_courses'; } Forum.php 0000644 00000004661 15102516312 0006350 0 ustar 00 <?php namespace App\Models; use Cviebrock\EloquentSluggable\Services\SlugService; use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Forum extends Model implements TranslatableContract { use Translatable; use Sluggable; protected $table = 'forums'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public static function makeSlug($title) { return SlugService::createSlug(self::class, 'slug', $title); } public function parent() { return $this->belongsTo('App\Models\Forum', 'parent_id', 'id'); } public function subForums() { return $this->hasMany($this, 'parent_id', 'id')->orderBy('order', 'asc'); } public function topics() { return $this->hasMany('App\Models\ForumTopic', 'forum_id', 'id'); } public function getUrl() { return '/forums/' . $this->slug . '/topics'; } public function isClosed() { $close = $this->close; if (!$close and !empty($this->parent_id)) { $parent = $this->parent; if (!empty($parent)) { $close = $parent->close; } } return $close; } public function checkUserCanCreateTopic($user = null) { $result = true; if (empty($user)) { $user = auth()->user(); } if (!empty($this->group_id)) { $result = false; if (!empty($user)) { $userGroup = $user->userGroup; if (!empty($userGroup) and $userGroup->group_id == $this->group_id) { $result = true; } } } if (!empty($this->role_id) and $result) { $result = (!empty($user) and $this->role_id == $user->role_id); } return $result; } } WebinarReview.php 0000644 00000001242 15102516312 0010021 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class WebinarReview extends Model { protected $table = 'webinar_reviews'; public $timestamps = false; protected $guarded = ['id']; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Comment', 'review_id', 'id'); } } WebinarAssignmentAttachment.php 0000644 00000001233 15102516312 0012701 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class WebinarAssignmentAttachment extends Model { protected $table = 'webinar_assignment_attachments'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function getDownloadUrl() { return "/course/assignment/{$this->assignment_id}/download/{$this->id}/attach"; } public function getFileSize() { $size = null; $file_path = public_path($this->attach); if (file_exists($file_path)) { $size = formatSizeUnits(filesize($file_path)); } return $size; } } Comment.php 0000644 00000002325 15102516312 0006655 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Comment extends Model { protected $table = 'comments'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $pending = 'pending'; static $active = 'active'; public function replies() { return $this->hasMany('App\Models\Comment', 'reply_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function review() { return $this->belongsTo('App\Models\WebinarReview', 'review_id', 'id'); } public function blog() { return $this->belongsTo('App\Models\Blog', 'blog_id', 'id'); } public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function productReview() { return $this->belongsTo('App\Models\ProductReview', 'product_review_id', 'id'); } } Traits/SequenceContent.php 0000644 00000024523 15102516312 0011630 0 ustar 00 <?php namespace App\Models\Traits; use App\Models\QuizzesResult; use App\Models\Sale; use App\Models\WebinarAssignmentHistory; use App\Models\WebinarChapterItem; use App\Models\WebinarPartnerTeacher; trait SequenceContent { protected $test = false; public function checkSequenceContent($user = null, $test = false) { //$this->test = $test; // use for debug $user = $user ?: auth()->user(); $result = null; // null means user can access to this content if ($this->checkUserCanPass($this, $user)) { return $result; } if (getFeaturesSettings('sequence_content_status')) { $chapter = $this->chapter; if (!empty($chapter)) { $previousChapters = $chapter->getPreviousContents(); $result['all_passed_items_error'] = $this->checkChapterAllContentPassed($previousChapters); } if ($this->check_previous_parts and empty($result['all_passed_items_error'])) { $previousItems = $this->getPreviousContents(); $result['all_passed_items_error'] = $this->checkAllPassedItems($previousItems); } if (!empty($this->access_after_day)) { $result['access_after_day_error'] = $this->checkAccessAfterDay($user); } } return $result; } public function getPreviousContents() { if ($this->table == 'webinar_chapters') { $previousItems = $this->getPreviousChapters(); } else { $chapter = $this->chapter; $type = WebinarChapterItem::$chapterFile; if ($this->table == 'sessions') { $type = WebinarChapterItem::$chapterSession; } else if ($this->table == 'text_lessons') { $type = WebinarChapterItem::$chapterTextLesson; } else if ($this->table == 'quizzes') { $type = WebinarChapterItem::$chapterQuiz; } else if ($this->table == 'webinar_assignments') { $type = WebinarChapterItem::$chapterAssignment; } $currentItemOrder = WebinarChapterItem::where('user_id', $this->creator_id) ->where('item_id', $this->id) ->where('chapter_id', $this->chapter_id) ->where('type', $type) ->first(); $previousItems = $this->getPreviousItemsByChapter($chapter, !empty($currentItemOrder) ? $currentItemOrder->order : null); if (empty($previousItems) or count($previousItems) < 1) { $previousChapters = $chapter->getPreviousContents(); if (!empty($previousChapters) and count($previousChapters)) { $previousChapter = $previousChapters->first(); $previousItems = $this->getPreviousItemsByChapter($previousChapter); } } } return $previousItems; } private function checkChapterAllContentPassed($chapters) { $result = null; if (!empty($chapters) and count($chapters)) { foreach ($chapters as $chapter) { if ($chapter->check_all_contents_pass) { $chapterItems = $this->getPreviousItemsByChapter($chapter); $chapterResult = $this->checkAllPassedItems($chapterItems); if (!empty($chapterResult)) { $result = trans('update.you_should_pass_the_previous_chapter_to_view_this_chapter_parts');; } } } } return $result; } private function checkAccessAfterDay($user = null) { $result = null; $user = $user ?: auth()->user(); $day = $this->access_after_day; if (!empty($user)) { $sale = Sale::where('buyer_id', $user->id) ->where('webinar_id', $this->webinar_id) ->whereNull('refund_at') ->first(); if (!empty($sale)) { $conditionDay = strtotime("+$day days", $sale->created_at); if (time() < $conditionDay) { $result = trans('update.this_content_will_be_accessible_for_you_on_date', ['date' => dateTimeFormat($conditionDay, 'j M Y H:i')]); } } else { $result = trans('public.not_access_to_this_content'); } } else { $result = trans('public.not_login_toast_msg_lang'); } return $result; } private function checkAllPassedItems($chapterItems) { $userId = auth()->id(); $result = null; foreach ($chapterItems as $chapterItem) { if ($chapterItem->type == \App\Models\WebinarChapterItem::$chapterSession and !empty($chapterItem->session)) { $item = $chapterItem->session; } else if ($chapterItem->type == \App\Models\WebinarChapterItem::$chapterFile and !empty($chapterItem->file)) { $item = $chapterItem->file; } else if ($chapterItem->type == \App\Models\WebinarChapterItem::$chapterTextLesson and !empty($chapterItem->textLesson)) { $item = $chapterItem->textLesson; } else if ($chapterItem->type == \App\Models\WebinarChapterItem::$chapterAssignment) { $item = $chapterItem->assignment; } else if ($chapterItem->type == \App\Models\WebinarChapterItem::$chapterQuiz) { $item = $chapterItem->quiz; } // Only check previous content that has the check_previous_parts enabled => Vahid Daghighy if (!empty($item)) { if ($chapterItem->type == \App\Models\WebinarChapterItem::$chapterSession or $chapterItem->type == \App\Models\WebinarChapterItem::$chapterFile or $chapterItem->type == \App\Models\WebinarChapterItem::$chapterTextLesson ) { if (empty($item->learningStatus)) { $result = trans('update.you_should_pass_the_previous_lesson_to_view_this_part'); } } else if ($chapterItem->type == \App\Models\WebinarChapterItem::$chapterAssignment) { $assignmentHistory = WebinarAssignmentHistory::where('assignment_id', $item->id) ->where('student_id', $userId) ->where('status', WebinarAssignmentHistory::$passed) ->first(); if (empty($assignmentHistory)) { $result = trans('update.you_should_pass_the_previous_lesson_to_view_this_part'); } } else if ($chapterItem->type == \App\Models\WebinarChapterItem::$chapterQuiz) { $quizHistory = QuizzesResult::where('quiz_id', $item->id) ->where('user_id', $userId) ->where('status', QuizzesResult::$passed) ->first(); if (empty($quizHistory)) { $result = trans('update.you_should_pass_the_previous_lesson_to_view_this_part'); } } } } return $result; } private function getPreviousChapters() { $query = $this->newQuery(); $query->where('webinar_id', $this->webinar_id); $query->where('status', 'active'); if (!empty($this->order)) { $query->where(function ($query) { $query->whereNull('order') ->orWhere('order', '<', $this->order); }); } else { $query->whereNull('order'); $query->where('id', '<', $this->id); } $query->orderBy('order', 'desc'); $query->orderBy('id', 'desc'); return $query->get(); } private function getPreviousItemsByChapter($chapter, $currentItemOrder = null) { $query = $chapter->chapterItems(); if (!empty($currentItemOrder)) { $query->where('order', '<', $currentItemOrder); } return $query->orderBy('order', 'desc') ->get(); } /*private function getPreviousItems() { $currentItemOrder = WebinarChapterItem::where('user_id', $this->creator_id) ->where('item_id', $this->id) ->where('chapter_id', $this->chapter_id) ->first(); $webinar = Webinar::where('id', $this->webinar_id) ->where(function ($query) { $query->where('creator_id', $this->creator_id) ->orWhere('teacher_id', $this->creator_id); }) ->first(); if (!empty($webinar)) { $creatorIds = [$webinar->creator_id, $webinar->teacher_id]; $query = $this->newQuery(); $query->join('webinar_chapter_items', 'webinar_chapter_items.item_id', "{$this->table}.id"); $query->select("{$this->table}.*", DB::raw('webinar_chapter_items.order as itemOrder')); $query->where("{$this->table}.chapter_id", $this->chapter_id); $query->where("{$this->table}.webinar_id", $this->webinar_id); $query->whereIn("{$this->table}.creator_id", $creatorIds); $query->where("webinar_chapter_items.chapter_id", $this->chapter_id); $query->whereIn("webinar_chapter_items.user_id", $creatorIds); $query->where('status', 'active'); $query->where("{$this->table}.id", '!=', $this->id); if (!empty($currentItemOrder)) { $query->where("webinar_chapter_items.order", '<', $currentItemOrder->order); } $query->orderBy('itemOrder', 'desc'); return $query->get(); } return null; }*/ private function checkUserCanPass($item, $user = null) { if (empty($user)) { $user = auth()->user(); } if (!empty($user)) { $invitedWebinars = WebinarPartnerTeacher::query()->where('teacher_id', $user->id)->pluck('webinar_id')->toArray(); // Creator, Teacher, Admin and invited partners can pass if ( $user->id == $item->creator_id or $user->id == $item->teacher_id or $user->isAdmin() or in_array($item->webinar_id, $invitedWebinars) ) { return true; } } return false; } } GeoPoint.php 0000644 00000002466 15102516312 0007005 0 ustar 00 <?php namespace App\Models; class GeoPoint { public $latitude; public $longitude; /** * Point constructor. * @param $latitude * @param $longitude */ public function __construct($latitude = null, $longitude = null) { $this->latitude = $latitude; $this->longitude = $longitude; } public function parse($point) { if($point) { $location = str_replace('point', '', strtolower($point)); $location = ltrim($location, '('); $location = rtrim($location, ')'); $location = explode(' ', $location); $this->latitude = isset($location[0]) ? floatval($location[0]) : null; $this->longitude = isset($location[1]) ? floatval($location[1]) : null; } } public function toArray() { return [ 'latitude' => $this->latitude, 'longitude' => $this->longitude ]; } public function toJson() { return json_encode($this->toArray()); } public function isEmpty() { return (empty($this->latitude) || empty($this->longitude)); } public function __toString() { if($this->isEmpty()) { return ''; } return "POINT({$this->latitude} {$this->longitude})"; } } DiscountCourse.php 0000644 00000000710 15102516312 0010220 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class DiscountCourse extends Model { protected $table = 'discount_courses'; public $timestamps = false; protected $guarded = ['id']; public function discount() { return $this->belongsTo('App\Models\Discount', 'discount_id', 'id'); } public function course() { return $this->belongsTo('App\Models\Webinar', 'course_id', 'id'); } } OfflineBank.php 0000644 00000001263 15102516312 0007431 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class OfflineBank extends Model implements TranslatableContract { use Translatable; protected $table = "offline_banks"; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function specifications() { return $this->hasMany('App\Models\OfflineBankSpecification', 'offline_bank_id', 'id'); } } Meeting.php 0000644 00000001423 15102516312 0006641 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Meeting extends Model { public $timestamps = false; protected $guarded = ['id']; public function teacher() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function meetingTimes() { return $this->hasMany('App\Models\MeetingTime', 'meeting_id', 'id'); } public function getTimezone() { $timezone = getGeneralSettings('default_time_zone'); $user = $this->creator; if (!empty($user) and !empty($user->timezone)) { $timezone = $user->timezone; } return $timezone; } } SupportConversation.php 0000644 00000000740 15102516312 0011321 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class SupportConversation extends Model { protected $table = 'support_conversations'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function sender() { return $this->belongsTo('App\User', 'sender_id', 'id'); } public function supporter() { return $this->belongsTo('App\User', 'supporter_id', 'id'); } } ProductSpecificationMultiValue.php 0000644 00000001313 15102516312 0013400 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class ProductSpecificationMultiValue extends Model implements TranslatableContract { use Translatable; protected $table = 'product_specification_multi_values'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function createName() { return str_replace(' ', '_', $this->title); } } GroupRegistrationPackage.php 0000644 00000000421 15102516312 0012211 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class GroupRegistrationPackage extends Model { protected $table = 'groups_registration_packages'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Sale.php 0000644 00000026622 15102516312 0006145 0 ustar 00 <?php namespace App\Models; use App\Mixins\RegistrationBonus\RegistrationBonusAccounting; use Illuminate\Database\Eloquent\Model; class Sale extends Model { public static $webinar = 'webinar'; public static $meeting = 'meeting'; public static $subscribe = 'subscribe'; public static $promotion = 'promotion'; public static $registrationPackage = 'registration_package'; public static $product = 'product'; public static $bundle = 'bundle'; public static $gift = 'gift'; public static $installmentPayment = 'installment_payment'; public static $credit = 'credit'; public static $paymentChannel = 'payment_channel'; public $timestamps = false; protected $guarded = ['id']; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } public function buyer() { return $this->belongsTo('App\User', 'buyer_id', 'id'); } public function seller() { return $this->belongsTo('App\User', 'seller_id', 'id'); } public function meeting() { return $this->belongsTo('App\Models\Meeting', 'meeting_id', 'id'); } public function subscribe() { return $this->belongsTo('App\Models\Subscribe', 'subscribe_id', 'id'); } public function promotion() { return $this->belongsTo('App\Models\Promotion', 'promotion_id', 'id'); } public function registrationPackage() { return $this->belongsTo('App\Models\RegistrationPackage', 'registration_package_id', 'id'); } public function order() { return $this->belongsTo('App\Models\Order', 'order_id', 'id'); } public function ticket() { return $this->belongsTo('App\Models\Ticket', 'ticket_id', 'id'); } public function saleLog() { return $this->hasOne('App\Models\SaleLog', 'sale_id', 'id'); } public function productOrder() { return $this->belongsTo('App\Models\ProductOrder', 'product_order_id', 'id'); } public function gift() { return $this->belongsTo('App\Models\Gift', 'gift_id', 'id'); } public function installmentOrderPayment() { return $this->belongsTo('App\Models\InstallmentOrderPayment', 'installment_payment_id', 'id'); } public static function createSales($orderItem, $payment_method) { $orderType = Order::$webinar; if (!empty($orderItem->reserve_meeting_id)) { $orderType = Order::$meeting; } elseif (!empty($orderItem->subscribe_id)) { $orderType = Order::$subscribe; } elseif (!empty($orderItem->promotion_id)) { $orderType = Order::$promotion; } elseif (!empty($orderItem->registration_package_id)) { $orderType = Order::$registrationPackage; } elseif (!empty($orderItem->product_id)) { $orderType = Order::$product; } elseif (!empty($orderItem->bundle_id)) { $orderType = Order::$bundle; } elseif (!empty($orderItem->installment_payment_id)) { $orderType = Order::$installmentPayment; } if (!empty($orderItem->gift_id)) { $orderType = Order::$gift; } $seller_id = OrderItem::getSeller($orderItem); $sale = Sale::create([ 'buyer_id' => $orderItem->user_id, 'seller_id' => $seller_id, 'order_id' => $orderItem->order_id, 'webinar_id' => (empty($orderItem->gift_id) and !empty($orderItem->webinar_id)) ? $orderItem->webinar_id : null, 'bundle_id' => (empty($orderItem->gift_id) and !empty($orderItem->bundle_id)) ? $orderItem->bundle_id : null, 'meeting_id' => !empty($orderItem->reserve_meeting_id) ? $orderItem->reserveMeeting->meeting_id : null, 'meeting_time_id' => !empty($orderItem->reserveMeeting) ? $orderItem->reserveMeeting->meeting_time_id : null, 'subscribe_id' => $orderItem->subscribe_id, 'promotion_id' => $orderItem->promotion_id, 'registration_package_id' => $orderItem->registration_package_id, 'product_order_id' => (!empty($orderItem->product_order_id)) ? $orderItem->product_order_id : null, 'installment_payment_id' => $orderItem->installment_payment_id ?? null, 'gift_id' => $orderItem->gift_id ?? null, 'type' => $orderType, 'payment_method' => $payment_method, 'amount' => $orderItem->amount, 'tax' => $orderItem->tax_price, 'commission' => $orderItem->commission_price, 'discount' => $orderItem->discount, 'total_amount' => $orderItem->total_amount, 'product_delivery_fee' => $orderItem->product_delivery_fee, 'created_at' => time(), ]); self::handleSaleNotifications($orderItem, $seller_id); if (!empty($orderItem->product_id)) { $buyStoreReward = RewardAccounting::calculateScore(Reward::BUY_STORE_PRODUCT, $orderItem->total_amount); RewardAccounting::makeRewardAccounting($orderItem->user_id, $buyStoreReward, Reward::BUY_STORE_PRODUCT, $orderItem->product_id); } $buyReward = RewardAccounting::calculateScore(Reward::BUY, $orderItem->total_amount); RewardAccounting::makeRewardAccounting($orderItem->user_id, $buyReward, Reward::BUY); /* Registration Bonus Accounting */ $registrationBonusAccounting = new RegistrationBonusAccounting(); $registrationBonusAccounting->checkBonusAfterSale($orderItem->user_id); return $sale; } private static function handleSaleNotifications($orderItem, $seller_id) { $title = ''; if (!empty($orderItem->webinar_id)) { $title = $orderItem->webinar->title; } elseif (!empty($orderItem->bundle_id)) { $title = $orderItem->bundle->title; } else if (!empty($orderItem->meeting_id)) { $title = trans('meeting.reservation_appointment'); } else if (!empty($orderItem->subscribe_id)) { $title = $orderItem->subscribe->title . ' ' . trans('financial.subscribe'); } else if (!empty($orderItem->promotion_id)) { $title = $orderItem->promotion->title . ' ' . trans('panel.promotion'); } else if (!empty($orderItem->registration_package_id)) { $title = $orderItem->registrationPackage->title . ' ' . trans('update.registration_package'); } else if (!empty($orderItem->product_id)) { $title = $orderItem->product->title; } else if (!empty($orderItem->installment_payment_id)) { $title = ($orderItem->installmentPayment->type == 'upfront') ? trans('update.installment_upfront') : trans('update.installment'); } if (!empty($orderItem->gift_id) and !empty($orderItem->gift)) { $title .= ' (' . trans('update.a_gift_for_name_on_date_without_bold', ['name' => $orderItem->gift->name, 'date' => dateTimeFormat($orderItem->gift->date, 'j M Y H:i')]) . ')'; } if ($orderItem->reserve_meeting_id) { $reserveMeeting = $orderItem->reserveMeeting; $notifyOptions = [ '[amount]' => handlePrice($orderItem->amount), '[u.name]' => $orderItem->user->full_name, '[time.date]' => $reserveMeeting->day . ' ' . $reserveMeeting->time, ]; sendNotification('new_appointment', $notifyOptions, $orderItem->user_id); sendNotification('new_appointment', $notifyOptions, $reserveMeeting->meeting->creator_id); } elseif (!empty($orderItem->product_id)) { $notifyOptions = [ '[p.title]' => $title, '[amount]' => handlePrice($orderItem->total_amount), '[u.name]' => $orderItem->user->full_name, ]; sendNotification('product_new_sale', $notifyOptions, $seller_id); sendNotification('product_new_purchase', $notifyOptions, $orderItem->user_id); sendNotification('new_store_order', $notifyOptions, 1); } elseif (!empty($orderItem->installment_payment_id)) { // TODO:: installment notification } else { $notifyOptions = [ '[c.title]' => $title, ]; sendNotification('new_sales', $notifyOptions, $seller_id); sendNotification('new_purchase', $notifyOptions, $orderItem->user_id); } if (!empty($orderItem->webinar_id)) { $notifyOptions = [ '[u.name]' => $orderItem->user->full_name, '[c.title]' => $title, '[amount]' => handlePrice($orderItem->total_amount), '[time.date]' => dateTimeFormat(time(), 'j M Y H:i'), ]; sendNotification("new_course_enrollment", $notifyOptions, 1); } if (!empty($orderItem->subscribe_id)) { $notifyOptions = [ '[u.name]' => $orderItem->user->full_name, '[item_title]' => $orderItem->subscribe->title, '[amount]' => handlePrice($orderItem->total_amount), ]; sendNotification("subscription_plan_activated", $notifyOptions, 1); } } public function getIncomeItem() { if ($this->payment_method == self::$subscribe) { $used = SubscribeUse::where('webinar_id', $this->webinar_id) ->where('sale_id', $this->id) ->first(); if (!empty($used)) { $subscribe = $used->subscribe; $financialSettings = getFinancialSettings(); $commission = $financialSettings['commission'] ?? 0; $pricePerSubscribe = $subscribe->price / $subscribe->usable_count; $commissionPrice = $commission ? $pricePerSubscribe * $commission / 100 : 0; return round($pricePerSubscribe - $commissionPrice, 2); } } $income = $this->total_amount - $this->tax - $this->commission; return round($income, 2); } public function getUsedSubscribe($user_id, $itemId, $itemName = 'webinar_id') { $subscribe = null; $use = SubscribeUse::where('sale_id', $this->id) ->where($itemName, $itemId) ->where('user_id', $user_id) ->first(); if (!empty($use)) { $subscribe = Subscribe::where('id', $use->subscribe_id)->first(); if (!empty($subscribe)) { $subscribe->installment_order_id = $use->installment_order_id; } } return $subscribe; } public function checkExpiredPurchaseWithSubscribe($user_id, $itemId, $itemName = 'webinar_id') { $result = true; $subscribe = $this->getUsedSubscribe($user_id, $itemId, $itemName); if (!empty($subscribe)) { $subscribeSale = self::where('buyer_id', $user_id) ->where('type', self::$subscribe) ->where('subscribe_id', $subscribe->id) ->whereNull('refund_at') ->latest('created_at') ->first(); if (!empty($subscribeSale)) { $usedDays = (int)diffTimestampDay(time(), $subscribeSale->created_at); if ($usedDays <= $subscribe->days) { $result = false; } } } return $result; } } UpcomingCourse.php 0000644 00000010103 15102516312 0010206 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Cviebrock\EloquentSluggable\Services\SlugService; use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Model; use Jorenvh\Share\ShareFacade; use Spatie\CalendarLinks\Link; class UpcomingCourse extends Model implements TranslatableContract { use Translatable; use Sluggable; protected $table = "upcoming_courses"; public $timestamps = false; protected $guarded = ['id']; static $active = 'active'; static $pending = 'pending'; static $isDraft = 'is_draft'; static $inactive = 'inactive'; static $webinar = 'webinar'; static $course = 'course'; static $textLesson = 'text_lesson'; public $translatedAttributes = ['title', 'description', 'seo_description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function getSeoDescriptionAttribute() { return getTranslateAttributeValue($this, 'seo_description'); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function teacher() { return $this->belongsTo('App\User', 'teacher_id', 'id'); } public function category() { return $this->belongsTo('App\Models\Category', 'category_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function filterOptions() { return $this->hasMany('App\Models\UpcomingCourseFilterOption', 'upcoming_course_id', 'id'); } public function followers() { return $this->hasMany('App\Models\UpcomingCourseFollower', 'upcoming_course_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Comment', 'upcoming_course_id', 'id'); } public function tags() { return $this->hasMany('App\Models\Tag', 'upcoming_course_id', 'id'); } public function faqs() { return $this->hasMany('App\Models\Faq', 'upcoming_course_id', 'id'); } public function favorite() { return $this->hasMany('App\Models\Favorite', 'upcoming_course_id', 'id'); } public function extraDescriptions() { return $this->hasMany('App\Models\WebinarExtraDescription', 'upcoming_course_id', 'id'); } /** * Return the sluggable configuration array for this model. * * @return array */ public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public static function makeSlug($title) { return SlugService::createSlug(self::class, 'slug', $title); } public function canAccess($user = null) { if (!$user) { $user = auth()->user(); } if (!empty($user)) { return ($this->creator_id == $user->id or $this->teacher_id == $user->id); } return false; } public function getImageCover() { return $this->image_cover; } public function getImage() { return $this->thumbnail; } public function getUrl() { return url('/upcoming_courses/' . $this->slug); } public function addToCalendarLink() { $date = \DateTime::createFromFormat('j M Y H:i', dateTimeFormat($this->publish_date, 'j M Y H:i', false)); $link = Link::create($this->title, $date, $date); //->description('Cookies & cocktails!') return $link->google(); } public function getShareLink($social) { $link = ShareFacade::page($this->getUrl(), $this->title) ->facebook() ->twitter() ->whatsapp() ->telegram() ->getRawLinks(); return !empty($link[$social]) ? $link[$social] : ''; } } File.php 0000644 00000006124 15102516312 0006133 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use App\Models\Traits\SequenceContent; class File extends Model implements TranslatableContract { use Translatable; use SequenceContent; public $timestamps = false; protected $table = 'files'; protected $guarded = ['id']; static $accessibility = [ 'free', 'paid' ]; static $videoTypes = ['mp4', 'mkv', 'avi', 'mov', 'wmv', 'avchd', 'flv', 'f4v', 'swf', 'mpeg-2', 'webm', 'video']; static $fileTypes = [ 'pdf', 'powerpoint', 'sound', 'video', 'image', 'archive', 'document', 'project' ]; static $fileSources = [ 'upload', 'youtube', 'vimeo', 'external_link', 'google_drive', 'iframe', 's3', 'secure_host' ]; static $Active = 'active'; static $Inactive = 'inactive'; static $fileStatus = ['active', 'inactive']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function chapter() { return $this->belongsTo('App\Models\WebinarChapter', 'chapter_id', 'id'); } public function learningStatus() { return $this->hasOne('App\Models\CourseLearning', 'file_id', 'id'); } public function isVideo() { return (in_array($this->file_type, self::$videoTypes)); } public function getFileDuration() { $duration = 0; if ($this->storage == 'upload') { $file_path = public_path($this->file); $getID3 = new \getID3; $file = $getID3->analyze($file_path); if (!empty($file) and !empty($file['playtime_seconds'])) { $duration = $file['playtime_seconds']; } } return convertMinutesToHourAndMinute($duration); } public function getIconByType($type = null) { $icon = 'file'; if (empty($type)) { $type = $this->file_type; } if (!empty($type)) { if (in_array($type, ['pdf', 'powerpoint', 'document'])) { $icon = 'file-text'; } else if (in_array($type, ['sound'])) { $icon = 'volume-2'; } else if (in_array($type, ['video'])) { $icon = 'film'; } else if (in_array($type, ['image'])) { $icon = 'image'; } else if (in_array($type, ['archive'])) { $icon = 'archive'; } } return $icon; } public function getVolume() { return $this->volume . ' MB'; } public function checkPassedItem() { $result = false; if (auth()->check()) { $check = $this->learningStatus()->where('user_id', auth()->id())->count(); $result = ($check > 0); } return $result; } } OfflineBankSpecification.php 0000644 00000001071 15102516312 0012127 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class OfflineBankSpecification extends Model implements TranslatableContract { use Translatable; protected $table = "offline_bank_specifications"; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['name']; public function getNameAttribute() { return getTranslateAttributeValue($this, 'name'); } } BundleWebinar.php 0000644 00000000742 15102516312 0007775 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class BundleWebinar extends Model { protected $table = 'bundle_webinars'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } } CourseForum.php 0000644 00000001054 15102516312 0007522 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class CourseForum extends Model { protected $table = 'course_forums'; protected $guarded = ['id']; public $timestamps = false; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function answers() { return $this->hasMany('App\Models\CourseForumAnswer', 'forum_id', 'id'); } } Gift.php 0000644 00000010342 15102516312 0006142 0 ustar 00 <?php namespace App\Models; use App\Mixins\Cart\CartItemInfo; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; class Gift extends Model { protected $table = "gifts"; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function receipt() { return $this->belongsTo('App\User', 'email', 'email'); } public function sale() { return $this->hasOne('App\Models\Sale', 'gift_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function getItemTitle() { $title = ''; if (!empty($this->webinar_id)) { $title = $this->webinar->title; } else if (!empty($this->bundle_id)) { $title = $this->bundle->title; } else if (!empty($this->product_id)) { $title = $this->product->title; } return $title; } public function getItemType() { $type = 'course'; if (!empty($this->bundle_id)) { $type = 'bundle'; } else if (!empty($this->product_id)) { $type = 'product'; } return $type; } public function sendNotificationsWhenActivated($amount) { $this->sendReminderToRecipient($amount); $this->sendReminderToSender($amount); $this->sendReminderToAdmin($amount, 'admin_gift_submission'); } public function sendReminderToRecipient($amount) { if (empty($this->date) or $this->date < time()) { $receipt = $this->receipt; $notifyOptions = [ '[u.name]' => $this->user->full_name, '[gift_title]' => $this->getItemTitle(), '[gift_type]' => $this->getItemType(), '[amount]' => (!empty($amount) and $amount > 0) ? handlePrice($amount) : trans('public.free'), '[gift_message]' => $this->description, ]; if (!empty($receipt)) { sendNotification('reminder_gift_to_receipt', $notifyOptions, $receipt->id); } else if (!empty($this->email)) { sendNotificationToEmail('reminder_gift_to_receipt', $notifyOptions, $this->email); } } } public function sendReminderToSender($amount, $template = "gift_sender_confirmation") { $sender = $this->user; $notifyOptions = [ '[u.name]' => $this->name, '[u.email]' => $this->email, '[gift_title]' => $this->getItemTitle(), '[gift_type]' => $this->getItemType(), '[amount]' => (!empty($amount) and $amount > 0) ? handlePrice($amount) : trans('public.free'), '[gift_message]' => $this->description, '[time.date]' => dateTimeFormat($this->created_at, "j M Y H:i"), // send date '[time.date.2]' => !empty($this->date) ? dateTimeFormat($this->date, "j M Y H:i") : trans('update.instantly'), // gift publish date ]; if (!empty($sender)) { sendNotification($template, $notifyOptions, $sender->id); } } public function sendReminderToAdmin($amount, $template) { $sender = $this->user; $notifyOptions = [ '[u.name]' => $this->name, '[u.name.2]' => $sender->full_name, '[u.email]' => $this->email, '[gift_title]' => $this->getItemTitle(), '[gift_type]' => $this->getItemType(), '[amount]' => (!empty($amount) and $amount > 0) ? handlePrice($amount) : trans('public.free'), '[time.date]' => dateTimeFormat($this->created_at, "j M Y H:i"), // send date '[time.date.2]' => !empty($this->date) ? dateTimeFormat($this->date, "j M Y H:i") : trans('update.instantly'), // gift publish date ]; if (!empty($sender)) { sendNotification($template, $notifyOptions, 1); } } } MeetingTime.php 0000644 00000001366 15102516312 0007466 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class MeetingTime extends Model { public static $open = "open"; public static $finished = "finished"; public static $saturday = "saturday"; public static $sunday = "sunday"; public static $monday = "monday"; public static $tuesday = "tuesday"; public static $wednesday = "wednesday"; public static $thursday = "thursday"; public static $friday = "friday"; public static $days = ["saturday", "sunday", "monday", "tuesday", "wednesday", "thursday", "friday"]; public $timestamps = false; protected $guarded = ['id']; public function meeting() { return $this->belongsTo('App\Models\Meeting', 'meeting_id', 'id'); } } SaleLog.php 0000644 00000000355 15102516312 0006602 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class SaleLog extends Model { protected $table = 'sales_log'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } Contact.php 0000644 00000000354 15102516312 0006646 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Contact extends Model { protected $table = 'contacts'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } ProductSelectedFilterOption.php 0000644 00000000366 15102516312 0012706 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ProductSelectedFilterOption extends Model { protected $table = 'product_selected_filter_options'; public $timestamps = false; protected $guarded = ['id']; } Bundle.php 0000644 00000037435 15102516312 0006476 0 ustar 00 <?php namespace App\Models; use App\User; use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Cviebrock\EloquentSluggable\Services\SlugService; use Illuminate\Support\Facades\DB; use Jorenvh\Share\ShareFacade; class Bundle extends Model implements TranslatableContract { use Translatable; use Sluggable; protected $table = 'bundles'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $active = 'active'; static $pending = 'pending'; static $isDraft = 'is_draft'; static $inactive = 'inactive'; static $statuses = [ 'active', 'pending', 'is_draft', 'inactive' ]; static $videoDemoSource = ['upload', 'youtube', 'vimeo', 'external_link']; public $translatedAttributes = ['title', 'description', 'seo_description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function getSeoDescriptionAttribute() { return getTranslateAttributeValue($this, 'seo_description'); } public function getDurationAttribute() { return $this->getBundleDuration(); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function teacher() { return $this->belongsTo('App\User', 'teacher_id', 'id'); } public function category() { return $this->belongsTo('App\Models\Category', 'category_id', 'id'); } public function filterOptions() { return $this->hasMany('App\Models\BundleFilterOption', 'bundle_id', 'id'); } public function tags() { return $this->hasMany('App\Models\Tag', 'bundle_id', 'id'); } public function tickets() { return $this->hasMany('App\Models\Ticket', 'bundle_id', 'id'); } public function bundleWebinars() { return $this->hasMany('App\Models\BundleWebinar', 'bundle_id', 'id'); } public function faqs() { return $this->hasMany('App\Models\Faq', 'bundle_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Comment', 'bundle_id', 'id'); } public function reviews() { return $this->hasMany('App\Models\WebinarReview', 'bundle_id', 'id'); } public function sales() { return $this->hasMany('App\Models\Sale', 'bundle_id', 'id') ->whereNull('refund_at') ->where('type', 'bundle'); } /** * Return the sluggable configuration array for this model. * * @return array */ public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public static function makeSlug($title) { return SlugService::createSlug(self::class, 'slug', $title); } public function canAccess($user = null) { if (!$user) { $user = auth()->user(); } if (!empty($user)) { return ($this->creator_id == $user->id or $this->teacher_id == $user->id); } return false; } public function getUrl() { return url('/bundles/' . $this->slug); } public function getImageCover() { return config('app_url') . $this->image_cover; } public function getImage() { return config('app_url') . $this->thumbnail; } public function getRate() { $rate = 0; if (!empty($this->avg_rates)) { $rate = $this->avg_rates; } else { $reviews = $this->reviews() ->where('status', 'active') ->get(); if (!empty($reviews) and $reviews->count() > 0) { $rate = number_format($reviews->avg('rates'), 2); } } if ($rate > 5) { $rate = 5; } return $rate > 0 ? number_format($rate, 2) : 0; } public function bestTicket($with_percent = false) { $ticketPercent = 0; $bestTicket = $this->price; $activeSpecialOffer = $this->activeSpecialOffer(); if ($activeSpecialOffer) { $bestTicket = $this->price - ($this->price * $activeSpecialOffer->percent / 100); $ticketPercent = $activeSpecialOffer->percent; } else if (count($this->tickets)) { foreach ($this->tickets as $ticket) { if ($ticket->isValid()) { $discount = $this->price - ($this->price * $ticket->discount / 100); if ($bestTicket > $discount) { $bestTicket = $discount; $ticketPercent = $ticket->discount; } } } } if ($with_percent) { return [ 'bestTicket' => $bestTicket, 'percent' => $ticketPercent ]; } return $bestTicket; } public function getBundleDuration() { if (empty($this->bundleDuration)) { $this->bundleDuration = $this->newQuery() ->where('bundles.id', $this->id) ->join('bundle_webinars', 'bundle_webinars.bundle_id', 'bundles.id') ->join('webinars', 'webinars.id', 'bundle_webinars.webinar_id') ->select('bundles.*', DB::raw('sum(webinars.duration) as duration')) ->sum('duration'); } return $this->bundleDuration; } public function getExpiredAccessDays($purchaseDate, $giftId = null) { if (!empty($giftId)) { $gift = Gift::query()->where('id', $giftId) ->where('status', 'active') ->first(); if (!empty($gift) and !empty($gift->date)) { $purchaseDate = $gift->date; } } return strtotime("+{$this->access_days} days", $purchaseDate); } public function checkHasExpiredAccessDays($purchaseDate, $giftId = null) { // true => has access // false => not access (expired) if (!empty($giftId)) { $gift = Gift::query()->where('id', $giftId) ->where('status', 'active') ->first(); if (!empty($gift) and !empty($gift->date)) { $purchaseDate = $gift->date; } } $time = time(); return strtotime("+{$this->access_days} days", $purchaseDate) > $time; } public function checkUserHasBought($user = null, $checkExpired = true): bool { $hasBought = false; if (empty($user) and auth()->check()) { $user = auth()->user(); } if (!empty($user)) { $sale = Sale::where('buyer_id', $user->id) ->where('bundle_id', $this->id) ->where('type', 'bundle') ->whereNull('refund_at') ->where('access_to_purchased_item', true) ->orderBy('created_at', 'desc') ->first(); if (!empty($sale)) { $hasBought = true; if ($sale->payment_method == Sale::$subscribe) { $subscribe = $sale->getUsedSubscribe($sale->buyer_id, $sale->bundle_id, 'bundle_id'); if (!empty($subscribe)) { $subscribeSaleCreatedAt = null; if (!empty($subscribe->installment_order_id)) { $installmentOrder = InstallmentOrder::query()->where('user_id', $user->id) ->where('id', $subscribe->installment_order_id) ->where('status', 'open') ->whereNull('refund_at') ->first(); if (!empty($installmentOrder)) { $subscribeSaleCreatedAt = $installmentOrder->created_at; if ($installmentOrder->checkOrderHasOverdue()) { $overdueIntervalDays = getInstallmentsSettings('overdue_interval_days'); if (empty($overdueIntervalDays) or $installmentOrder->overdueDaysPast() > $overdueIntervalDays) { $hasBought = false; } } } } else { $subscribeSale = Sale::where('buyer_id', $user->id) ->where('type', Sale::$subscribe) ->where('subscribe_id', $subscribe->id) ->whereNull('refund_at') ->latest('created_at') ->first(); if (!empty($subscribeSale)) { $subscribeSaleCreatedAt = $subscribeSale->created_at; } } if (!empty($subscribeSaleCreatedAt)) { $usedDays = (int)diffTimestampDay(time(), $subscribeSaleCreatedAt); if ($usedDays > $subscribe->days) { $hasBought = false; } } } else { $hasBought = false; } } if ($hasBought and !empty($this->access_days) and $checkExpired) { $hasBought = $this->checkHasExpiredAccessDays($sale->created_at, $sale->gift_id); } } if (!$hasBought) { $hasBought = ($this->creator_id == $user->id or $this->teacher_id == $user->id); } if (!$hasBought) { $hasBought = $user->isAdmin(); } /* Check Installment */ if (!$hasBought) { $installmentOrder = $this->getInstallmentOrder(); if (!empty($installmentOrder)) { $hasBought = true; if ($installmentOrder->checkOrderHasOverdue()) { $overdueIntervalDays = getInstallmentsSettings('overdue_interval_days'); if (empty($overdueIntervalDays) or $installmentOrder->overdueDaysPast() > $overdueIntervalDays) { $hasBought = false; } } } } /* Check Gift */ if (!$hasBought) { $gift = Gift::query()->where('email', $user->email) ->where('status', 'active') ->where('bundle_id', $this->id) ->where(function ($query) { $query->whereNull('date'); $query->orWhere('date', '<', time()); }) ->whereHas('sale') ->first(); if (!empty($gift)) { $hasBought = true; } } } return $hasBought; } public function getInstallmentOrder() { $user = auth()->user(); if (!empty($user)) { return InstallmentOrder::query()->where('user_id', $user->id) ->where('bundle_id', $this->id) ->where('status', 'open') ->whereNull('refund_at') ->first(); } return null; } public function isOwner($userId = null) { if (empty($userId)) { $userId = auth()->id(); } return (($this->creator_id == $userId) or ($this->teacher_id == $userId)); } public function activeSpecialOffer() { $activeSpecialOffer = SpecialOffer::where('bundle_id', $this->id) ->where('status', SpecialOffer::$active) ->where('from_date', '<', time()) ->where('to_date', '>', time()) ->first(); return $activeSpecialOffer ?? false; } public function getPrice() { $price = $this->price; $specialOffer = $this->activeSpecialOffer(); if (!empty($specialOffer)) { $price = $price - ($price * $specialOffer->percent / 100); } return $price; } public function canSale() { // TODO:: If there was a sales restriction like the courses, we apply here return true; } public function getShareLink($social) { $link = ShareFacade::page($this->getUrl()) ->facebook() ->twitter() ->whatsapp() ->telegram() ->getRawLinks(); return !empty($link[$social]) ? $link[$social] : ''; } public function getDiscount($ticket = null, $user = null) { $activeSpecialOffer = $this->activeSpecialOffer(); $discountOut = $activeSpecialOffer ? $this->price * $activeSpecialOffer->percent / 100 : 0; if (!empty($user) and !empty($user->getUserGroup()) and isset($user->getUserGroup()->discount) and $user->getUserGroup()->discount > 0) { $discountOut += $this->price * $user->getUserGroup()->discount / 100; } if (!empty($ticket) and $ticket->isValid()) { $discountOut += $this->price * $ticket->discount / 100; } return $discountOut; } public function getDiscountPercent() { $percent = 0; $activeSpecialOffer = $this->activeSpecialOffer(); if (!empty($activeSpecialOffer)) { $percent += $activeSpecialOffer->percent; } $tickets = Ticket::where('webinar_id', $this->id)->get(); foreach ($tickets as $ticket) { if (!empty($ticket) and $ticket->isValid()) { $percent += $ticket->discount; } } return $percent; } public function getStudentsIds() { $studentsIds = Sale::where('bundle_id', $this->id) ->whereNull('refund_at') ->pluck('buyer_id') ->toArray(); // get users by installments $installmentOrders = InstallmentOrder::query() ->where('bundle_id', $this->id) ->where('status', 'open') ->whereNull('refund_at') ->get(); foreach ($installmentOrders as $installmentOrder) { if (!empty($installmentOrder)) { $hasBought = true; if ($installmentOrder->checkOrderHasOverdue()) { $overdueIntervalDays = getInstallmentsSettings('overdue_interval_days'); if (empty($overdueIntervalDays) or $installmentOrder->overdueDaysPast() > $overdueIntervalDays) { $hasBought = false; } } if ($hasBought) { $studentsIds[] = $installmentOrder->user_id; } } } // get users by gifts $gifts = Gift::query() ->where('status', 'active') ->where('bundle_id', $this->id) ->where(function ($query) { $query->whereNull('date'); $query->orWhere('date', '<', time()); }) ->whereHas('sale') ->get(); foreach ($gifts as $gift) { $user = User::query()->select('id', 'email')->where('email', $gift->email)->first(); if (!empty($user)) { $studentsIds[] = $user->id; } } return array_unique($studentsIds); } public function checkShowProgress() { return false; } } Reward.php 0000644 00000003665 15102516312 0006507 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Reward extends Model { public $timestamps = false; protected $table = 'rewards'; protected $guarded = ['id']; const ACCOUNT_CHARGE = 'account_charge'; const CREATE_CLASSES = 'create_classes'; const BUY = 'buy'; const PASS_THE_QUIZ = 'pass_the_quiz'; const CERTIFICATE = 'certificate'; const COMMENT = 'comment'; const REGISTER = 'register'; const REVIEW_COURSES = 'review_courses'; const INSTRUCTOR_MEETING_RESERVE = 'instructor_meeting_reserve'; const STUDENT_MEETING_RESERVE = 'student_meeting_reserve'; const NEWSLETTERS = 'newsletters'; const BADGE = 'badge'; const REFERRAL = 'referral'; const LEARNING_PROGRESS_100 = 'learning_progress_100'; const CHARGE_WALLET = 'charge_wallet'; const BUY_STORE_PRODUCT = 'buy_store_product'; const PASS_ASSIGNMENT = 'pass_assignment'; const MAKE_TOPIC = 'make_topic'; const SEND_TOPIC_POST = 'send_post_in_topic'; const CREATE_BLOG_BY_INSTRUCTOR = 'create_blog_by_instructor'; const COMMENT_FOR_INSTRUCTOR_BLOG = 'comment_for_instructor_blog'; public static function getTypesLists(): array { return [ self::ACCOUNT_CHARGE, self::CREATE_CLASSES, self::BUY, self::PASS_THE_QUIZ, self::CERTIFICATE, self::COMMENT, self::REGISTER, self::REVIEW_COURSES, self::INSTRUCTOR_MEETING_RESERVE, self::STUDENT_MEETING_RESERVE, self::NEWSLETTERS, self::BADGE, self::REFERRAL, self::LEARNING_PROGRESS_100, self::CHARGE_WALLET, self::BUY_STORE_PRODUCT, self::PASS_ASSIGNMENT, self::MAKE_TOPIC, self::SEND_TOPIC_POST, self::CREATE_BLOG_BY_INSTRUCTOR, self::COMMENT_FOR_INSTRUCTOR_BLOG, ]; } } ForumTopicBookmark.php 0000644 00000000737 15102516312 0011035 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ForumTopicBookmark extends Model { protected $table = 'forum_topic_bookmarks'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function topic() { return $this->belongsTo('App\Models\ForumTopic', 'topic_id', 'id'); } } CashbackRule.php 0000644 00000007216 15102516312 0007606 0 ustar 00 <?php namespace App\Models; use App\User; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class CashbackRule extends Model implements TranslatableContract { use Translatable; protected $table = 'cashback_rules'; public $timestamps = false; protected $guarded = ['id']; // Enums static $targetTypes = ['all', 'recharge_wallet', 'courses', 'store_products', 'bundles', 'meetings', 'registration_packages', 'subscription_packages']; static $courseTargets = ['all_courses', 'live_classes', 'video_courses', 'text_courses', 'specific_categories', 'specific_instructors', 'specific_courses']; static $productTargets = ['all_products', 'virtual_products', 'physical_products', 'specific_categories', 'specific_sellers', 'specific_products']; static $bundleTargets = ['all_bundles', 'specific_categories', 'specific_instructors', 'specific_bundles']; static $meetingTargets = ['all_meetings', 'specific_instructors']; static $subscriptionTargets = ['all_packages', 'specific_packages']; static $registrationPackagesTargets = ['all_packages', 'specific_packages']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } // ############# // Relations // ############ public function usersAndGroups() { return $this->hasMany(CashbackRuleUserGroup::class, 'cashback_rule_id', 'id'); } public function userGroups() { return $this->belongsToMany(Group::class, 'cashback_rule_users_groups', 'cashback_rule_id', 'group_id'); } public function users() { return $this->belongsToMany(User::class, 'cashback_rule_users_groups', 'cashback_rule_id', 'user_id'); } public function specificationItems() // used just in query { return $this->hasMany(CashbackRuleSpecificationItem::class, 'cashback_rule_id', 'id'); } public function categories() { return $this->belongsToMany(Category::class, 'cashback_rule_specification_items', 'cashback_rule_id', 'category_id'); } public function instructors() { return $this->belongsToMany(User::class, 'cashback_rule_specification_items', 'cashback_rule_id', 'instructor_id'); } public function sellers() { return $this->belongsToMany(User::class, 'cashback_rule_specification_items', 'cashback_rule_id', 'seller_id'); } public function webinars() { return $this->belongsToMany(Webinar::class, 'cashback_rule_specification_items', 'cashback_rule_id', 'webinar_id'); } public function products() { return $this->belongsToMany(Product::class, 'cashback_rule_specification_items', 'cashback_rule_id', 'product_id'); } public function bundles() { return $this->belongsToMany(Bundle::class, 'cashback_rule_specification_items', 'cashback_rule_id', 'bundle_id'); } public function subscribes() { return $this->belongsToMany(Subscribe::class, 'cashback_rule_specification_items', 'cashback_rule_id', 'subscribe_id'); } public function registrationPackages() { return $this->belongsToMany(RegistrationPackage::class, 'cashback_rule_specification_items', 'cashback_rule_id', 'registration_package_id'); } // ############# // Helpers // ############ public function getAmount($itemPrice = 1) { if ($this->amount_type == 'percent') { return ($itemPrice * $this->amount) / 100; } else { return $this->amount; } } } Noticeboard.php 0000644 00000001422 15102516312 0007501 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Noticeboard extends Model { protected $table = 'noticeboards'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $types = ['students', 'instructors', 'students_and_instructors']; static $adminTypes = ['organizations', 'students', 'instructors', 'students_and_instructors']; static $migrateTypes = ['all', 'organizations', 'students', 'instructors', 'students_and_instructors']; public function noticeboardStatus() { return $this->hasOne('App\Models\NoticeboardStatus', 'noticeboard_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } } NewsletterHistory.php 0000644 00000000402 15102516312 0010763 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class NewsletterHistory extends Model { protected $table = 'newsletters_history'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } TrendCategory.php 0000644 00000000737 15102516312 0010032 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class TrendCategory extends Model { protected $table = 'trend_categories'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function category() { return $this->belongsTo('App\Models\Category', 'category_id', 'id'); } /** * @return mixed */ public function getIcon() { return $this->icon; } } Notification.php 0000644 00000002011 15102516312 0007671 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Notification extends Model { protected $table = 'notifications'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $AdminSender = 'admin'; static $SystemSender = 'system'; static $notificationsType = ['single', 'all_users', 'students', 'instructors', 'organizations', 'group', 'course_students']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function senderUser() { return $this->belongsTo('App\User', 'sender_id', 'id'); } public function group() { return $this->belongsTo('App\Models\Group', 'group_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function notificationStatus() { return $this->hasOne('App\Models\NotificationStatus', 'notification_id', 'id'); } } Affiliate.php 0000644 00000010367 15102516312 0007144 0 ustar 00 <?php namespace App\Models; use App\Mixins\RegistrationBonus\RegistrationBonusAccounting; use App\User; use Illuminate\Database\Eloquent\Model; class Affiliate extends Model { protected $table = 'affiliates'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function affiliateUser() { return $this->belongsTo('App\User', 'affiliate_user_id', 'id'); } public function referredUser() { return $this->belongsTo('App\User', 'referred_user_id', 'id'); } public function getTotalAffiliateRegistrationAmounts() { $amount = Accounting::where('user_id', $this->affiliate_user_id) ->where('is_affiliate_amount', true) ->where('system', false) ->sum('amount'); return $amount; } public function getTotalAffiliateCommissions() { $amount = Accounting::where('user_id', $this->affiliate_user_id) ->where('is_affiliate_commission', true) ->where('system', false) ->sum('amount'); return $amount; } public function getAffiliateRegistrationAmountsOfEachReferral() { $amount = Accounting::where('user_id', $this->affiliate_user_id) ->where('referred_user_id', $this->referred_user_id) ->where('is_affiliate_amount', true) ->where('system', false) ->sum('amount'); return $amount; } public function getTotalAffiliateCommissionOfEachReferral() { $amount = Accounting::where('user_id', $this->affiliate_user_id) ->where('referred_user_id', $this->referred_user_id) ->where('is_affiliate_commission', true) ->where('system', false) ->sum('amount'); return $amount; } public function getReferredAmount() { $amount = Accounting::where('user_id', $this->referred_user_id) ->where('referred_user_id', null) ->where('is_affiliate_amount', true) ->where('system', false) ->sum('amount'); return $amount; } public static function storeReferral($user, $code) { $referralSettings = getReferralSettings(); $affiliateStatus = (!empty($referralSettings) and !empty($referralSettings['status'])); if ($affiliateStatus) { $affiliateCode = AffiliateCode::where('code', $code)->first(); $affiliateUser = User::find($affiliateCode->user_id); $checkAffiliate = self::where('referred_user_id', $user->id)->first(); if (empty($checkAffiliate) and !empty($affiliateCode) and !empty($affiliateUser) and $affiliateUser->affiliate) { self::create([ 'affiliate_user_id' => $affiliateUser->id, 'referred_user_id' => $user->id, 'created_at' => time(), ]); $affiliate_user_amount = (!empty($referralSettings) and !empty($referralSettings['affiliate_user_amount'])) ? $referralSettings['affiliate_user_amount'] : 0; $referred_user_amount = (!empty($referralSettings) and !empty($referralSettings['referred_user_amount'])) ? $referralSettings['referred_user_amount'] : 0; if ($affiliate_user_amount) { Accounting::createAffiliateUserAmountAccounting($affiliateUser->id, $user->id, $affiliate_user_amount); } if ($referred_user_amount) { Accounting::createAffiliateUserAmountAccounting($user->id, null, $referred_user_amount); } $rewardScore = RewardAccounting::calculateScore(Reward::REFERRAL); RewardAccounting::makeRewardAccounting($affiliateUser->id, $rewardScore, Reward::REFERRAL, $user->id, true); $registrationBonusAccounting = new RegistrationBonusAccounting(); $registrationBonusAccounting->storeRegistrationBonus($affiliateUser); $notifyOptions = [ '[u.name]' => $user->full_name, '[time.date]' => dateTimeFormat(time(), 'j M Y') ]; sendNotification("new_referral_user", $notifyOptions, $affiliateUser->id); } } } } Subscribe.php 0000644 00000010242 15102516312 0007171 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Subscribe extends Model implements TranslatableContract { use Translatable; protected $table = 'subscribes'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function sales() { return $this->hasMany('App\Models\Sale', 'subscribe_id', 'id'); } public function uses() { return $this->hasMany('App\Models\SubscribeUse', 'subscribe_id', 'id'); } public static function getActiveSubscribe($userId) { $activePlan = null; $subscribe = null; $saleCreatedAt = null; $lastSubscribeSale = Sale::where('buyer_id', $userId) ->where('type', Sale::$subscribe) ->whereNull('refund_at') ->latest('created_at') ->first(); if ($lastSubscribeSale) { $subscribe = $lastSubscribeSale->subscribe; $saleCreatedAt = $lastSubscribeSale->created_at; } /* check installment */ if (empty($subscribe)) { $installmentOrder = InstallmentOrder::query()->where('user_id', $userId) ->whereNotNull('subscribe_id') ->where('status', 'open') ->whereNull('refund_at') ->latest('created_at') ->first(); if (!empty($installmentOrder)) { $subscribe = $installmentOrder->subscribe; $subscribe->installment_order_id = $installmentOrder->id; $saleCreatedAt = $installmentOrder->created_at; if ($installmentOrder->checkOrderHasOverdue()) { $overdueIntervalDays = getInstallmentsSettings('overdue_interval_days'); if (empty($overdueIntervalDays) or $installmentOrder->overdueDaysPast() > $overdueIntervalDays) { $subscribe = null; } } } } if (!empty($subscribe) and !empty($saleCreatedAt)) { $useCount = SubscribeUse::where('user_id', $userId) ->where('subscribe_id', $subscribe->id) ->whereHas('sale', function ($query) use ($saleCreatedAt) { $query->where('created_at', '>', $saleCreatedAt); $query->whereNull('refund_at'); }) ->count(); $subscribe->used_count = $useCount; $countDayOfSale = (int)diffTimestampDay(time(), $saleCreatedAt); if ( ($subscribe->usable_count > $useCount or $subscribe->infinite_use) and $subscribe->days >= $countDayOfSale ) { $activePlan = $subscribe; } } return $activePlan; } public static function getDayOfUse($userId) { $lastSubscribeSale = Sale::where('buyer_id', $userId) ->where('type', Sale::$subscribe) ->whereNull('refund_at') ->latest('created_at') ->first(); return $lastSubscribeSale ? (int)diffTimestampDay(time(), $lastSubscribeSale->created_at) : 0; } public function activeSpecialOffer() { $activeSpecialOffer = SpecialOffer::where('subscribe_id', $this->id) ->where('status', SpecialOffer::$active) ->where('from_date', '<', time()) ->where('to_date', '>', time()) ->first(); return $activeSpecialOffer ?? false; } public function getPrice() { $price = $this->price; $specialOffer = $this->activeSpecialOffer(); if (!empty($specialOffer)) { $price = $price - ($price * $specialOffer->percent / 100); } return $price; } } ProductMedia.php 0000644 00000001001 15102516312 0007621 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ProductMedia extends Model { protected $table = 'product_media'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $types = ['thumbnail', 'image', 'video']; static $thumbnail = 'thumbnail'; static $image = 'image'; static $video = 'video'; public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } } Discount.php 0000644 00000016230 15102516312 0007043 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Discount extends Model { public $timestamps = false; protected $guarded = ['id']; static $discountUserTypes = ['all_users', 'special_users']; static $discountSource = ['all', 'course', 'bundle', 'category', 'meeting', 'product']; static $discountSourceAll = 'all'; static $discountSourceCourse = 'course'; static $discountSourceCategory = 'category'; static $discountSourceMeeting = 'meeting'; static $discountSourceProduct = 'product'; static $discountSourceBundle = 'bundle'; static $discountTypes = ['percentage', 'fixed_amount']; static $discountTypePercentage = 'percentage'; static $discountTypeFixedAmount = 'fixed_amount'; public function discountUsers() { return $this->hasOne('App\Models\DiscountUser', 'discount_id', 'id'); } public function discountCourses() { return $this->hasMany('App\Models\DiscountCourse', 'discount_id', 'id'); } public function discountBundles() { return $this->hasMany('App\Models\DiscountBundle', 'discount_id', 'id'); } public function discountCategories() { return $this->hasMany('App\Models\DiscountCategory', 'discount_id', 'id'); } public function discountGroups() { return $this->hasMany('App\Models\DiscountGroup', 'discount_id', 'id'); } public function discountRemain() { $count = $this->count; $orderItems = OrderItem::where('discount_id', $this->id) ->groupBy('order_id') ->get(); foreach ($orderItems as $orderItem) { if (!empty($orderItem) and !empty($orderItem->order) and $orderItem->order->status == 'paid') { $count = $count - 1; } } return ($count > 0) ? $count : 0; } public function checkValidDiscount() { if ($this->expired_at < time()) { return trans('update.discount_code_has_expired'); // expired } $user = auth()->user(); $carts = Cart::where('creator_id', $user->id)->get(); if ($this->source == self::$discountSourceCourse or $this->source == self::$discountSourceCategory) { $webinarCount = array_filter($carts->pluck('webinar_id')->toArray()); if (empty($webinarCount) or count($webinarCount) < 1) { return trans('update.discount_code_is_for_courses_error'); } } elseif ($this->source == self::$discountSourceMeeting) { $meetingCount = array_filter($carts->pluck('reserve_meeting_id')->toArray()); if (empty($meetingCount) or count($meetingCount) < 1) { return trans('update.discount_code_is_for_meetings_error'); } } if ($this->source == self::$discountSourceCourse) { $discountWebinarsIds = $this->discountCourses()->pluck('course_id')->toArray(); $hasSpecialWebinars = false; foreach ($carts as $cart) { $webinar = $cart->webinar; if (!empty($webinar) and in_array($webinar->id, $discountWebinarsIds)) { $hasSpecialWebinars = true; } } if (!$hasSpecialWebinars) { return trans('update.your_coupon_is_valid_for_another_course'); } } if ($this->source == self::$discountSourceBundle) { $discountBundlesIds = $this->discountBundles()->pluck('bundle_id')->toArray(); $hasSpecialBundles = false; foreach ($carts as $cart) { $bundle = $cart->bundle; if (!empty($bundle) and in_array($bundle->id, $discountBundlesIds)) { $hasSpecialBundles = true; } } if (!$hasSpecialBundles) { return trans('update.your_coupon_is_valid_for_another_bundle'); } } if ($this->source == self::$discountSourceProduct) { $hasSpecialProducts = false; foreach ($carts as $cart) { if (!empty($cart->productOrder)) { $product = $cart->productOrder->product; if (!empty($product) and ($this->product_type == 'all' or $this->product_type == $product->type)) { $hasSpecialProducts = true; } } } if (!$hasSpecialProducts) { return trans('update.your_coupon_is_valid_for_another_products_type'); } } if ($this->source == self::$discountSourceCategory) { $categoriesIds = ($this->discountCategories) ? $this->discountCategories()->pluck('category_id')->toArray() : []; $hasSpecialCategories = false; foreach ($carts as $cart) { $webinar = $cart->webinar; if (!empty($webinar) and in_array($webinar->category_id, $categoriesIds)) { $hasSpecialCategories = true; } } if (!$hasSpecialCategories) { return trans('update.your_coupon_is_valid_for_another_category'); } } if ($this->type == 'special_users') { $userDiscount = DiscountUser::where('user_id', $user->id) ->where('discount_id', $this->id) ->first(); if (empty($userDiscount)) { return trans('cart.coupon_invalid'); // not for this user } } if (!empty($this->minimum_order)) { // check user orders minimum amounts $totalCartsPrice = Cart::getCartsTotalPrice($carts); if ($this->minimum_order > $totalCartsPrice) { return trans('update.discount_code_minimum_order_error', ['min_order' => $this->minimum_order]); // the minimum order is less than the discount amount } } if (!empty($this->discountGroups) and count($this->discountGroups)) { $groupsIds = $this->discountGroups()->pluck('group_id')->toArray(); if (empty($user->userGroup) or !in_array($user->userGroup->group_id, $groupsIds)) { return trans('update.discount_code_group_error'); // this user is not in specific group } } if ($this->for_first_purchase) { $checkIsFirstPurchase = Sale::where('buyer_id', $user->id) ->whereNull('refund_at') ->count(); if ($checkIsFirstPurchase > 0) { return trans('update.discount_code_for_first_purchase_error'); // This discount code for first purchase. } } $usedCount = 0; $orderItems = OrderItem::where('discount_id', $this->id) ->groupBy('order_id') ->get(); foreach ($orderItems as $orderItem) { if (!empty($orderItem) and !empty($orderItem->order) and $orderItem->order->status == 'paid') { $usedCount += 1; } } if ($usedCount >= $this->count) { return trans('update.discount_code_used_count_error'); // The number of uses of this code has expired. } return 'ok'; } } Category.php 0000644 00000006457 15102516312 0007042 0 ustar 00 <?php namespace App\Models; use Cviebrock\EloquentSluggable\Services\SlugService; use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Category extends Model implements TranslatableContract { use Translatable; use Sluggable; protected $table = 'categories'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $cacheKey = 'categories'; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } /** * Return the sluggable configuration array for this model. * * @return array */ public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public static function makeSlug($title) { return SlugService::createSlug(self::class, 'slug', $title); } public function category() { return $this->belongsTo('App\Models\Category', 'parent_id', 'id'); } public function subCategories() { return $this->hasMany($this, 'parent_id', 'id')->orderBy('order', 'asc'); } public function filters() { return $this->hasMany('App\Models\Filter', 'category_id', 'id'); } public function webinars() { return $this->hasMany('App\Models\Webinar', 'category_id', 'id'); } public function userOccupations() { return $this->hasMany('App\Models\UserOccupation', 'category_id', 'id'); } public function getUrl() { $url = '/categories/'; if (!empty($this->category)) { $url .= $this->category->slug . '/'; } $url .= $this->slug; return $url; } static function getCategories() { $categories = cache()->remember(self::$cacheKey, 24 * 60 * 60, function () { return self::whereNull('parent_id') ->with([ 'subCategories' => function ($query) { $query->orderBy('order', 'asc'); }, ]) ->orderBy('order', 'asc') ->get(); }); return $categories; } public function getCategoryCourses() { $webinars = collect([]); $subCategories = $this->subCategories; foreach ($subCategories as $category) { $webinars = $webinars->merge($category->webinars); } return $webinars; } public function getCategoryInstructorsIdsHasMeeting() { $ids = []; $subCategories = $this->subCategories; foreach ($subCategories as $category) { if (count($category->userOccupations)) { foreach ($category->userOccupations as $occupation) { if (!empty($occupation->user) and !$occupation->user->isUser() and !$occupation->user->isAdmin()) { if (!empty($occupation->user->hasMeeting())) { $ids[] = $occupation->user->id; } } } } } return $ids; } } SessionRemind.php 0000644 00000000371 15102516312 0010034 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class SessionRemind extends Model { public $timestamps = false; protected $guarded = ['id']; protected $table = 'session_reminds'; protected $dateFormat = 'U'; } CashbackRuleUserGroup.php 0000644 00000000726 15102516312 0011461 0 ustar 00 <?php namespace App\Models; use App\User; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class CashbackRuleUserGroup extends Model { protected $table = 'cashback_rule_users_groups'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo(User::class, 'user_id', 'id'); } } Currency.php 0000644 00000000512 15102516312 0007041 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Currency extends Model { protected $table = 'currencies'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $currencyPositions = ['left', 'right', 'left_with_space', 'right_with_space']; } Blog.php 0000644 00000004311 15102516312 0006133 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Cviebrock\EloquentSluggable\Services\SlugService; use Cviebrock\EloquentSluggable\Sluggable; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Jorenvh\Share\ShareFacade; class Blog extends Model implements TranslatableContract { use Translatable; use Sluggable; protected $table = 'blog'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'description', 'meta_description', 'content']; /** * Return the sluggable configuration array for this model. * * @return array */ public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public static function makeSlug($title) { return SlugService::createSlug(self::class, 'slug', $title); } public function category() { return $this->belongsTo('App\Models\BlogCategory', 'category_id', 'id'); } public function author() { return $this->belongsTo('App\User', 'author_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Comment', 'blog_id', 'id'); } public function getUrl() { return '/blog/' . $this->slug; } public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function getMetaDescriptionAttribute() { return getTranslateAttributeValue($this, 'meta_description'); } public function getContentAttribute() { return getTranslateAttributeValue($this, 'content'); } public function getShareLink($social) { $link = ShareFacade::page(url($this->getUrl()), $this->title) ->facebook() ->twitter() ->whatsapp() ->telegram() ->getRawLinks(); return !empty($link[$social]) ? $link[$social] : ''; } } ProductFilterOption.php 0000644 00000001061 15102516312 0011226 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class ProductFilterOption extends Model implements TranslatableContract { use Translatable; protected $table = 'product_filter_options'; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } } WebinarChapterItem.php 0000644 00000004431 15102516312 0010770 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class WebinarChapterItem extends Model { protected $table = 'webinar_chapter_items'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $chapterFile = 'file'; static $chapterSession = 'session'; static $chapterTextLesson = 'text_lesson'; static $chapterQuiz = 'quiz'; static $chapterAssignment = 'assignment'; static public function makeItem($userId, $chapterId, $itemId, $type) { $order = WebinarChapterItem::where('chapter_id', $chapterId)->count() + 1; WebinarChapterItem::updateOrCreate([ 'user_id' => $userId, 'chapter_id' => $chapterId, 'item_id' => $itemId, 'type' => $type, ], [ 'order' => $order, 'created_at' => time() ]); } static public function changeChapter($userId, $oldChapterId, $newChapterId, $itemId, $type) { $chapterItem = WebinarChapterItem::query() ->where('user_id', $userId) ->where('chapter_id', $oldChapterId) ->where('item_id', $itemId) ->where('type', $type) ->first(); if (!empty($chapterItem)) { $order = WebinarChapterItem::where('chapter_id', $newChapterId)->count() + 1; $chapterItem->update([ 'chapter_id' => $newChapterId, 'order' => $order, ]); } else { WebinarChapterItem::makeItem($userId, $newChapterId, $itemId, $type); } } public function session() { return $this->belongsTo('App\Models\Session', 'item_id', 'id'); } public function file() { return $this->belongsTo('App\Models\File', 'item_id', 'id'); } public function textLesson() { return $this->belongsTo('App\Models\TextLesson', 'item_id', 'id'); } public function assignment() { return $this->belongsTo('App\Models\WebinarAssignment', 'item_id', 'id'); } public function quiz() { return $this->belongsTo('App\Models\Quiz', 'item_id', 'id'); } public function chapter() { return $this->belongsTo('App\Models\WebinarChapter', 'chapter_id', 'id'); } } Certificate.php 0000644 00000001237 15102516312 0007476 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Certificate extends Model { protected $table = "certificates"; public $timestamps = false; protected $guarded = ['id']; public function quiz() { return $this->hasOne('App\Models\Quiz', 'id', 'quiz_id'); } public function student() { return $this->hasOne('App\User', 'id', 'student_id'); } public function quizzesResult() { return $this->hasOne('App\Models\QuizzesResult', 'id', 'quiz_result_id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } } Api/CourseForumAnswer.php 0000644 00000000412 15102516312 0011410 0 ustar 00 <?php namespace App\Models\Api; use App\Models\CourseForum; use App\Models\CourseForumAnswer as Model; class CourseForumAnswer extends Model { // public function course_forum() { return $this->belongsTo(CourseForum::class, 'forum_id'); } } Api/WebinarAssignmentHistory.php 0000644 00000006115 15102516312 0012767 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Sale; use App\Models\WebinarAssignmentHistory as Model; class WebinarAssignmentHistory extends Model { public function deadline() { $deadline = true; // default can access $assignment = $this->assignment; if (!empty($assignment->deadline)) { $conditionDay = $assignment->getDeadlineTimestamp($this->student); if (time() > $conditionDay) { $deadline = false; } else { $deadline = round(($conditionDay - time()) / (60 * 60 * 24), 1); $deadline = ceil($deadline); } } return $deadline; } public function deadlineDays() { if (!$this->deadline()) { return 'expired'; } elseif (is_bool($this->deadline())) { return 'unlimited'; } else { return $this->deadline(); } } public function checkHasAttempts() { $result = true; $user = $this->student; $assignment = $this->assignment; if (!empty($assignment->attempts) and $user->id != $assignment->creator_id) { $submissionTimes = $this->messages ->where('sender_id', $user->id) //->whereNotNull('file_path') ->count(); $result = ($submissionTimes < $assignment->attempts); } return $result; } public function submissionTimes() { return $this->messages->count(); } public function canSendMessage() { $user = $this->student; $assignment = $this->assignment; return !( $user->id != $assignment->creator_id and ( $this->status == WebinarAssignmentHistory::$passed or $this->status == WebinarAssignmentHistory::$notPassed or !$this->deadline() or ( !$this->checkHasAttempts() and !empty($assignment->attempts) and $this->submissionTimes() >= $assignment->attempts ) ) ); } public function getLastSubmissionAttribute() { if ($this->messages) { return $this->messages->where('sender_id', apiAuth()->id)->first()->created_at ?? null; } return null; } public function getFirstSubmissionAttribute() { if ($this->messages) { return $this->messages->where('sender_id', apiAuth()->id)->last()->created_at ?? null; } return null; } public function getUsedAttemptsCountAttribute() { if ($this->messages) { return $this->messages->where('sender_id', $this->student_id)->count() ?? 0; } return 0; } public function sale() { return Sale::where('buyer_id', $this->student_id) ->where('webinar_id', $this->assignment->webinar_id) ->whereNull('refund_at') ->first(); } public function assignment() { return $this->belongsTo('App\Models\Api\WebinarAssignment', 'assignment_id', 'id'); } } Api/Product.php 0000644 00000017030 15102516312 0007403 0 ustar 00 <?php namespace App\Models\Api; //use Illuminate\Database\Eloquent\Model; use App\Models\Product as Model; use App\Models\ProductOrder; use App\Models\ProductSelectedFilterOption; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; class Product extends Model { public function getLabelAttribute() { if ($this->ordering and !empty($this->inventory) and $this->getAvailability() < 1) { return trans('update.out_of_stock'); } elseif (!$this->ordering and $this->getActiveDiscount()) { return trans('update.ordering_off'); } elseif ($this->getActiveDiscount()) { return trans('public.offer', ['off' => $this->getActiveDiscount()->percent]); } else { switch ($this->status) { case \App\Models\Product::$active: return trans('public.active'); case Product::$inactive: return trans('public.rejected'); case Product::$draft: return trans('public.draft'); case Product::$pending: return trans('public.waiting'); default: return null; } } } public function getWaitingOrdersAttribute() { return $this->productOrders->whereIn('status', [ProductOrder::$waitingDelivery, ProductOrder::$shipped])->count(); } public function canAddToCart($user) { } public function checkProductForSale($user) { if ($this->getAvailability() < 1) { return apiResponse2(0, 'not_availability', trans('update.product_not_availability')); } if ($this->creator_id == $user->id) { return apiResponse2(0, 'same_user', trans('update.cant_purchase_your_product')); } return 'ok'; } public function scopeHandleFilters($query) { $isRewardProducts = false; $request = \request(); $isFree = $request->get('free', null); $isFreeShipping = $request->get('free_shipping', null); $withDiscount = $request->get('discount', null); $sort = $request->get('sort', null); $type = $request->get('type', null); $options = $request->get('options', null); $categoryId = $request->get('cat', null); $filterOption = $request->get('filter_option', null); if (!empty($isFree) and $isFree == '1') { $query->where(function ($qu) { $qu->whereNull('price') ->orWhere('price', '0'); }); } if (!empty($isFreeShipping) and $isFreeShipping == '1') { $query->where(function ($qu) { $qu->whereNull('delivery_fee') ->orWhere('delivery_fee', '0'); }); } if (!empty($withDiscount) and $withDiscount == '1') { $query->whereHas('discounts', function ($query) { $query->where('status', 'active') ->where('start_date', '<', time()) ->where('end_date', '>', time()); }); } if (!empty($type) and count($type)) { $query->whereIn('type', $type); } if (!empty($options) and count($options)) { if (in_array('only_available', $options)) { $query->where(function ($query) { $query->where('unlimited_inventory', true) ->orWhereHas('productOrders', function ($query) { $query->havingRaw('products.inventory > sum(quantity)') ->whereNotNull('sale_id') ->whereNotIn('status', [ProductOrder::$canceled, ProductOrder::$pending]) ->groupBy('product_id'); }); }); } if (in_array('with_point', $options)) { $query->whereNotNull('point'); } } if (!empty($categoryId)) { $query->where('category_id', $categoryId); } if (!empty($filterOption) and is_array($filterOption)) { $productIdsFilterOptions = ProductSelectedFilterOption::whereIn('filter_option_id', $filterOption) ->pluck('product_id') ->toArray(); $productIdsFilterOptions = array_unique($productIdsFilterOptions); $query->whereIn('products.id', $productIdsFilterOptions); } if (!empty($sort)) { if ($sort == 'expensive') { if ($isRewardProducts) { $query->orderBy('point', 'desc'); } else { $query->orderBy('price', 'desc'); } } if ($sort == 'inexpensive') { if ($isRewardProducts) { $query->orderBy('point', 'asc'); } else { $query->orderBy('price', 'asc'); } } if ($sort == 'bestsellers') { $query->leftJoin('product_orders', function ($join) { $join->on('products.id', '=', 'product_orders.product_id') ->whereNotNull('product_orders.sale_id') ->whereNotIn('product_orders.status', [ProductOrder::$canceled, ProductOrder::$pending]); }) ->select('products.*', DB::raw('sum(product_orders.quantity) as salesCounts')) ->groupBy('product_orders.product_id') ->orderBy('salesCounts', 'desc'); } if ($sort == 'best_rates') { $query->leftJoin('product_reviews', function ($join) { $join->on('products.id', '=', 'product_reviews.product_id'); $join->where('product_reviews.status', 'active'); }) ->whereNotNull('rates') ->select('products.*', DB::raw('avg(rates) as rates')) ->groupBy('product_reviews.product_id') ->orderBy('rates', 'desc'); } } return $query; } public function getPrettySpecification() { return $this->selectedSpecifications->where('allow_selection', false) ->map(function ($selected) { if ($selected->type == 'textarea') { $value = $selected->value; } elseif (!empty($selected->selectedMultiValues)) { $value = $selected->selectedMultiValues->map(function ($multi) { return $multi->multiValue->title; }); } return [ 'title' => $selected->specification->title, 'type' => $selected->type, 'value' => $value ]; })->toArray(); } public function dde() { return $this->selectedSpecifications->where('allow_selection', true) ->where('type', 'multi_value')->map(function ($selectable) { return [ 'title' => $selectable->specification->title, 'values' => $selectable->selectedMultiValues->map(function ($multi) { return $multi->multiValue->title; }), // 'name' => $selectable->specification->createName(), ]; })->toArray(); } public function comments() { return $this->hasMany('App\Models\Api\Comment', 'product_id', 'id'); } } Api/Setting.php 0000644 00000001026 15102516312 0007376 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\Setting as WebSetting ; class Setting extends WebSetting { public static $register_method ; public static $offline_bank_account ; public static $user_language ; public static $payment_channels ; public static $minimum_payout_amount ; public static $currency ; public function __construct() { self::$register_method= 'ff' ; } public static function getRegisterMethodAttribute(){ return self::$register_method= 'ff' ; } } Api/QuizzesQuestionsAnswer.php 0000644 00000000777 15102516312 0012542 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\QuizzesQuestionsAnswer as WebQuizzesQuestionsAnswer; class QuizzesQuestionsAnswer extends WebQuizzesQuestionsAnswer{ public function getDetailsAttribute(){ return [ 'id'=>$this->id , 'title'=>$this->title , 'correct'=>$this->correct , 'image'=>($this->image)?url($this->image):null , 'created_at'=>$this->created_at , 'updated_at'=>$this->updated_at , ] ; } } Api/RewardAccounting.php 0000644 00000001163 15102516312 0011222 0 ustar 00 <?php namespace App\Models\Api; use App\Models\RewardAccounting as Model; class RewardAccounting extends Model { // public function getDetailsAttribute() { return [ 'id' => $this->id, 'user'=>$this->user->brief, 'item_id'=>$this->item_id, 'type'=>$this->type , 'score'=>$this->score, 'status'=>($this->status==self::ADDICTION)?'addition':$this->status , 'created_at'=>$this->created_at, ]; } public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } } Api/Accounting.php 0000644 00000005552 15102516312 0010063 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Accounting as Model; class Accounting extends Model { public function getDetailsAttribute(){ return [ 'type'=>$this->item , 'balance_type' => $this->balance_type, 'webinar' => ($this->item == 'webinar') ?$this->webinar->brief:null, 'subscribe' => ($this->item == 'subscribe') ? $this->subscribe->details : null, 'promotion' => ($this->item == 'promotion') ? $this->promotion: null, 'registration_package' => ($this->item == 'registration_package') ? $this->registrationPackage: null, 'description' => $this->description, 'amount' => number_format($this->amount, 2, ".", "") + 0, 'created_at' => $this->created_at ] ; } public function getBalanceTypeAttribute(){ if ($this->type == Accounting::$addiction) { $balance_type = 'addition'; } elseif ($this->type = Accounting::$deduction) { $balance_type = 'deduction'; } return $balance_type ; } public function getItemAttribute(){ if ($this->webinar_id and $this->webinar) { $type = 'webinar'; $title = $this->webinar->title; } elseif ($this->meeting_time_id) { $type = 'meeting'; $title = 'meeting book'; } elseif ($this->subscribe_id && $this->subscribe) { $type = 'subscribe'; } elseif ($this->promotion_id && $this->promotion) { $type = 'promotion'; } elseif ($this->registration_package_id and $this->registrationPackage){ $type = 'registration_package'; } elseif ($this->store_type == Accounting::$storeManual) { $type = 'manual_document'; } elseif ($this->type == Accounting::$addiction and $this->type_account == self::$asset) { $type = 'manual_document'; } elseif ($this->type == Accounting::$deduction and $this->type_account == self::$income) { $type = 'charge_account'; } else { $type = '---'; } return $type ; } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } public function creator() { return $this->belongsTo('App\Models\Api\User', 'creator_id', 'id'); } public function promotion() { return $this->belongsTo('App\Models\Api\Promotion', 'promotion_id', 'id'); } public function subscribe() { return $this->belongsTo('App\Models\Api\Subscribe', 'subscribe_id', 'id'); } public function meetingTime() { return $this->belongsTo('App\Models\Api\MeetingTime', 'meeting_time_id', 'id'); } } Api/User.php 0000644 00000024370 15102516312 0006706 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\Meeting; use App\Models\Region; use App\Models\UserOccupation; use App\User as Model; use App\Models\ReserveMeeting; use App\Models\Api\Follow; use App\Models\Role; use App\Models\Api\Sale; use App\Models\Api\Subscribe; use Illuminate\Support\Facades\DB; use Tymon\JWTAuth\Contracts\JWTSubject; class User extends Model implements JWTSubject { public function getJWTIdentifier() { return $this->getKey(); } public function getJWTCustomClaims() { return []; } public function getBriefAttribute() { return [ 'id' => $this->id, 'full_name' => $this->full_name, 'role_name' => $this->role_name, 'bio' => $this->bio, 'offline' => $this->offline, 'offline_message' => $this->offline_message, 'verified' => $this->verified, 'rate' => $this->rates(), 'avatar' => url($this->getAvatar()), 'meeting_status' => $this->meeting_status, 'user_group' => $this->userGroup->brief ?? null, 'address' => $this->address, ]; } public function getDetailsAttribute() { $details = [ 'status' => $this->status, 'email' => $this->email, 'mobile' => $this->mobile, 'language' => $this->language, 'newsletter' => ($this->newsletter) ? true : false, 'public_message' => $this->public_message, 'active_subscription' => Subscribe::getActiveSubscribe($this->id)->details ?? null, 'headline' => $this->headline, 'courses_count' => $this->webinars->count(), 'reviews_count' => $this->reviewsCount(), 'appointments_count' => $this->appointments()->count() , 'students_count' => $this->students->count(), 'followers_count' => $this->followers()->count(), 'following_count' => $this->following()->count(), 'badges' => $this->badges, 'students' => $this->students, 'followers' => $this->followers()->map(function ($follower) { return $follower->userFollower->brief; }), 'following' => $this->following()->map(function ($following) { return $following->user->brief; }), 'auth_user_is_follower' => $this->authUserIsFollower, 'referral' => null, 'education' => $this->userMetas()->where('name', 'education')->get()->map(function ($meta) { return $meta->value; }), 'experience' => $this->userMetas()->where('name', 'experience')->get()->map(function ($meta) { return $meta->value; }), 'occupations' => $this->occupations->map(function ($occupation) { return $occupation->category->title; }), 'about' => $this->about, 'webinars' => $this->webinars->map(function ($webinar) { return $webinar->brief; }), 'meeting' => ($this->meeting && $this->meeting->meetingTimes->count()) ? $this->meeting->details : null, 'organization_teachers' => $this->getOrganizationTeachers->map(function ($teacher) { return $teacher->brief; }), 'country_id' => $this->country_id, 'province_id' => $this->province_id, 'city_id' => $this->city_id, 'district_id' => $this->district_id, /* 'country' => [ 'id' => $this->country_id, 'title' => Region::find($this->country_id)->title??null, ], 'province' => [ 'id' => $this->province_id, 'title' => Region::find($this->province_id)->title??null, ], 'city' => [ 'id' => $this->city_id, 'title' => Region::find($this->city_id)->title??null, ], 'district_id' => [ 'id' => $this->district_id, 'title' => Region::find($this->district_id)->title??null, ],*/ ]; return array_merge($this->brief, $details, $this->financial);; } public function meetingsSaleAmount() { return Sale::where('seller_id', $this->id) ->whereNotNull('meeting_id') ->sum('amount'); } public function classesSaleAmount() { return Sale::where('seller_id', $this->id) ->whereNotNull('webinar_id') ->sum('amount'); } public function achievement_certificates($webinar) { $quiz_id = $webinar->quizzes->pluck('id'); return QuizzesResult::where('user_id', $this->id) ->whereIn('quiz_id', $quiz_id) ->where('status', QuizzesResult::$passed) ->get()->map(function ($result) { return array_merge($result->details, ['certificate' => $result->certificate->brief ?? null] ); }); } public function getFinancialAttribute() { return [ 'account_type' => $this->account_type, 'iban' => $this->iban, 'account_id' => $this->account_id, 'identity_scan' => ($this->identity_scan) ? url($this->identity_scan) : null, 'certificate' => ($this->certificate) ? url($this->certificate) : null, 'address' => $this->address, ]; } public function getAuthUserIsFollowerAttribute() { $user = apiAuth(); $authUserIsFollower = false; if ($user) { $authUserIsFollower = $user->following()->where('follower', $user->id) ->where('status', Follow::$accepted) ->count(); if ($authUserIsFollower) { return true; } return false; } return $authUserIsFollower; } public function getTotalPointsAttribute() { return (int)RewardAccounting::where('user_id', $this->id)->where('status', RewardAccounting::ADDICTION) ->sum('score'); } public function getSpentPointsAttribute() { return (int)RewardAccounting::where('user_id', $this->id)->where('status', RewardAccounting::DEDUCTION) ->sum('score'); } public function getAvailablePointsAttribute() { return $this->total_points - $this->spent_points; } public function getStudentsAttribute() { return Sale::whereNull('refund_at') ->where('seller_id', $this->id) ->whereNotNull('webinar_id') ->groupBy('buyer_id')->get()->map(function ($sale) { return $sale->buyer->brief; }); // ->pluck('buyer_id') // ->toArray(); // $user->students_count = count(array_unique($studentsIds)); } public function getActiveSubscription() { return Subscribe::getActiveSubscribe($this->id)->details ?? false; } public function getHasActiveSubscriptionAttribute() { return (Subscribe::getActiveSubscribe($this->id)) ? true : false; } public function getBadgesAttribute() { return collect($this->getBadges())->map(function ($badges) { return [ 'id' => $badges->id, 'title' => !empty($badges->badge_id) ? $badges->badge->title : $badges->title, 'type' => $badges->type, 'condition' => $badges->condition, 'image' => !empty($badges->badge_id) ? url($badges->badge->image) : url($badges->image), 'locale' => $badges->locale, 'description' => !empty($badges->badge_id) ? $badges->badge->description : $badges->description, 'created_at' => $badges->created_at, ]; }); } public function getMeetingStatusAttribute() { $meeting = 'no'; if ($this->meeting) { $meeting = 'available'; if ($this->meeting->disabled) { $meeting = 'unavailable'; } } return $meeting; } public function appointments() { $meetingIds = Meeting::where('creator_id', $this->id)->pluck('id'); $appointments = ReserveMeeting::whereIn('meeting_id', $meetingIds) ->whereNotNull('reserved_at') ->where('status', '!=', ReserveMeeting::$canceled)->get(); return $appointments; } public function getRoleLabelAttribute() { /* @if($cardUser->isUser()) * {{ trans('quiz.student') }} * @elseif($cardUser->isTeacher()) * {{ trans('public.instructor') }} * @elseif($cardUser->isOrganization()) * {{ trans('home.organization') }} * @elseif($cardUser->isAdmin()) * {{ trans('panel.staff') }} * @endif */ if ($this->isUser()) { return trans('quiz.student'); } elseif ($this->isTeacher()) { return trans('public.instructor'); } else { } } public function quizResults() { return $this->hasMany('App\Models\Api\QuizzesResult', 'user_id'); } public function meeting() { return $this->hasOne('App\Models\Api\Meeting', 'creator_id', 'id'); } public function webinars() { return $this->hasMany('App\Models\Api\Webinar', 'creator_id', 'id') ->orWhere('teacher_id', $this->id); } public function userCreatedQuizzes() { return $this->hasMany('App\Models\Api\Quiz', 'creator_id'); } public function userGroup() { return $this->belongsTo('App\Models\Api\GroupUser', 'id', 'user_id'); } public function followers() { return Follow::where('user_id', $this->id)->where('status', Follow::$accepted)->get(); } public function following() { return Follow::where('follower', $this->id)->where('status', Follow::$accepted)->get(); } public function getOrganizationTeachers() { return $this->hasMany($this, 'organ_id', 'id')->where('role_name', Role::$teacher); } public function purchases() { return $this->hasMany(Sale::class, 'buyer_id'); } } Api/Cart.php 0000644 00000002646 15102516312 0006663 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Cart as Model; class Cart extends Model { public function getDetailsAttribute(){ // dd($this->webinar->brief ) ; return [ 'id'=>$this->id , 'user'=>$this->user->brief , 'webinar'=>$this->webinar->brief??null , 'price'=>$this->price , 'discount'=>$this->discount , 'meeting'=>$this->reserveMeeting->details??null ] ; } public function getDiscountAttribute(){ if($this->webinar_id){ return $this->webinar->price - $this->webinar->getDiscount($this->ticket) ; } return null ; // $cart->webinar->price - $cart->webinar->getDiscount($cart->ticket), 2, ".", "" } public function getPriceAttribute(){ if($this->webinar_id){ return $this->webinar->price ; } return $this->reserveMeeting->paid_amount ; } public function user() { return $this->belongsTo('App\Models\Api\User', 'creator_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function reserveMeeting() { return $this->belongsTo('App\Models\Api\ReserveMeeting', 'reserve_meeting_id', 'id'); } public function ticket() { return $this->belongsTo('App\Models\Ticket', 'ticket_id', 'id'); } } Api/WebinarReport.php 0000644 00000001257 15102516312 0010552 0 ustar 00 <?php namespace App\Models\Api; use Illuminate\Database\Eloquent\Model; class WebinarReport extends Model { // public function getDetailsAttribute(){ return [ 'id'=>$this->id , 'reason'=>$this->reason , 'message'=>$this->message , 'created_at'=>$this->created_at , 'user'=>$this->user->brief??null , 'webinar'=>$this->webinar->brief??null ] ; } public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } } Api/Prerequisite.php 0000644 00000000477 15102516312 0010453 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Prerequisite as Model; class Prerequisite extends Model { public function prerequisiteWebinar() { return $this->belongsTo('App\Models\Api\Webinar', 'prerequisite_id', 'id') ->where('status','active')->where('private',false) ; ; } } Api/QuizzesResult.php 0000644 00000011146 15102516312 0010636 0 ustar 00 <?php namespace App\Models\Api; use App\Models\QuizzesResult as WebQuizzesResult; use App\User; use App\Models\Role; class QuizzesResult extends WebQuizzesResult { public function getBriefAttribute() { return [ 'id' => $this->id, 'quiz' => $this->quiz->details, 'webinar' => $this->quiz->webinar->brief, 'user' => $this->user->brief, 'user_grade' => $this->user_grade, 'status' => $this->status, 'created_at' => $this->created_at, 'auth_can_try_again' => $this->quiz->auth_can_take_quiz, 'count_try_again' => $this->quiz->CountTryAgain, ]; } public function getDetailsAttribute() { $details = [ 'reviewable' => $this->reviewable, 'answer_sheet' => json_decode($this->results, true), 'quiz_review' => $this->quiz_review, ]; return array_merge($this->brief, $details); } public function getFinishedAttribute() { if ( !$this->results && $this->status == QuizzesResult::$waiting ) { return false; } return true; } public function getQuizReviewAttribute() { $r = []; foreach ($this->quiz->quizQuestions as $question) { $details = $question->details; $answer_sheet = json_decode($this->results, true); $user_answer = $answer_sheet[$question['id']] ?? null; if (!$user_answer) { continue; } // $question->user_answer= $user_answer ; $details['user_answer'] = [ 'grade' => $user_answer['grade'] ?? null, 'status' => $user_answer['status'] ?? null, ]; $details['user_answer']['answer'] = $user_answer['answer'] ?? null; // if($question->type==QuizzesQuestion::$descriptive){ // $details['user_answer']['answer'] =$user_answer['answer']??null ; // }else{ // $details['user_answer']['answer_id'] =$user_answer['answer']??null ; // } $correct_answer = $question->quizzesQuestionsAnswers()->where('correct', 1)->first(); $details['descriptive_correct_answer'] = ($question->type == QuizzesQuestion::$descriptive) ? $question->correct : null; $details['multiple_correct_answer'] = ($question->type == QuizzesQuestion::$multiple) ? $correct_answer->details : null; $r[] = $details; } return $r; } public function getReviewableAttribute() { return ($this->status == self::$waiting && $this->results) ? true : false; } public function scopeHandleFilters($query) { $request = request(); $from = $request->get('from', null); $to = $request->get('to', null); $quiz_id = $request->get('quiz_id', null); $total_mark = $request->get('total_mark', null); $status = $request->get('status', null); $user_id = $request->get('user_id', null); $creator_id = $request->get('creator_id', null); $instructor = $request->get('instructor', null); $open_results = $request->get('open_results', null); $query = fromAndToDateFilter($from, $to, $query, 'created_at'); if (!empty($quiz_id) and $quiz_id != 'all') { $query->where('quiz_id', $quiz_id); } if ($total_mark) { $query->where('total_mark', $total_mark); } if (!empty($user_id) and $user_id != 'all') { $query->where('user_id', $user_id); } if (!empty($creator_id) and $creator_id != 'all') { $query->where('creator_id', $creator_id); } if ($instructor) { $userIds = User::whereIn('role_name', [Role::$teacher, Role::$organization]) ->where('full_name', 'like', '%' . $instructor . '%') ->pluck('id')->toArray(); $query->whereIn('creator_id', $userIds); } if ($status and $status != 'all') { $query->where('status', strtolower($status)); } if (!empty($open_results)) { $query->where('status', 'waiting'); } return $query; } public function quiz() { return $this->belongsTo('App\Models\Api\Quiz', 'quiz_id', 'id'); } public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } public function certificate() { return $this->hasOne('App\Models\Api\Certificate', 'quiz_result_id', 'id'); } } Api/SupportDepartment.php 0000644 00000000411 15102516312 0011456 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\SupportDepartment as Model ; class SupportDepartment extends Model { public function getDetailsAttribute(){ return [ 'id'=>$this->id , 'title'=>$this->title , ] ; } } Api/BlogCategory.php 0000644 00000000406 15102516312 0010343 0 ustar 00 <?php namespace App\Models\Api; use Illuminate\Database\Eloquent\Model; class BlogCategory extends Model { // public function getDetailsAttribute(){ return [ 'id'=>$this->id , 'title'=>$this->title ] ; } } Api/WebinarReview.php 0000644 00000003611 15102516312 0010534 0 ustar 00 <?php namespace App\Models\Api; use App\Models\WebinarReview as Model; class WebinarReview extends Model { public function getDetailsAttribute() { return [ 'id'=>$this->id , 'auth' => $this->auth, 'user' => [ 'full_name' => $this->creator->full_name, 'avatar' => url($this->creator->getAvatar()), ], 'created_at' => $this->created_at, 'description' => $this->description, 'rate' => $this->rates, 'rate_type' => [ 'content_quality' => $this->content_quality, 'instructor_skills' => $this->instructor_skills, 'purchase_worth' => $this->purchase_worth, 'support_quality' => $this->support_quality, ], 'replies' => $this->comments->where('status', 'active')->map(function ($reply) { return [ 'id' => $this->id, 'user' => [ 'full_name' => $reply->user->full_name, 'avatar' => url($reply->user->getAvatar()), ], 'created_at' => $reply->created_at, 'comment' => $reply->comment, ]; }) ]; } public function getAuthAttribute() { $user = apiAuth(); if (!$user) { return null; } if ($user->id == $this->creator_id) { return true; } return false; } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function creator() { return $this->belongsTo('App\Models\Api\User', 'creator_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Api\Comment', 'review_id', 'id'); } } ?> Api/WebinarAssignmentAttachment.php 0000644 00000000223 15102516312 0013410 0 ustar 00 <?php namespace App\Models\Api; use App\Models\WebinarAssignmentAttachment as Model; class WebinarAssignmentAttachment extends Model { // } Api/Comment.php 0000644 00000010031 15102516312 0007357 0 ustar 00 <?php namespace App\Models\Api; use App\Http\Resources\ProductResource; use App\Models\Comment as Model; use App\Models\Api\Product; class Comment extends Model { public function getDetailsAttribute() { return [ 'id' => $this->id, 'status' => $this->status, 'comment_user_type' => $this->comment_user_type, 'create_at' => $this->created_at, 'comment' => $this->comment, 'blog' => $this->blog->brief ?? null, 'user' => $this->user->brief ?? null, 'webinar' => $this->webinar->brief ?? null, 'product' => $this->product ? new ProductResource($this->product) : null, 'replies' => $this->replies->where('status', 'active')->map(function ($reply) { return [ 'id' => $reply->id, 'comment_user_type' => $reply->comment_user_type, 'user' => $reply->user->brief, 'create_at' => $reply->created_at, 'comment' => $reply->comment, ]; }) ]; } public function scopeHandleFilters($query) { $request = request(); $from = $request->get('from', null); $to = $request->get('to', null); $user = $request->get('user_id', null); $webinar = $request->get('webinar_id', null); $product = $request->get('product_id', null); $blogId = $request->get('blog_id', null); $filter_new_comments = request()->get('new_comments', null); if (!empty($from) and !empty($to)) { $from = strtotime($from); $to = strtotime($to); $query->whereBetween('created_at', [$from, $to]); } else { if (!empty($from)) { $from = strtotime($from); $query->where('created_at', '>=', $from); } if (!empty($to)) { $to = strtotime($to); $query->where('created_at', '<', $to); } } if (!empty($user)) { $usersIds = User::where('full_name', 'like', "%$user%")->pluck('id')->toArray(); $query->whereIn('user_id', $usersIds); } if (!empty($webinar)) { $webinarsIds = Webinar::where('title', 'like', "%$webinar%")->pluck('id')->toArray(); $query->whereIn('webinar_id', $webinarsIds); } if (!empty($filter_new_comments) and $filter_new_comments == 'on') { } if (!empty($product)) { $productsIds = Product::whereTranslationLike('title', "%$product%")->pluck('id')->toArray(); $query->whereIn('product_id', $productsIds); } if (!empty($blogId) and is_numeric($blogId)) { $query->where('blog_id', $blogId); } return $query; } public function getCommentUserTypeAttribute() { if ($this->user->isUser() or !empty($this->webinar) and $this->webinar->checkUserHasBought($this->user)) { $type = 'student'; } elseif ( !$this->user->isUser() and !empty($this->webinar) and ($this->webinar->creator_id == $this->user->id or $this->webinar->teacher_id == $this->user->id) ) { $type = 'teacher'; } elseif ($this->user->isAdmin()) { $type = 'staff'; } else { $type = 'user'; } return $type; } public function replies() { return $this->hasMany($this, 'reply_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } public function review() { return $this->belongsTo('App\Models\Api\WebinarReview', 'review_id', 'id'); } public function blog() { return $this->belongsTo('App\Models\Api\Blog', 'blog_id', 'id'); } } ?> Api/Traits/CheckWebinarItemAccessTrait.php 0000644 00000001706 15102516312 0014526 0 ustar 00 <?php namespace App\Models\Api\Traits; trait CheckWebinarItemAccessTrait { public function canViewError() { $error = null; $user = apiAuth(); if (!$user) { $error = trans('public.not_login_toast_msg_lang'); } elseif (!$this->webinar->checkUserHasBought($user)) { $error = trans('public.not_access_to_this_content'); } elseif ($checkSequenceContent = $this->checkSequenceContent($user)) { $errors = []; if (is_array($checkSequenceContent)) { foreach ($checkSequenceContent as $key => $value) { if ($value) { $errors[] = $value; } } } $error = (count($errors) > 0) ? implode(' ', $errors) : null; } elseif (!$this->user_has_access) { $error = trans('public.not_access_to_this_content'); } return $error; } } Api/Traits/CheckForSaleTrait.php 0000644 00000003540 15102516312 0012527 0 ustar 00 <?php namespace App\Models\Api\Traits; trait CheckForSaleTrait { public function checkWebinarForSale($user) { if (!$this->canSale()) { return apiResponse2(0, 'no_capacity', trans('cart.course_not_capacity')); } if ($this->creator_id == $user->id or $this->teacher_id == $user->id) { return apiResponse2(0, 'same_user', trans('cart.cant_purchase_your_course')); } if ($this->checkUserHasBought($user)) { return apiResponse2(0, 'already_bought', trans('site.you_bought_webinar')); } if ($this->notPassedRequiredPrerequisite2($user)) { return apiResponse2(0, 'required_prerequisites', trans('cart.this_course_has_required_prerequisite')); } return 'ok'; } public function checkWebinarForAccess($user) { $access = false; if ($this->checkUserHasBought($user)) { $isPrivate = $this->private; if (!empty($user) and ($user->id == $this->creator_id or $user->organ_id == $this->creator_id or $user->isAdmin())) { $isPrivate = false; } $access = true; if ($isPrivate) { $access = false; } } return $access; } public function notPassedRequiredPrerequisite2($user) { $isRequiredPrerequisite = false; $prerequisites = $this->prerequisites; if (!empty($prerequisites)) { foreach ($prerequisites as $prerequisite) { $prerequisiteWebinar = $prerequisite->prerequisiteWebinar; if ($prerequisite->required and !empty($prerequisiteWebinar) and !$prerequisiteWebinar->checkUserHasBought($user)) { $isRequiredPrerequisite = true; } } } return $isRequiredPrerequisite; } } Api/Traits/WebinarChartTrait.php 0000644 00000017325 15102516312 0012615 0 ustar 00 <?php namespace App\Models\Api\Traits; use App\Http\Resources\UserResource; use App\Models\Api\Quiz; use App\Models\Api\QuizzesResult; use App\Models\Api\User; use App\Models\Role; use App\Models\Sale; use App\Models\WebinarAssignmentHistory; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; trait WebinarChartTrait { public function getStudentsIdsAttribute() { return Sale::where('webinar_id', $this->id) ->whereNull('refund_at') ->pluck('buyer_id') ->toArray(); } public function getStudentsRolesAttribute() { $labels = [ trans('public.students'), trans('public.instructors'), trans('home.organizations'), ]; $studentsIds = Sale::where('webinar_id', $this->id) ->whereNull('refund_at') ->pluck('buyer_id') ->toArray(); $users = User::whereIn('id', $studentsIds) ->select('id', 'role_name', DB::raw('count(id) as count')) ->groupBy('role_name') ->get(); $data['students'] = 0; $data['instructors'] = 0; $data['organizations'] = 0; foreach ($users as $user) { if ($user->role_name == Role::$user) { $data['students'] = $user->count; } else if ($user->role_name == Role::$teacher) { $data['instructors'] = $user->count; } else if ($user->role_name == Role::$organization) { $data['organizations'] = $user->count; } } return $data; return [ 'labels' => $labels, 'data' => $data ]; } public function getQuizStatusAttribute() { $labels = [ trans('quiz.passed'), trans('public.pending'), trans('quiz.failed'), ]; $data[0] = 0; // passed $data[1] = 0; // pending $data[2] = 0; // failed $quizzes = $this->quizzes; foreach ($quizzes as $quiz) { $passed = $quiz->quizResults()->where('status', QuizzesResult::$passed)->count(); $pending = $quiz->quizResults()->where('status', QuizzesResult::$waiting)->count(); $failed = $quiz->quizResults()->where('status', QuizzesResult::$failed)->count(); $data[0] += $passed; $data[1] += $pending; $data[2] += $failed; } return array_combine($labels, $data); } public function getAssignmentsStatusAttribute() { $labels = [ trans('quiz.passed'), trans('public.pending'), trans('quiz.failed'), ]; $data[0] = 0; // passed $data[1] = 0; // pending $data[2] = 0; // failed $assignments = $this->assignments; foreach ($assignments as $quiz) { $passed = $quiz->assignmentHistory()->where('status', WebinarAssignmentHistory::$passed)->count(); $pending = $quiz->assignmentHistory()->where('status', WebinarAssignmentHistory::$pending)->count(); $failed = $quiz->assignmentHistory()->where('status', WebinarAssignmentHistory::$notPassed)->count(); $data[0] += $passed; $data[1] += $pending; $data[2] += $failed; } return array_combine($labels, $data); } public function getMonthlySalesAttribute() { $labels = []; $data = []; for ($month = 1; $month <= 12; $month++) { $date = Carbon::create(date('Y'), $month); $start_date = $date->timestamp; $end_date = $date->copy()->endOfMonth()->timestamp; $labels[] = trans('panel.month_' . $month); $amount = Sale::whereNull('refund_at') ->whereBetween('created_at', [$start_date, $end_date]) ->where('webinar_id', $this->id) ->sum('total_amount'); $data[] = round($amount, 2); } return array_combine($labels, $data); } public function getCourseProgressAttribute() { $labels = [ trans('update.completed'), trans('webinars.in_progress'), trans('update.not_started'), ]; $data[0] = 0; // completed $data[1] = 0; // in_progress $data[2] = 0; // not_started foreach ($this->StudentsIds as $userId) { $progress = $this->getCourseProgressForStudent($this, $userId); if ($progress > 0 and $progress < 100) { $data[1] += 1; } elseif ($progress == 100) { $data[0] += 1; } else { $data[2] += 1; } } return array_combine($labels, $data); } public function getCourseProgressLineAttribute() { $labels = []; $data = []; $progress = []; foreach ($this->StudentsIds as $userId) { $progress[] = $this->getCourseProgressForStudent($this, $userId); } for ($percent = 0; $percent < 100; $percent += 10) { $endPercent = $percent + 10; $labels[] = $percent . '-' . $endPercent; $count = 0; foreach ($progress as $value) { if ($value >= $percent and $value < $endPercent) { $count += 1; } } $data[] = $count; } return array_combine($labels, $data); } public function getCourseProgressForStudent($webinar, $userId) { $progress = 0; $filesStat = $webinar->getFilesLearningProgressStat($userId); $sessionsStat = $webinar->getSessionsLearningProgressStat($userId); $textLessonsStat = $webinar->getTextLessonsLearningProgressStat($userId); $assignmentsStat = $webinar->getAssignmentsLearningProgressStat($userId); $quizzesStat = $webinar->getQuizzesLearningProgressStat($userId); $passed = $filesStat['passed'] + $sessionsStat['passed'] + $textLessonsStat['passed'] + $assignmentsStat['passed'] + $quizzesStat['passed']; $count = $filesStat['count'] + $sessionsStat['count'] + $textLessonsStat['count'] + $assignmentsStat['count'] + $quizzesStat['count']; if ($passed > 0 and $count > 0) { $progress = ($passed * 100) / $count; } return round($progress, 2); } public function getStudents() { $webinar = $this; $users = User::whereIn('id', $this->studentsIds) ->paginate(10); $quizzesIds = $webinar->quizzes->pluck('id')->toArray(); $assignmentsIds = $webinar->assignments->pluck('id')->toArray(); foreach ($users as $user) { $user->course_progress = $this->getCourseProgressForStudent($webinar, $user->id); $user->passed_quizzes = Quiz::whereIn('quizzes.id', $quizzesIds) ->join('quizzes_results', 'quizzes_results.quiz_id', 'quizzes.id') ->select(DB::raw('count(quizzes_results.id) as count')) ->where('quizzes_results.user_id', $user->id) ->where('quizzes_results.status', QuizzesResult::$passed) ->first()->count; $assignmentsHistoriesCount = WebinarAssignmentHistory::whereIn('assignment_id', $assignmentsIds) ->where('student_id', $user->id) ->count(); $user->unsent_assignments = count($assignmentsIds) - $assignmentsHistoriesCount; $user->pending_assignments = WebinarAssignmentHistory::whereIn('assignment_id', $assignmentsIds) ->where('student_id', $user->id) ->where('status', WebinarAssignmentHistory::$pending) ->count(); } return UserResource::collection($users); } } Api/Traits/UploaderTrait.php 0000644 00000000541 15102516312 0012007 0 ustar 00 <?php namespace App\Models\Api\Traits; trait UploaderTrait { public function storage( $file) { if (!$file ) { return null; } $fileName = $file->getClientOriginalName(); $path = apiAuth()->id; $storage_path = $file->storeAs($path, $fileName); return 'store/' . $storage_path; } } Api/Meeting.php 0000644 00000004612 15102516312 0007355 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Meeting as Model; use App\Http\Controllers\Api\Config\ConfigController; class Meeting extends Model { public function getDetailsAttribute() { return [ 'time_zone' => $this->getTimezone(), 'gmt' => toGmtOffset($this->getTimezone()), 'id' => $this->id, 'disabled' => $this->disabled, 'discount' => $this->discount, 'price' => nicePrice($this->amount), 'price_with_discount' => ($this->discount) ? nicePrice($this->amount - (($this->amount * $this->discount) / 100)) : $this->amount, 'in_person' => $this->in_person, 'in_person_price' => nicePrice($this->in_person_amount), 'in_person_price_with_discount' => nicePrice($this->in_person_amount - (($this->in_person_amount * $this->discount) / 100)), 'in_person_group_min_student' => $this->in_person_group_min_student, 'in_person_group_max_student' => $this->in_person_group_max_student, 'in_person_group_amount ' => $this->in_person_group_amount, 'group_meeting' => $this->group_meeting, 'online_group_min_student' => $this->online_group_min_student, 'online_group_max_student' => $this->online_group_max_student, 'online_group_amount' => $this->online_group_amount, 'timing' => $this->meetingTimes->map(function ($time) { return [ 'id' => $time->id, 'day_label' => $time->day_label, 'time' => $time->time, ]; }), 'timing_group_by_day' => $this->meetingTimes->groupBy('day_label')->map(function ($time) { return $time->map(function ($ee) { return [ 'id' => $ee->id, 'day_label' => $ee->day_label, 'time' => $ee->time, ]; }); }), ]; } public function teacher() { return $this->belongsTo('App\Models\Api\User', 'teacher_id', 'id'); } public function creator() { return $this->belongsTo('App\Models\Api\User', 'creator_id', 'id'); } public function meetingTimes() { return $this->hasMany('App\Models\Api\MeetingTime', 'meeting_id', 'id'); } } Api/SupportConversation.php 0000644 00000001516 15102516312 0012034 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\SupportConversation as Model ; class SupportConversation extends Model{ public function getBriefAttribute(){ return [ 'message' => $this->message, 'sender' =>($this->sender_id) ?[ 'id' => $this->sender->id, 'full_name' => $this->sender->full_name, 'avatar' => url($this->sender->getAvatar()), ]:null , 'supporter' => ($this->supporter_id) ? [ 'id' => $this->supporter->id, 'full_name' => $this->supporter->full_name, 'avatar' => url($this->supporter->getAvatar()), ] : null, 'attach'=>($this->attach)?url($this->attach):null , 'created_at' => $this->created_at , ]; } } Api/Sale.php 0000644 00000006222 15102516312 0006650 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\Sale as WebSale ; class Sale extends WebSale{ public function getDetailsAttribute(){ return[ 'buyer' => $this->buyer->brief, 'type' => $this->type, 'payment_method' => $this->payment_method, 'created_at' => $this->created_at, 'amount' => $this->amount, 'discount' => $this->discount, 'total_amount' => $this->total_amount, 'income' => $this->getIncomeItem(), 'webinar' => ($this->webinar_id) ? $this->webinar->brief: null, 'meeting' => ($this->meeting_id) ? $this->meeting->details: null, ]; } public function scopeHandleFilters($query){ $request=request() ; $from = $request->input('from'); $to = $request->input('to'); $student_id = $request->input('student_id'); $webinar_id = $request->input('webinar_id'); $type = $request->input('type'); if (!empty($from) and !empty($to)) { $from = strtotime($from); $to = strtotime($to); $query->whereBetween('created_at', [$from, $to]); } else { if (!empty($from)) { $from = strtotime($from); $query->where('created_at', '>=', $from); } if (!empty($to)) { $to = strtotime($to); $query->where('created_at', '<', $to); } } if (isset($type) && $type !== 'all') { $query->where('type', $type); } if (!empty($student_id) and $student_id != 'all') { $query->where('buyer_id', $student_id); } if (!empty($webinar_id) and $webinar_id != 'all') { $query->where('webinar_id', $webinar_id); } return $query; } public function getItemTypeAttribute(){ if ($this->webinar_id) { $type = 'class'; } elseif ($this->meeting_id) { $type = 'meeting'; } else { $type = null; } return $type ; } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function buyer() { return $this->belongsTo('App\Models\Api\User', 'buyer_id', 'id'); } public function seller() { return $this->belongsTo('App\Model\Api\User', 'seller_id', 'id'); } public function meeting() { return $this->belongsTo('App\Models\Api\Meeting', 'meeting_id', 'id'); } public function subscribe() { return $this->belongsTo('App\Models\Subscribe', 'subscribe_id', 'id'); } public function promotion() { return $this->belongsTo('App\Models\Promotion', 'promotion_id', 'id'); } public function order() { return $this->belongsTo('App\Models\Order', 'order_id', 'id'); } public function ticket() { return $this->belongsTo('App\Models\Ticket', 'ticket_id', 'id'); } public function saleLog() { return $this->hasOne('App\Models\SaleLog', 'sale_id', 'id'); } } Api/File.php 0000644 00000005557 15102516312 0006655 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\Traits\CheckWebinarItemAccessTrait; use App\Models\File as WebFile; class File extends WebFile { use CheckWebinarItemAccessTrait; public function getDetailsAttribute() { return [ // 'icon_by_type' => $this->getIconByType(), 'id' => $this->id, 'title' => $this->title, 'auth_has_read' => $this->read, 'status' => $this->status, 'order' => $this->order, 'downloadable' => $this->downloadable, 'accessibility' => $this->accessibility, 'description' => $this->description, 'storage' => $this->storage, 'download_link' => $this->webinar->getUrl() . '/file/' . $this->id . '/download', 'auth_has_access' => $this->auth_has_access, 'user_has_access' => $this->user_has_access, 'file' => $this->file(), // 'file' => $this->storage == 'local' ? url("/course/" . $this->webinar->slug . "/file/" . $this->id . "/play") : $this->file, 'volume' => $this->volume, 'file_type' => $this->file_type, 'is_video' => $this->isVideo(), 'interactive_type' => $this->interactive_type, 'interactive_file_name' => $this->interactive_file_name, 'interactive_file_path' => ($this->interactive_file_path) ? url($this->interactive_file_path) : null, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; } public function file() { if (!$this->file) { return null; } if (strstr($this->file, 'iframe') or strstr($this->file, 'https')) { return $this->file; } return url($this->file); } public function getUserHasAccessAttribute() { $user = apiAuth(); $access = false; $hasBought = $this->webinar->checkUserHasBought($user); if ($this->accessibility == 'paid') { if ($user and $hasBought) { $access = true; } } else { $access = true; } return $access; } public function getAuthHasAccessAttribute() { $user = apiAuth(); $canAccess = null; if ($user) { $canAccess = true; if ($this->accessibility == 'paid') { $canAccess = ($this->webinar->checkUserHasBought($user)) ? true : false; } } return $canAccess; } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function getReadAttribute() { $user = apiAuth(); if (!$user) { return null; } return ($this->learningStatus()->where('user_id', $user->id)->count()) ? true : false; } } Api/BundleWebinar.php 0000644 00000000541 15102516312 0010503 0 ustar 00 <?php namespace App\Models\Api; use Illuminate\Database\Eloquent\Model; class BundleWebinar extends Model { public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Api\Bundle', 'bundle_id', 'id'); } } Api/CourseForum.php 0000644 00000001665 15102516312 0010243 0 ustar 00 <?php namespace App\Models\Api; use App\Http\Controllers\Api\UploadFileManager; use App\Models\Api\Traits\UploaderTrait; use App\Models\CourseForum as Model; class CourseForum extends Model { use UploaderTrait; public function setAttachAttribute($value) { $path = $this->storage($value); $this->attributes['attach'] = $path ?: $this->attributes['attach']??null; } public function scopeHandleFilters($query) { $search = request()->get('search'); if (!empty($search)) { $query->where(function ($query) use ($search) { $query->where('title', 'like', "%$search%"); $query->orWhere('description', 'like', "%$search%"); $query->orWhereHas('answers', function ($query) use ($search) { $query->where('description', 'like', "%$search%"); }); }); } return $query; } } Api/MeetingTime.php 0000644 00000000354 15102516312 0010173 0 ustar 00 <?php namespace App\Models\Api; use App\Models\MeetingTime as Model; class MeetingTime extends Model { // public function meeting() { return $this->belongsTo('App\Models\Api\Meeting', 'meeting_id', 'id'); } } Api/Bundle.php 0000644 00000001521 15102516312 0007172 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\Traits\CheckForSaleTrait; use App\Models\Favorite; use App\Models\Bundle as Model; class Bundle extends Model { use CheckForSaleTrait; public function getIsFavoriteAttribute() { if (!apiAuth()) { return null; } return (bool)Favorite::where('bundle_id', $this->id) ->where('user_id', apiAuth()->id) ->first(); } public function bundleWebinars() { return $this->hasMany('App\Models\Api\BundleWebinar', 'bundle_id', 'id'); } public function webinars() { // return $this->hasManyThrough('App\Models\Webinar', 'App\Models\BundleWebinar', 'bundle_id', 'id'); } public function teacher() { return $this->belongsTo('App\Models\Api\User', 'teacher_id', 'id'); } } Api/TrendCategory.php 0000644 00000001725 15102516312 0010541 0 ustar 00 <?php namespace App\Models\Api; use App\Models\TrendCategory as Model; class TrendCategory extends Model { // public function getDetailsAttribute(){ return [ 'id' => $this->category->id, 'title' => $this->category->title, 'color' =>$this->color, 'icon' =>($this->icon)? url($this->icon):null, 'sub_categories' => $this->category->subCategories->map(function ($sub_category) use (&$all_webinar_count) { $all_webinar_count += $sub_category->webinars->count(); return [ 'id' => $sub_category->id, 'title' => $sub_category->title, 'icon' =>($sub_category->icon)? url($sub_category->icon):null, 'webinars_count' => $sub_category->webinars->count(), ]; }), 'webinars_count' => $all_webinar_count ?? $this->category->webinars->count() ]; } } Api/Subscribe.php 0000644 00000001076 15102516312 0007707 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Subscribe as Model; class Subscribe extends Model { // public function getDetailsAttribute(){ return [ 'id'=>$this->id , 'title'=>$this->title , 'description'=>$this->description , 'usable_count'=>$this->usable_count , 'days'=>$this->days , 'price'=>$this->price , 'is_popular'=>$this->is_popular , 'image'=>($this->icon)?url($this->icon):null , 'created_at'=>$this->created_at , ] ; } } Api/Category.php 0000644 00000001747 15102516312 0007550 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Category as Model; class Category extends Model { // public function getDetailsAttribute() { return [ 'id' => $this->id, 'title' => $this->title, 'color' => TrendCategory::where('category_id', $this->id)->first()->color ?? null, 'icon' =>($this->icon)? url($this->icon):null, 'sub_categories' => $this->subCategories->map(function ($sub_category) use (&$all_webinar_count) { $all_webinar_count += $sub_category->webinars->count(); return [ 'id' => $sub_category->id, 'title' => $sub_category->title, 'icon' => ($sub_category->icon) ? url($sub_category->icon) : null, 'webinars_count' => $sub_category->webinars->count(), ]; }), 'webinars_count' => $all_webinar_count ?? $this->webinars->count() ]; } } Api/Blog.php 0000644 00000004020 15102516312 0006641 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Blog as Model; class Blog extends Model { public function getDetailsAttribute() { return [ 'id' => $this->id, 'title' => $this->title, 'image' =>($this->image)? url($this->image):null, 'description' => truncate($this->description, 160), 'content' => $this->content, 'created_at' => $this->created_at, 'locale'=>$this->locale , 'author' => $this->author->brief, 'comment_count' => $this->comments()->where('status','active')->count(), 'comments' => $this->comments()->where('status','active') ->get()->map(function ($item) { return $item->details ; }), 'category'=>$this->category->title , ]; } public function getBriefAttribute(){ return [ 'id' => $this->id, 'title' => $this->title, 'image' =>($this->image)? url($this->image):null, 'description' => truncate($this->description, 160), 'created_at' => $this->created_at, 'author' => $this->author->brief, 'comment_count' => $this->comments->count(), 'category'=>$this->category->title , ]; } public function author() { return $this->belongsTo('App\Models\Api\User', 'author_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Api\Comment', 'blog_id', 'id'); } public function scopeHandleFilters( $query) { $request=request() ; $offset = $request->get('offset', null); $limit = $request->get('limit', null); $category=$request->get('cat',null) ; if (!empty($offset) && !empty($limit)) { $query->skip($offset); } if (!empty($limit)) { $query->take($limit); } if($category){ $query->where('category_id',$category) ; } return $query; } } Api/WebinarChapterItem.php 0000644 00000006453 15102516312 0011507 0 ustar 00 <?php namespace App\Models\Api; use App\Http\Resources\FileResource; use App\Http\Resources\SessionResource; use App\Http\Resources\TextLessonResource; use App\Http\Resources\WebinarAssignmentResource; use App\Models\WebinarChapterItem as Model; class WebinarChapterItem extends Model { public function getItemResource() { $type = $this->type; if ($type == self::$chapterFile) { return [ 'id' => $this->item->id, 'title' => $this->item->title, 'file_type' => $this->item->file_type, 'storage' => $this->item->storage, 'volume' => $this->item->volume, 'downloadable' => $this->item->downloadable, // 'auth_has_read'=>$this->item->auth_has_read ]; // return new FileResource($this->file); } elseif ($type == self::$chapterSession) { return [ 'id' => $this->item->id, 'title' => $this->item->title, 'date' => $this->item->date, 'auth_has_read' => $this->item->auth_has_read ]; // return new SessionResource($this->session); } elseif ($type == self::$chapterTextLesson) { return [ 'id' => $this->item->id, 'title' => $this->item->title, 'summary' => $this->item->summary, ]; return new TextLessonResource($this->textLesson); } elseif ($type == self::$chapterQuiz) { return [ 'id' => $this->item->id, 'title' => $this->item->title, 'time' => $this->item->time, 'question_count' => $this->item->quizQuestions->count(), 'auth_status' => $this->auth_status, // 'created_at' => $this->item->created_at, ]; // return $this->quiz(); } elseif ($type == self::$chapterAssignment) { return [ 'id' => $this->item->id, 'title' => $this->item->title, ]; return new WebinarAssignmentResource($this->assignment); } return []; } public function item() { $type = $this->type; if ($type == self::$chapterFile) { return $this->file(); } elseif ($type == self::$chapterSession) { return $this->session(); } elseif ($type == self::$chapterTextLesson) { return $this->textLesson(); } elseif ($type == self::$chapterQuiz) { return $this->quiz(); } elseif ($type == self::$chapterAssignment) { return $this->assignment(); } return []; } public function session() { return $this->belongsTo('App\Models\Api\Session', 'item_id', 'id'); } public function file() { return $this->belongsTo('App\Models\Api\File', 'item_id', 'id'); } public function textLesson() { return $this->belongsTo('App\Models\Api\TextLesson', 'item_id', 'id'); } public function assignment() { return $this->belongsTo('App\Models\Api\WebinarAssignment', 'item_id', 'id'); } public function quiz() { return $this->belongsTo('App\Models\Api\Quiz', 'item_id', 'id'); } } Api/Certificate.php 0000644 00000003053 15102516312 0010205 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Certificate as WebCertificate; class Certificate extends WebCertificate { public function getDetailsAttribute() { return [ 'id' => $this->id, 'user_grade' => $this->user_grade, 'user' => $this->student->brief, 'quiz' => $this->quiz->details, 'quiz_result' => $this->quizzesResult->details, 'file' => ($this->file) ? url($this->file) : null, 'created_at' => $this->created_at, ]; } public function getBriefAttribute() { return [ 'id' => $this->id, 'user_grade' => $this->user_grade, 'file' => ($this->file) ? url($this->file) : null, 'created_at' => $this->created_at, ]; } public function scopeHandleFilter($query) { $request = request(); $from = $request->get('from'); $to = $request->get('to'); $webinar_id = $request->get('webinar_id'); fromAndToDateFilter($from, $to, $query, 'created_at'); if (!empty($webinar_id)) { $query->where('webinar_id', $webinar_id); } return $query; } public function quiz() { return $this->hasOne('App\Models\Api\Quiz', 'id', 'quiz_id'); } public function student() { return $this->hasOne('App\Models\Api\User', 'id', 'student_id'); } public function quizzesResult() { return $this->hasOne('App\Models\Api\QuizzesResult', 'id', 'quiz_result_id'); } } Api/Quiz.php 0000644 00000021344 15102516312 0006716 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\QuizzesResult; use App\Models\Api\Traits\CheckWebinarItemAccessTrait; use App\Models\Quiz as Model; use App\User; use App\Models\Role; use Illuminate\Support\Facades\Auth; use Illuminate\Auth\Events\Failed; class Quiz extends Model { use CheckWebinarItemAccessTrait ; public function getBriefAttribute() { return [ 'id' => $this->id, 'title' => $this->title, 'time' => $this->time, 'auth_status' => $this->auth_status, 'question_count' => $this->quizQuestions->count(), 'total_mark' => $this->quizQuestions->sum('grade'), 'pass_mark' => $this->pass_mark, 'average_grade' => $this->average_grade, 'student_count' => $this->quizResults->pluck('user_id')->count(), 'certificates_count' => $this->certificates->count(), 'success_rate' => $this->success_rate, 'status' => $this->status, 'attempt' => $this->attempt, 'created_at' => $this->created_at, 'certificate' => $this->certificate, 'teacher' => $this->creator->brief, /**********************/ 'auth_attempt_count' => $this->auth_attempt_count, 'attempt_state' => $this->attempt_state, 'auth_can_start' => $this->auth_can_take_quiz, 'webinar' => $this->webinar->brief, ]; } public function getDetailsAttribute() { $details = [ 'questions' => $this->quizQuestions->map(function ($question) { return $question->details; }), 'chapter' => ($this->chapter) ? $this->chapter->details : null, 'auth_can_download_certificate' => $this->auth_can_download_certificate, 'participated_count' => $this->quizResults->count(), 'latest_students' => $this->latest_students, ]; return array_merge($this->brief, $details); } public function getAuthCanTakeQuizStatusAttribute() { $user = apiAuth(); if (!$user) { return null; } $status = 'ok'; $hasBought = $this->webinar->checkUserHasBought($user); if (!$hasBought) { $status = 'not_purchased'; } elseif ($this->auth_passed_quiz) { $status = 'passed'; } // !$this->results && $this->status == QuizzesResult::$waiting elseif (isset($this->attempt) and $this->auth_attempt_count >= $this->attempt ) { $status = 'max_attempt'; } return $status; } public function getAuthCanTakeQuizAttribute() { $user = apiAuth(); if (!$user) { return null; } if ($this->auth_can_take_quiz_status == 'ok') { return true; } return false; } public function getAuthPassedQuizAttribute() { $user = apiAuth(); if (!$user) { return null; } $userQuizDone = $this->auth_results; $status_pass = false; foreach ($userQuizDone as $result) { if ($result->status == QuizzesResult::$passed) { $status_pass = true; } } return $status_pass; } public function getAuthAttemptCountAttribute() { if ($this->auth_results) { return $this->auth_results->count(); } return null; } public function getCountTryAgainAttribute() { if (!$this->auth_can_take_quiz) { return 0; } if (!$this->attempt) { return 'unlimited'; } $diff = $this->attempt - $this->auth_results->count(); return ($diff >= 0) ? $diff : 0; } public function getAuthResultsAttribute() { // $user->quizResults->where('quiz_id', $this->id) $user = apiAuth(); if (!$user) { return null; } $userQuizDone = QuizzesResult::where('quiz_id', $this->id) ->where('user_id', $user->id) ->orderBy('id', 'desc') ->get(); return $userQuizDone; } public function getAttemptStateAttribute() { $a = (!empty(apiAuth()) and !empty($this->auth_results)) ? $this->auth_results->count() : '0'; return $a . '/' . $this->attempt; } public function getAuthCanDownloadCertificateAttribute() { if (!apiAuth()) { return null; } $canDownloadCertificate = false; if (!$this->certificate) { return false; } $user_passed_quiz = apiAuth()->quizResults->where('quiz_id', $this->id)->where('status', 'passed'); if ($user_passed_quiz->count()) { $canDownloadCertificate = true; } return $canDownloadCertificate; } public function getSuccessRateAttribute() { if ($this->quizResults->count()) { return round($this->quizResults->where('status', QuizzesResult::$passed)->pluck('user_id')->count() / $this->quizResults->count() * 100); } return 0; } public function getLatestStudentsAttribute() { /// return 'f' ; return $this->quizResults()->orderBy('created_at', 'desc')->groupBy('user_id')->get()->map(function ($result) { return $result->user->brief/// ->user() ; }); } public function getAverageGradeAttribute() { // $quiz->avg_grade = $quizResults->where('status', \App\Models\QuizzesResult::$passed)->avg('user_grade'); return round($this->quizResults->where('status', QuizzesResult::$passed)->avg('user_grade'),2); } public function getAuthStatusAttribute() { $user = apiAuth(); if (!$user) { return null; } $user_quiz_result = $user->quizResults()-> where('quiz_id', $this->id) ->orderBy('id', 'desc') ->get(); if (!$user_quiz_result->count()) { return 'not_participated'; } if ($user_quiz_result->where('status', 'passed')->count() > 0) { return 'passed'; } if ($user_quiz_result->first()->status == 'waiting') { return 'waiting'; } if ($user_quiz_result->first()->status == 'failed') { return 'failed'; } return null; } public function scopeHandleFilters($query) { $request = request(); $from = $request->get('from', null); $to = $request->get('to', null); $quiz_id = $request->get('quiz_id', null); $total_mark = $request->get('total_mark', null); $status = $request->get('status', null); $user_id = $request->get('user_id', null); $creator_id = $request->get('creator_id', null); $webinar_id = $request->get('webinar_id', null); $instructor = $request->get('instructor', null); $open_results = $request->get('open_results', null); $query = fromAndToDateFilter($from, $to, $query, 'created_at'); if (!empty($webinar_id)) { $query->where('webinar_id', $webinar_id); } if (!empty($quiz_id) and $quiz_id != 'all') { $query->where('quiz_id', $quiz_id); } if ($total_mark) { $query->where('total_mark', $total_mark); } if (!empty($user_id) and $user_id != 'all') { $query->where('user_id', $user_id); } if (!empty($creator_id) and $creator_id != 'all') { $query->where('creator_id', $creator_id); } if ($instructor) { $userIds = User::whereIn('role_name', [Role::$teacher, Role::$organization]) ->where('full_name', 'like', '%' . $instructor . '%') ->pluck('id')->toArray(); $query->whereIn('creator_id', $userIds); } if ($status and $status != 'all') { $query->where('status', strtolower($status)); } if (!empty($open_results)) { $query->where('status', 'waiting'); } return $query; } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function chapter() { return $this->belongsTo('App\Models\Api\WebinarChapter', 'webinar_id', 'id'); } public function quizResults() { return $this->hasMany('App\Models\Api\QuizzesResult', 'quiz_id', 'id'); } public function quizQuestions() { return $this->hasMany('App\Models\Api\QuizzesQuestion', 'quiz_id', 'id'); } public function creator() { return $this->belongsTo('App\Models\Api\User', 'creator_id', 'id'); } } Api/WebinarAssignmentHistoryMessage.php 0000644 00000000552 15102516312 0014273 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\Traits\UploaderTrait; use App\Models\WebinarAssignmentHistoryMessage as Model; class WebinarAssignmentHistoryMessage extends Model { use UploaderTrait; public function setFilePathAttribute($value) { $path = $this->storage($value); $this->attributes['file_path'] = $path; } } Api/ProductOrder.php 0000644 00000002206 15102516312 0010376 0 ustar 00 <?php namespace App\Models\Api; //use Illuminate\Database\Eloquent\Model; use App\Models\ProductOrder as Model; class ProductOrder extends Model { public function scopeHandleFilters($query) { $request = request(); $from = $request->input('from'); $to = $request->input('to'); $customer_id = $request->input('customer_id'); $seller_id = $request->input('seller_id'); $type = $request->input('type'); $status = $request->input('status'); $query = fromAndToDateFilter($from, $to, $query, 'created_at'); if (!empty($seller_id) and $seller_id != 'all') { $query->where('seller_id', $seller_id); } if (!empty($customer_id) and $customer_id != 'all') { $query->where('buyer_id', $customer_id); } if (isset($type) and $type !== 'all') { $query->whereHas('product', function ($query) use ($type) { $query->where('type', $type); }); } if (isset($status) and $status !== 'all') { $query->where('status', $status); } return $query; } } Api/TextLessonAttachment.php 0000644 00000000700 15102516312 0012100 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\TextLessonAttachment as PrimaryModel; class TextLessonAttachment extends PrimaryModel { public function file() { return $this->belongsTo('App\Models\Api\File', 'file_id', 'id'); } public function getDetailsAttribute(){ return $this->file->details ; return [ 'id'=>$this->id , 'file'=>$this->file->details ] ; } } Api/Webinar.php 0000644 00000076025 15102516312 0007363 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\Traits\CheckForSaleTrait; use App\Models\Api\Traits\WebinarChartTrait; use App\Models\CourseForum; use App\Models\Webinar as Model; use App\Models\Sale; use App\Models\Ticket; use App\Models\WebinarChapterItem; use App\Models\WebinarFilterOption; use App\Models\CourseLearning; use Illuminate\Support\Facades\DB; class Webinar extends Model { use WebinarChartTrait; use CheckForSaleTrait; public function can_view_error() { $error = null; $user = apiAuth(); if ($user) { if (!$user->access_content) { $error = [trans('update.not_access_to_content'), trans('update.not_access_to_content_hint')]; } // return $user->private_content ? null : 'private_content'; } else { if (getFeaturesSettings('webinar_private_content_status')) { $error = [trans('update.private_content'), trans('update.private_content_login_hint')]; } // return !getFeaturesSettings('webinar_private_content_status'); } return $error; } public function getBriefAttribute() { if (!$this) { return null; } $user = apiAuth(); $hasBought = $this->checkUserHasBought($user); // $sale = Sale::where('buyer_id', $user->id)->where('webinar_id', $this->id)->first(); return [ 'image' => url($this->getImage()), 'auth' => ($user) ? true : false, 'can' => [ 'view' => !$this->can_view_error(), ], 'can_view_error' => $this->can_view_error(), 'id' => $this->id, 'status' => $this->status, 'label' => $this->label, 'title' => $this->title, 'type' => $this->type, 'link' => $this->getUrl(), // getExpiredAccessDays 'access_days' => $this->access_days, // 'expired' => ($sale and $this->access_days and !$this->checkHasExpiredAccessDays($sale->created_at)), // 'expire_on' => ($sale and $this->getExpiredAccessDays($sale->created_at) ) ? $this->getExpiredAccessDays($sale->created_at) : null, // 'expired' => ($sale and $this->checkHasExpiredAccessDays($sale->created_at)) ?$this->getExpiredAccessDays($sale->created_at) : false, 'live_webinar_status' => $this->liveWebinarStatus(), 'auth_has_bought' => ($user) ? $hasBought : null, 'sales' => [ 'count' => $this->sales->count(), 'amount' => $this->sales->sum('amount'), ], 'is_favorite' => $this->isFavorite(), 'price_string' => ($this->price > 0) ? handlePrice($this->price) : null, 'best_ticket_string' => ($this->price > 0 and $this->bestTicket() < $this->price) ? handlePrice($this->bestTicket()) : null, 'price' => nicePriceWithTax($this->price)['price'], 'tax' => nicePriceWithTax($this->price)['tax'], 'tax_with_discount' => nicePriceWithTax($this->bestTicket(true)['bestTicket'])['tax'], 'best_ticket_price' => round(nicePriceWithTax($this->bestTicket(true)['bestTicket'])['price'], 3), 'discount_percent' => $this->bestTicket(true)['percent'], 'course_page_tax' => (!$this->activeSpecialOffer()) ? nicePriceWithTax($this->price)['tax'] : nicePriceWithTax(number_format($this->price - ($this->price * $this->activeSpecialOffer()->percent / 100), 2))['tax'] , 'price_with_discount' => nicePrice(($this->activeSpecialOffer()) ? ( number_format($this->price - ($this->price * $this->activeSpecialOffer()->percent / 100), 2)) : $this->price), 'discount_amount' => ((int)nicePriceWithTax($this->price)['price'] - (int)round(nicePriceWithTax($this->bestTicket(true)['bestTicket'])['price'] )), 'active_special_offer' => $this->activeSpecialOffer() ?: null, // 'discount' => $this->getDiscount(), 'duration' => $this->duration, 'teacher' => $this->teacher->brief, 'students_count' => $this->sales->count(), 'rate' => $this->getRate(), 'rate_type' => [ 'content_quality' => $this->reviews->count() > 0 ? round($this->reviews->avg('content_quality'), 1) : 0, 'instructor_skills' => $this->reviews->count() > 0 ? round($this->reviews->avg('instructor_skills'), 1) : 0, 'purchase_worth' => $this->reviews->count() > 0 ? round($this->reviews->avg('purchase_worth'), 1) : 0, 'support_quality' => $this->reviews->count() > 0 ? round($this->reviews->avg('support_quality'), 1) : 0, ], 'created_at' => $this->created_at, 'start_date' => $this->start_date, 'purchased_at' => $this->purchasedDate(), 'reviews_count' => $this->reviews->pluck('creator_id')->count(), 'points' => $this->points, 'progress' => $this->progress(), 'progress_percent' => $this->getProgress(), 'category' => $this->category->title ?? null, 'capacity' => $this->capacity, ]; } public function getDiscount($ticket = null, $user = null) { $activeSpecialOffer = $this->activeSpecialOffer(); $discountOut = $activeSpecialOffer ? $this->price * $activeSpecialOffer->percent / 100 : 0; if (!empty($user) and !empty($user->getUserGroup()) and isset($user->getUserGroup()->discount) and $user->getUserGroup()->discount > 0) { $discountOut += $this->price * $user->getUserGroup()->discount / 100; } if (!empty($ticket)) { $discountOut += $this->price * $ticket->discount / 100; } return $discountOut; } public function getDetailsAttribute() { $user = apiAuth(); $details = [ 'support' => $this->support ? true : false, 'subscribe' => $this->subscribe ? true : false, 'description' => $this->description, 'prerequisites' => $this->prerequisites() ->whereHas('prerequisiteWebinar') ->orderBy('order', 'asc') ->get() ->map(function ($prerequisite) { if ($prerequisite->prerequisiteWebinar) { return [ 'required' => $prerequisite->required, 'webinar' => $prerequisite->prerequisiteWebinar->brief ?? null, ]; } }), 'faqs' => $this->faqs()->orderBy('order', 'asc') ->get() ->map(function ($faq) { return $faq->details; }), 'comments' => $this->comments() ->where('status', 'active') ->whereNull('reply_id') ->orderBy('created_at', 'desc') ->get() ->map(function ($comment) { return $comment->details; }), 'session_chapters' => $this->chapters() ->whereHas('chapterItems', function ($query) { $query->where('type', WebinarChapterItem::$chapterSession); }) ->where('status', WebinarChapter::$chapterActive) ->orderBy('order', 'asc') ->get() ->map(function ($chapter) { return $chapter->details; }), 'sessions_without_chapter' => $this->sessions() ->where('status', WebinarChapter::$chapterActive) ->orderBy('order', 'asc') ->whereNull('chapter_id') ->get()->map(function ($session) { return $session->details; }), 'sessions_count' => $this->sessions() ->where('status', WebinarChapter::$chapterActive) ->count(), 'files_chapters' => $this->chapters() ->whereHas('chapterItems', function ($query) { $query->where('type', WebinarChapterItem::$chapterFile); }) ->where('status', WebinarChapter::$chapterActive) // ->where('type', WebinarChapter::$chapterFile) ->orderBy('order', 'asc') ->get() ->map(function ($chapter) { return $chapter->details; }), 'files_without_chapter' => $this->files() ->where('status', WebinarChapter::$chapterActive) ->orderBy('order', 'asc') ->whereNull('chapter_id') ->get() ->map(function ($file) { return $file->details; }), 'files_count' => $this->files() ->where('status', WebinarChapter::$chapterActive) ->count(), 'text_lesson_chapters' => $this->chapters() ->whereHas('chapterItems', function ($query) { $query->where('type', WebinarChapterItem::$chapterTextLesson); }) ->where('status', WebinarChapter::$chapterActive) // ->where('type', WebinarChapter::$chapterTextLesson) ->get() ->map(function ($chapter) { return $chapter->details; }), 'text_lessons_without_chapter' => $this->textLessons() ->where('status', WebinarChapter::$chapterActive) ->orderBy('order', 'asc') ->whereNull('chapter_id') ->get() ->map(function ($file) { return $file->details; }), 'text_lessons_count' => $this->chapters() ->whereHas('chapterItems', function ($query) { $query->where('type', WebinarChapterItem::$chapterTextLesson); }) // ->where('type', WebinarChapter::$chapterTextLesson) ->count(), 'quizzes' => $this->quizzes() ->whereNull('chapter_id') ->where('status', 'active') ->get() ->map(function ($quiz) { return $quiz->brief; }), 'quizzes_count' => $this->quizzes->count(), 'certificate' => $this->quizzes->where('certificate', 1)->map(function ($quiz) { return $quiz->brief; }), 'auth_certificates' => $user ? $user->achievement_certificates($this) : [], 'reviews' => $this->reviews->where('status', 'active')->map(function ($review) { return $review->details; }), 'video_demo' => $this->video_demo ? url($this->video_demo) : null, 'video_demo_source' => $this->video_demo_source, 'image_cover' => $this->image_cover ? url($this->image_cover) : null, 'tickets' => $this->tickets->map(function ($ticket) { return $ticket->details; }), 'teacher' => $this->teacher->brief, 'isDownloadable' => $this->isDownloadable() ? true : false, 'teacher_is_offline' => $this->teacher->offline ? true : false, 'tags' => $this->tags->map(function ($tag) { return [ 'id' => $tag->id, 'title' => $tag->title ]; }), 'auth_has_subscription' => ($user) ? $user->hasActiveSubscription : null, 'can_add_to_cart' => $this->canAddToCart(), 'can_buy_with_points' => ($this->canSale() and !$this->checkUserHasBought($user) and !empty($this->points) and $this->price > 0), //////******************** ]; // return $details ; return array_merge($this->brief, $details); } public function getStudentsCountAttribute() { $studentsIds = Sale::where('webinar_id', $this->id) ->whereNull('refund_at') ->pluck('buyer_id') ->toArray(); return count(array_unique($studentsIds)); } public function pendingAssignments() { return $this->assignments()->where('status', 'active') ->whereHas('assignmentHistory', function ($query) { $query->where('status', 'pending'); }); } public function getQuizzesAverageGradeAttribute() { $quizzes = Quiz::where('webinar_id', $this->id) ->join('quizzes_results', 'quizzes_results.quiz_id', 'quizzes.id') ->select(DB::raw('avg(quizzes_results.user_grade) as result_grade')) ->whereIn('quizzes_results.status', ['passed', 'failed']) ->groupBy('quizzes_results.quiz_id') ->get(); return $quizzes->avg('result_grade'); } public function getAssignmentsAverageGradeAttribute() { $assignments = WebinarAssignment::where('webinar_id', $this->id) ->join('webinar_assignment_history', 'webinar_assignment_history.assignment_id', 'webinar_assignments.id') ->select(DB::raw('avg(webinar_assignment_history.grade) as result_grade')) ->whereIn('webinar_assignment_history.status', ['passed', 'not_passed']) ->groupBy('webinar_assignment_history.assignment_id') ->get(); return $assignments->avg('result_grade') ?? 0; } public function getForumsMessagesCountAttribute() { $forums = CourseForum::where('webinar_id', $this->id) ->join('course_forum_answers', 'course_forum_answers.forum_id', 'course_forums.id') ->select(DB::raw('count(course_forum_answers.id) as count')) ->groupBy('course_forum_answers.forum_id') ->get(); return $forums->sum('count') ?? 0; } public function getForumsStudentsCountAttribute($webinarId) { $forums = CourseForum::where('webinar_id', $webinarId) ->join('course_forum_answers', 'course_forum_answers.forum_id', 'course_forums.id') ->select(DB::raw('count(distinct course_forum_answers.user_id) as count')) ->groupBy('course_forum_answers.forum_id') ->get(); return $forums->sum('count') ?? 0; } public function getSalesAmountAttribute() { return Sale::where('webinar_id', $this->id) ->whereNull('refund_at') ->sum('total_amount'); } public function pendingQuizzes() { return $this->quizzes()->where('status', 'active') ->whereHas('quizResults', function ($query) { $query->where('status', 'waiting'); }); } public function getCommentsCountAttribute() { return Comment::where('webinar_id', $this->id) ->where('status', 'active') ->count(); } public function getLabelAttribute() { switch ($this->status) { case self::$active : if ($this->isWebinar()) { if ($this->start_date > time()) { return trans('panel.not_conducted'); } elseif ($this->isProgressing()) { return trans('webinars.in_progress'); } else { return trans('public.finished'); } } else { return trans('webinars.' . $this->type); } case self::$isDraft : return trans('public.draft'); case self::$pending : return trans('public.waiting'); case self::$inactive : return trans('public.rejected'); } } public function getSpecificationAttribute() { $array = []; $nextSession = $this->nextSession(); if ($this->isProgressing() and $nextSession) { $array['next_session_duration'] = $nextSession->duration; if ($this->isWebinar()) { $array['next_session_start_date'] = $nextSession->date; } } else { $array['duration'] = $this->duration; if ($this->isWebinar()) { $array['start_date'] = $this->start_date; } } if ($this->isTextCourse() or $this->isCourse()) { $array['files_count'] = $this->files->count(); } if ($this->isTextCourse()) { $array['text_lessions_count'] = $this->textLessons->count(); } if ($this->isCourse()) { $array['downloadable'] = (bool)$this->downloadable; } return $array; } public function scopeHandleFilters($query) { $request = request(); $onlyNotConducted = $request->get('not_conducted'); $offset = $request->get('offset', null); $limit = $request->get('limit', null); $upcoming = $request->get('upcoming', null); $isFree = $request->get('free', null); $withDiscount = $request->get('discount', null); $isDownloadable = $request->get('downloadable', null); $sort = $request->get('sort', null); $filterOptions = $request->get('filter_option', null); $type = $request->get('type', []); $moreOptions = $request->get('moreOptions', []); $category = $request->get('cat', null); $reward = $request->get('reward', null); if (!empty($reward) and $reward == 1) { $query->whereNotNull('points'); } if (!empty($onlyNotConducted)) { $query->where('status', 'active') ->where('start_date', '>', time()); } if (!empty($category) and is_numeric($category)) { $query->where('category_id', $category); } if (!empty($upcoming) and $upcoming == 1) { $query->whereNotNull('start_date') ->where('start_date', '>=', time()); } if (!empty($isFree) and $isFree == 1) { $query->where(function ($qu) { $qu->whereNull('price') ->orWhere('price', '0'); }); } if (!empty($isDownloadable) and $isDownloadable == 1) { $query->where('downloadable', 1); } if (!empty($withDiscount) and $withDiscount == 1) { $now = time(); $webinarIdsHasDiscount = []; $tickets = Ticket::where('start_date', '<', $now) ->where('end_date', '>', $now) ->get(); foreach ($tickets as $ticket) { if ($ticket->isValid()) { $webinarIdsHasDiscount[] = $ticket->webinar_id; } } $webinarIdsHasDiscount = array_unique($webinarIdsHasDiscount); $query->whereIn('webinars.id', $webinarIdsHasDiscount); } if (!empty($filterOptions)) { $webinarIdsFilterOptions = WebinarFilterOption::where('filter_option_id', $filterOptions) ->pluck('webinar_id') ->toArray(); $query->whereIn('webinars.id', $webinarIdsFilterOptions); } if (!empty($type)) { $query->where('type', $type); } if (!empty($moreOptions) and is_array($moreOptions)) { if (in_array('subscribe', $moreOptions)) { $query->where('subscribe', 1); } if (in_array('certificate_included', $moreOptions)) { $query->whereHas('quizzes', function ($query) { $query->where('certificate', 1) ->where('status', 'active'); }); } if (in_array('with_quiz', $moreOptions)) { $query->whereHas('quizzes', function ($query) { $query->where('status', 'active'); }); } if (in_array('featured', $moreOptions)) { $query->whereHas('feature', function ($query) { $query->whereIn('page', ['home_categories', 'categories']) ->where('status', 'publish'); }); } } if (!empty($offset) && !empty($limit)) { $query->skip($offset); } if (!empty($limit)) { $query->take($limit); } if (!empty($sort)) { if ($sort == 'expensive') { $query->orderBy('price', 'desc'); } if ($sort == 'inexpensive') { $query->orderBy('price', 'asc'); } if ($sort == 'bestsellers') { $query->leftJoin('sales', function ($join) { $join->on('webinars.id', '=', 'sales.webinar_id') ->whereNull('refund_at'); }) ->whereNotNull('sales.webinar_id') ->select('webinars.*', 'sales.webinar_id', DB::raw('count(sales.webinar_id) as salesCounts')) ->groupBy('sales.webinar_id') ->orderBy('salesCounts', 'desc'); } if ($sort == 'best_rates') { $query->leftJoin('webinar_reviews', function ($join) { $join->on('webinars.id', '=', 'webinar_reviews.webinar_id'); $join->where('webinar_reviews.status', 'active'); }) ->whereNotNull('rates') ->select('webinars.*', DB::raw('avg(rates) as rates')) ->groupBy('webinars.id') ->orderBy('rates', 'desc'); } if ($sort == 'newest') { $query->orderBy('created_at', 'desc'); } } else { $query->orderBy('webinars.created_at', 'desc') ->orderBy('webinars.updated_at', 'desc'); } return $query; } public function scopeValidWebinar($query) { return $query->where('private', false)->where('status', 'active'); } private function liveWebinarStatus() { $live_webinar_status = null; if ($this->type == 'webinar') { if ($this->start_date > time()) { $live_webinar_status = 'not_conducted'; } elseif ($this->isProgressing()) { $live_webinar_status = 'in_progress'; } else { $live_webinar_status = 'finished'; } } return $live_webinar_status; } public function progress() { $user = apiAuth(); /* progressbar status */ $hasBought = $this->checkUserHasBought($user); $progress = null; if ($hasBought or $this->isWebinar()) { if ($this->isWebinar()) { if ($hasBought and $this->isProgressing()) { $progress = $this->getProgress(); } else { $progress = ($this->capacity) ?: ($this->sales()->count() . '/' . $this->capacity); } } else { $progress = $this->getProgress(); } } return $progress; } public function getProgress($isLearningPage = false) { $progress = 0; $user = apiAuth(); if (!$user and !$this->isWebinar()) { return null; } if ($this->isWebinar()) { if ($user and ($this->isProgressing() or $isLearningPage) and $this->checkUserHasBought($user)) { $user_id = $user->id; $sessions = $this->sessions; $files = $this->files; $passed = 0; foreach ($files as $file) { $status = CourseLearning::where('user_id', $user_id) ->where('file_id', $file->id) ->first(); if (!empty($status)) { $passed += 1; } } foreach ($sessions as $session) { $status = CourseLearning::where('user_id', $user_id) ->where('session_id', $session->id) ->first(); if (!empty($status)) { $passed += 1; } } if ($passed > 0) { $progress = ($passed * 100) / ($sessions->count() + $files->count()); $this->handleLearningProgress100Reward($progress, $user_id, $this->id); } } else if (!empty($this->capacity)) { $salesCount = !empty($this->sales_count) ? $this->sales_count : $this->sales()->count(); if ($salesCount > 0) { $progress = ($salesCount * 100) / $this->capacity; } } } elseif ($this->checkUserHasBought($user)) { $user_id = $user->id; $files = $this->files; $textLessons = $this->textLessons; $passed = 0; foreach ($files as $file) { $status = CourseLearning::where('user_id', $user_id) ->where('file_id', $file->id) ->first(); if (!empty($status)) { $passed += 1; } } foreach ($textLessons as $textLesson) { $status = CourseLearning::where('user_id', $user_id) ->where('text_lesson_id', $textLesson->id) ->first(); if (!empty($status)) { $passed += 1; } } if ($passed > 0) { $progress = ($passed * 100) / ($files->count() + $textLessons->count()); $this->handleLearningProgress100Reward($progress, $user_id, $this->id); } } return round($progress, 2); } private function isFavorite() { $user = apiAuth(); $isFavorite = false; if (!empty($user)) { $isFavorite = Favorite::where('webinar_id', $this->id) ->where('user_id', $user->id) ->first(); } return ($isFavorite) ? true : false; } public function purchasedDate() { $user = apiAuth(); $sale = null; if ($user) { $sale = Sale::where('buyer_id', $user->id) ->whereNotNull('webinar_id') ->where('type', 'webinar') ->where('webinar_id', $this->id) ->whereNull('refund_at') ->first(); } return ($sale) ? $sale->created_at : null; } public function contentItems() { // if($this->ty) } public function canAddToCart($user = null) { if (!apiAuth()) { return null; } if (!$this->price) { return 'free'; } return $this->checkCourseForSale($user); } function checkCourseForSale($user = null) { $course = $this; $user = ($user) ?: apiAuth(); if ($this->expired) return 'expired'; if (!$this->hasCapacity) return 'no_capacity'; if ($this->sameUser) return 'same_user'; if ($course->checkUserHasBought($user)) return 'already_bought'; if ($this->notPassedRequiredPrerequisite()) return 'required_prerequisites'; return 'ok'; } function checkCourseForSaleMsg($user = null) { $status = $this->checkCourseForSale(); if ($status == 'expired') { return trans('cart.course_not_capacity'); } elseif ($status == 'no_capacity') { return trans('cart.course_not_capacity'); } elseif ($status == 'already_bought') { return trans('site.you_bought_webinar'); } elseif ($status == 'same_user') { return trans('cart.cant_purchase_your_course'); } elseif ($status == 'required_prerequisites') { return trans('cart.this_course_has_required_prerequisite'); } elseif ($status == 'ok') { } } public function getExpiredAttribute() { if ($this->type == self::$webinar) { return ($this->start_date < time()); } return false; } public function getHasCapacityAttribute() { $salesCount = !empty($this->sales_count) ? $this->sales_count : $this->sales()->count(); if ($this->type == 'webinar') { return ($salesCount < $this->capacity); } return true; } public function getSameUserAttribute($user = null) { $user = $user ?: apiAuth(); if ($this->creator_id == $user->id or $this->teacher_id == $user->id) { return true; } return false; } public function notPassedRequiredPrerequisite($user = null) { $user = $user ?: apiAuth(); $isRequiredPrerequisite = false; $prerequisites = $this->prerequisites; if (count($prerequisites)) { foreach ($prerequisites as $prerequisite) { $prerequisiteWebinar = $prerequisite->prerequisiteWebinar; if ($prerequisite->required and !empty($prerequisiteWebinar) and !$prerequisiteWebinar->checkUserHasBought($user)) { $isRequiredPrerequisite = true; } } } return $isRequiredPrerequisite; } public function tickets() { return $this->hasMany('App\Models\Api\Ticket', 'webinar_id', 'id'); } public function chapters() { return $this->hasMany('App\Models\Api\WebinarChapter', 'webinar_id', 'id'); } public function sessions() { return $this->hasMany('App\Models\Api\Session', 'webinar_id', 'id'); } public function files() { return $this->hasMany('App\Models\Api\File', 'webinar_id', 'id'); } public function textLessons() { return $this->hasMany('App\Models\Api\TextLesson', 'webinar_id', 'id'); } public function creator() { return $this->belongsTo('App\Models\Api\User', 'creator_id', 'id'); } public function teacher() { return $this->belongsTo('App\Models\Api\User', 'teacher_id', 'id'); } public function category() { return $this->belongsTo('App\Models\Category', 'category_id', 'id'); } public function tags() { return $this->hasMany('App\Models\Tag', 'webinar_id', 'id'); } public function purchases() { return $this->hasMany('App\Models\Purchase', 'webinar_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Api\Comment', 'webinar_id', 'id'); } public function reviews() { return $this->hasMany('App\Models\Api\WebinarReview', 'webinar_id', 'id'); } public function prerequisites() { return $this->hasMany('App\Models\Api\Prerequisite', 'webinar_id', 'id'); } public function faqs() { return $this->hasMany('App\Models\Api\Faq', 'webinar_id', 'id'); } public function quizzes() { return $this->hasMany('App\Models\Api\Quiz', 'webinar_id', 'id'); } } Api/WebinarChapter.php 0000644 00000005366 15102516312 0010672 0 ustar 00 <?php namespace App\Models\Api; use App\Models\WebinarChapter as Model; class WebinarChapter extends Model { public function sessions() { return $this->hasMany('App\Models\Api\Session', 'chapter_id', 'id'); } public function files() { return $this->hasMany('App\Models\Api\File', 'chapter_id', 'id'); } public function textLessons() { return $this->hasMany('App\Models\Api\TextLesson', 'chapter_id', 'id'); } public function quizzes() { return $this->hasMany('App\Models\Api\Quiz', 'chapter_id', 'id'); } public function chapterItems() { return $this->hasMany('App\Models\Api\WebinarChapterItem', 'chapter_id', 'id'); } public function getDetailsAttribute() { return [ 'id' => $this->id, 'title' => $this->title, 'topics_count' => $this->getTopicsCount(), 'duration' => convertMinutesToHourAndMinute($this->getDuration()), 'status' => $this->status, 'order' => $this->order, 'type' => $this->type, 'created_at' => $this->created_at, 'textLessons' => $this->textLessons()->where('status', WebinarChapter::$chapterActive) ->orderBy('order', 'asc') ->get()->map(function ($textLesson) { return $textLesson->details; }), 'sessions' => $this->sessions() ->where('status', WebinarChapter::$chapterActive) ->orderBy('order', 'asc') ->get()->map(function ($sessions) { return $sessions->details; }), 'files' => $this->files() ->where('status', WebinarChapter::$chapterActive) ->orderBy('order', 'asc') ->get()->map(function ($file) { return $file->details; }), 'quizzes' => $this->quizzes ->where('status', 'active') ->map(function ($quiz) { return $quiz->brief; }) ]; } public function getChapterContentAttribute() { if ($this->type = self::$chapterTextLesson) { return $this->textLessons()->get()->map(function ($textLesson) { return $textLesson->details; }); } if ($this->type = self::$chapterFile) { return $this->files()->get()->map(function ($files) { return $files->details; }); } if ($this->type = self::$chapterSession) { return $this->sessions()->get()->map(function ($sessions) { return $sessions->details; }); } return null; } } Api/RegistrationPackage.php 0000644 00000001647 15102516312 0011720 0 ustar 00 <?php namespace App\Models\Api; use App\Models\RegistrationPackage as Model; class RegistrationPackage extends Model { public function getDetailsAttribute() { return [ 'id' => $this->id, 'days' => $this->days??'unlimited', 'price' => $this->price, 'icon'=>($this->icon)?url($this->icon):null , 'role' => $this->role, 'instructors_count' => $this->instructors_count??'unlimited', 'students_count' => $this->students_count??"unlimited", 'courses_capacity' => $this->courses_capacity??"unlimited", 'courses_count' => $this->courses_count??'unlimited', 'meeting_count' => $this->meeting_count??'unlimited', 'status' => $this->status, 'created_at' => $this->created_at, 'title' => $this->title, 'description' => $this->description, ]; } } Api/Session.php 0000644 00000005401 15102516312 0007405 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\Traits\CheckWebinarItemAccessTrait; use App\Models\Session as WebSession; class Session extends WebSession { use CheckWebinarItemAccessTrait ; public function getDetailsAttribute() { return [ 'id' => $this->id, 'title' => $this->title, 'auth_has_read' => $this->read, 'user_has_access' => $this->user_has_access, 'is_finished' => $this->isFinished(), 'is_started'=>(time() > $this->date) , 'status' => $this->status, 'order' => $this->order, 'moderator_secret' => $this->moderator_secret, 'date' => $this->date, 'duration' => $this->duration, 'link' => $this->link, 'join_link' => (apiAuth()) ? $this->getJoinLink() : null, 'can_join'=>(apiAuth() and !$this->isFinished() and time() > $this->date ) , 'session_api' => $this->session_api, 'zoom_start_link' => $this->zoom_start_link, // 'session_api' => $this->session_api, 'api_secret' => $this->api_secret, 'description' => $this->description, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'agora_settings ' => $this->agora_settings ]; } public function getJoinLink($zoom_start_link = false) { $link = $this->link; if ($this->session_api == 'big_blue_button') { $link = route('big_blue_button', [ 'user_id' => apiAuth()->id, 'session_id' => $this->id, ]); // $link = url('panel/sessions/' . $this->id . '/joinToBigBlueButton'); } if ($zoom_start_link and auth('api')->check() and auth('api')->id() == $this->creator_id and $this->session_api == 'zoom') { $link = $this->zoom_start_link; } if ($this->session_api == 'agora') { // $link = url('panel/sessions/' . $this->id . '/joinToAgora'); /* $link = route('agora', [ 'user_id' => apiAuth()->id, 'session_id' => $this->id, ]);*/ $link=null; } return $link; } public function getUserHasAccessAttribute() { $user = apiAuth(); $hasBought = $this->webinar->checkUserHasBought($user); $access = false; if ($user and $hasBought and !$this->isFinished()) { $access = true; } return $access; } public function getReadAttribute() { $user = apiAuth(); if (!$user) { return null; } return ($this->learningStatus()->where('user_id', $user->id)->count()) ? true : false; } } Api/QuizzesQuestion.php 0000644 00000001566 15102516312 0011174 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\QuizzesQuestion as WebQuizzesQuestion; class QuizzesQuestion extends WebQuizzesQuestion{ public function quizzesQuestionsAnswers() { return $this->hasMany('App\Models\Api\QuizzesQuestionsAnswer', 'question_id', 'id'); } public function getAnswersAttribute(){ return $this->quizzesQuestionsAnswers->map(function($answer){ return $answer->details ; }) ; } public function getDetailsAttribute(){ return [ 'id'=>$this->id , 'title'=>$this->title , 'type'=>$this->type , 'descriptive_correct_answer'=>$this->correct , 'grade'=>$this->grade , 'created_at'=>$this->created_at , 'answers'=>$this->answers , 'updated_at'=>$this->updated_at , ] ; } } Api/Follow.php 0000644 00000000516 15102516312 0007226 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Follow as Model; class Follow extends Model { public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } public function userFollower() { return $this->belongsTo('App\Models\Api\User', 'follower', 'id'); } } Api/ReserveMeeting.php 0000644 00000003101 15102516312 0010701 0 ustar 00 <?php namespace App\Models\Api; use App\Models\ReserveMeeting as Model; class ReserveMeeting extends Model { public function getDetailsAttribute() { $time_exploded = explode('-', $this->meetingTime->time); return [ 'id' => $this->id, 'status' => $this->status, 'link' => $this->link, 'user_paid_amount' => $this->user_paid_amount, 'discount' => $this->discount, 'amount' => $this->paid_amount, 'date' => $this->date, 'day' => $this->meetingTime->day_label, 'time' => [ 'start' => $time_exploded[0], 'end' => $time_exploded[1], ], 'student_count'=>$this->student_count, 'description'=>$this->description , 'meeting' => $this->meeting->details, 'user' => $this->meeting->creator->brief, ]; } public function getUserPaidAmountAttribute() { return ($this->sale && $this->sale->total_amount && $this->sale->total_amount > 0) ? $this->sale->total_amount : 0; } public function meetingTime() { return $this->belongsTo('App\Models\MeetingTime', 'meeting_time_id', 'id'); } public function meeting() { return $this->belongsTo('App\Models\Api\Meeting', 'meeting_id', 'id'); } public function sale() { return $this->belongsTo('App\Models\Api\Sale', 'sale_id', 'id'); } public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } } Api/Payout.php 0000644 00000001212 15102516312 0007237 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Payout as Model; class Payout extends Model { public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } public function getDetailsAttribute(){ return [ 'id'=>$this->id , // 'user'=>$this->user->brief , 'amount'=>$this->amount , 'account_name'=>$this->account_name , 'account_number'=>$this->account_number , 'account_bank_name'=>$this->account_bank_name , 'status'=>$this->status , 'created_at'=>$this->created_at ] ; } } Api/Favorite.php 0000644 00000000536 15102516312 0007545 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\Favorite as WebFavorite; class Favorite extends WebFavorite{ public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } } Api/FeatureWebinar.php 0000644 00000001711 15102516312 0010665 0 ustar 00 <?php namespace App\Models\Api; use App\Models\FeatureWebinar as Model; class FeatureWebinar extends Model { public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function scopeHandleFilters($query) { $request=request() ; $offset = $request->get('offset', null); $limit = $request->get('limit', null); $category = $request->get('cat', null); if (!empty($category) and is_numeric($category)) { // $query->with('webinar') ;//->where('webinar.category_id', $category); $query->whereHas('webinar', function ($q) use ($category) { $q->where('category_id', $category); }); } if (!empty($offset) && !empty($limit)) { $query->skip($offset); } if (!empty($limit)) { $query->take($limit); } return $query; } } Api/Support.php 0000644 00000005671 15102516312 0007447 0 ustar 00 <?php namespace App\Models\Api ; use App\Models\Support as Model ; class Support extends Model{ public function department() { return $this->belongsTo('App\Models\SupportDepartment', 'department_id', 'id'); } public function user() { return $this->belongsTo('App\Models\Api\User', 'user_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } public function conversations() { return $this->hasMany('App\Models\Api\SupportConversation', 'support_id', 'id'); } public function getDetailsAttribute(){ return [ 'id'=>$this->id , 'department'=>$this->department->title??null , 'status'=>$this->status , 'type' => ($this->webinar_id) ? 'course_support' : 'platform_support', 'title'=>$this->title , 'webinar'=>$this->webinar->brief??null , 'user'=>$this->user->brief , 'conversations'=>$this->conversations->map(function($conversation){ return $conversation->brief ; }) , 'created_at'=>$this->created_at , 'updated_at'=>$this->updated_at , ] ; } public function scopeHandleFilters($query, $userWebinarsIds = []) { $request=request() ; $from = $request->get('from'); $to = $request->get('to'); $role = $request->get('role'); $student_id = $request->get('student'); $teacher_id = $request->get('teacher'); $webinar_id = $request->get('webinar'); $department = $request->get('department'); $status = $request->get('status'); $query = fromAndToDateFilter($from, $to, $query, 'created_at'); if (!empty($role) and $role == 'student' and (empty($student_id) or $student_id == 'all')) { $studentsIds = Sale::whereIn('webinar_id', $userWebinarsIds) ->whereNull('refund_at') ->pluck('buyer_id') ->toArray(); $query->whereIn('user_id', $studentsIds); } if (!empty($student_id) and $student_id != 'all') { $query->where('user_id', $student_id); } if (!empty($teacher_id) and $teacher_id != 'all') { $teacher = User::where('id', $teacher_id) ->where('status', 'active') ->first(); $teacherWebinarIds = $teacher->webinars->pluck('id')->toArray(); $query->whereIn('webinar_id', $teacherWebinarIds); } if (!empty($webinar_id) and $webinar_id != 'all') { $query->where('webinar_id', $webinar_id); } if (!empty($status) and $status != 'all') { $query->where('status', $status); } if (!empty($department) and $department != 'all') { $query->where('department_id', $department); } return $query; } } Api/GroupUser.php 0000644 00000000734 15102516312 0007721 0 ustar 00 <?php namespace App\Models\Api; use App\Models\GroupUser as Model; class GroupUser extends Model { // public function getBriefAttribute(){ if(!$this->group){ return null ; } return [ 'id'=>$this->group->id , 'name'=>$this->group->name , 'status'=>$this->group->status , 'commission'=>$this->group->commission , 'discount'=>$this->group->discount ] ; } } Api/Faq.php 0000644 00000000620 15102516312 0006467 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Faq as Model ; class Faq extends Model { public function getDetailsAttribute(){ return [ 'id'=>$this->id , 'title'=>$this->title , 'answer'=>$this->answer , 'order'=>$this->order , 'created_at'=>$this->created_at , 'updated_at'=>$this->updated_at ] ; } } Api/TextLesson.php 0000644 00000004553 15102516312 0010101 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\Traits\CheckWebinarItemAccessTrait; use App\Models\TextLesson as WebTextLesson; class TextLesson extends WebTextLesson { use CheckWebinarItemAccessTrait ; public function getDetailsAttribute() { return [ 'id' => $this->id, 'title' => $this->title, 'auth_has_read' => $this->read, 'auth_has_access' => $this->auth_has_access, 'user_has_access' => $this->user_has_access, 'study_time' => $this->study_time, 'order' => $this->order, 'created_at' => $this->created_at, 'accessibility' => $this->accessibility, 'status' => $this->status, 'updated_at' => $this->updated_at, 'summary' => $this->summary, 'content' => $this->content, 'locale' => $this->locale, // 'read'=>$this->read , 'attachments' => $this->attachments()->get()->map(function ($attachment) { return $attachment->details; }), 'attachments_count' => $this->attachments()->count(), ]; } public function getUserHasAccessAttribute() { $user = apiAuth(); $access = false; $hasBought = $this->webinar->checkUserHasBought($user); if ($this->accessibility == 'paid') { if ($user and $hasBought) { $access = true; } } else { $access = true; } return $access; } public function getAuthHasAccessAttribute() { $user = apiAuth(); $canAccess = null; if ($user) { $canAccess = true; if ($this->accessibility == 'paid') { $canAccess = ($this->webinar->checkUserHasBought($user)) ? true : false; } } return $canAccess; } public function getReadAttribute() { $user = apiAuth(); if (!$user) { return null; } return ($this->learningStatus()->where('user_id', $user->id)->count()) ? true : false; } public function attachments() { return $this->hasMany('App\Models\Api\TextLessonAttachment', 'text_lesson_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } } Api/WebinarAssignment.php 0000644 00000011326 15102516312 0011405 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Api\Traits\CheckWebinarItemAccessTrait; use App\Models\Sale; use App\Models\WebinarAssignment as Model; use App\Models\WebinarAssignmentHistory; use App\Models\WebinarAssignmentHistoryMessage; use Illuminate\Http\Request; class WebinarAssignment extends Model { use CheckWebinarItemAccessTrait; public function scopeHandleFilters($query) { $request = \request(); $user = apiAuth(); $from = $request->get('from'); $to = $request->get('to'); $webinarId = $request->get('webinar_id'); $status = $request->get('status'); // $from and $to $query = fromAndToDateFilter($from, $to, $query, 'created_at'); if (!empty($webinarId)) { $query->where('webinar_id', $webinarId); } if (!empty($status)) { $query->whereHas('assignmentHistory', function ($query) use ($user, $status) { $query->where('student_id', $user->id); $query->where('status', $status); }); } return $query; } public function getDeadlineTimeAttribute() { if (!apiAuth()) { return null; } if (!empty($this->deadline)) { $sale = Sale::where('buyer_id', apiAuth()->id) ->where('webinar_id', $this->webinar_id) ->whereNull('refund_at') ->first(); return strtotime("+{$this->deadline} days", $sale->created_at); } } public function userAssignmentHistory() { return $this->assignmentHistory()->where('student_id', apiAuth()->id); } public function getLastSubmissionAttribute() { if ($this->userAssignmentHistory and $this->userAssignmentHistory->messages) { return $this->userAssignmentHistory->messages->where('sender_id', apiAuth()->id)->first()->created_at ?? null; } return null; } public function attachments() { return $this->hasMany('App\Models\Api\WebinarAssignmentAttachment', 'assignment_id', 'id'); } public function getFirstSubmissionAttribute() { if ($this->userAssignmentHistory and $this->userAssignmentHistory->messages) { return $this->userAssignmentHistory->messages->where('sender_id', apiAuth()->id)->last()->created_at ?? null; } return null; } public function getUsedAttemptsCountAttribute() { if ($this->userAssignmentHistory and $this->userAssignmentHistory->messages) { return $this->userAssignmentHistory->messages->where('sender_id', apiAuth()->id)->count() ?? 0; } return 0; } public function getAssignmentStatusAttribute() { if (empty($this->assignmentHistory) or ($this->assignmentHistory->status == \App\Models\WebinarAssignmentHistory::$notSubmitted)) { return 'not_submitted'; } else { return $this->userAssignmentHistory->status; } } public function grades() { return $this->assignmentHistory()->get()->filter(function ($item) { return !is_null($item->grade); }); } public function getMinGradeAttribute() { $grades = $this->grades(); return $grades->count() ? $grades->min('grade') : null; } public function getAvgGradeAttribute() { $grades = $this->grades(); return $grades->count() ? $grades->avg('grade') : null; } public function getPendingCountAttribute() { return $this->instructorAssignmentHistories()->where('status', WebinarAssignmentHistory::$pending)->count(); } public function getPassedCountAttribute() { return $this->instructorAssignmentHistories()->where('status', WebinarAssignmentHistory::$passed)->count(); } public function getFailedCountAttribute() { return $this->instructorAssignmentHistories()->where('status', WebinarAssignmentHistory::$notPassed)->count(); } public function getSubmissionsCountAttribute() { $historyIds = $this->instructorAssignmentHistories->pluck('id')->toArray(); return WebinarAssignmentHistoryMessage::whereIn('assignment_history_id', $historyIds) ->where('sender_id', '!=', $this->creator_id) ->count(); // return $this->instructorAssignmentHistories()->messages()->where('sender_id', '!=', $this->creator_id)->count(); } public function assignmentHistory() { return $this->hasOne('App\Models\Api\WebinarAssignmentHistory', 'assignment_id', 'id') ->withDefault([ 'student_id' => apiAuth()->id, 'status' => WebinarAssignmentHistory::$notSubmitted ]); } } Api/Ticket.php 0000644 00000001561 15102516312 0007210 0 ustar 00 <?php namespace App\Models\Api; use App\Models\Ticket as Model; class Ticket extends Model { // public function getDetailsAttribute(){ // dd($this->webinar); return [ 'id' => $this->id, 'title' => $this->title, 'sub_title' => $this->getSubTitle(), 'discount' => $this->discount, // 'price_with_ticket_discount'=>$this->price - ($ticket->discount) * $this->price/100 , // 'price_with_ticket_discount' => $this->price - $this->getDiscount($ticket), 'price_with_ticket_discount' => $this->webinar->price - $this->webinar->getDiscount($this), // 'order' => $ticket->order, 'is_valid' => $this->isValid(), ]; } public function webinar() { return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id'); } } UserSelectedBankSpecification.php 0000644 00000001021 15102516312 0013127 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class UserSelectedBankSpecification extends Model { protected $table = "user_selected_bank_specifications"; public $timestamps = false; protected $guarded = ['id']; public function bankSpecification() { return $this->belongsTo('App\Models\UserBankSpecification', 'user_bank_specification_id', 'id'); } } Testimonial.php 0000644 00000001513 15102516312 0007541 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Testimonial extends Model implements TranslatableContract { use Translatable; protected $table = 'testimonials'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['user_name', 'user_bio', 'comment']; public function getUserNameAttribute() { return getTranslateAttributeValue($this, 'user_name'); } public function getUserBioAttribute() { return getTranslateAttributeValue($this, 'user_bio'); } public function getCommentAttribute() { return getTranslateAttributeValue($this, 'comment'); } } InstallmentOrderPayment.php 0000644 00000001345 15102516312 0012100 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class InstallmentOrderPayment extends Model { protected $table = 'installment_order_payments'; public $timestamps = false; protected $guarded = ['id']; public function installmentOrder() { return $this->belongsTo(InstallmentOrder::class, 'installment_order_id', 'id'); } public function sale() { return $this->belongsTo(Sale::class, 'sale_id', 'id'); } public function step() { return $this->belongsTo(SelectedInstallmentStep::class, 'selected_installment_step_id', 'id'); } } Badge.php 0000644 00000024012 15102516312 0006252 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Badge extends Model implements TranslatableContract { use Translatable; protected $table = 'badges'; protected $guarded = ['id']; public $timestamps = false; static $badgeTypes = ['register_date', 'course_count', 'course_rate', 'sale_count', 'support_rate', 'product_sale_count', 'make_topic', 'send_post_in_topic', 'instructor_blog' ]; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } static function getUserBadges($user, $customBadges = false, $getNext = false) { $earnedBadges = []; $nextBadges = []; // for normal user just register_date and for instructor and organization just sale_count $nextBadge = null; $badges = self::all(); $badges = $badges->groupBy('type'); $courses = $user->webinars; foreach (self::$badgeTypes as $type) { if (!empty($badges[$type]) and !$badges[$type]->isEmpty()) { switch ($type) { case 'register_date' : $timeElapsed = time() - $user->created_at; $days = round($timeElapsed / 86400); $registerDateBadges = self::handleCondition($badges[$type], $days); if (!empty($registerDateBadges['result'])) { $earnedBadges[] = $registerDateBadges['result']; } if ($user->isUser() and count($registerDateBadges['nextBadge'])) { $nextBadge = $registerDateBadges['nextBadge']; $nextBadge['earned'] = $registerDateBadges['result']; $nextBadges[] = $nextBadge; } break; case 'course_count': if (!empty($courses) and !$courses->isEmpty()) { $coursesCount = $courses->count(); $courseBadges = self::handleCondition($badges[$type], $coursesCount); if (!empty($courseBadges['result'])) { $earnedBadges[] = $courseBadges['result']; } } break; case 'course_rate': if (!empty($courses) and !$courses->isEmpty()) { $rate = 0; foreach ($courses as $course) { $rate += $course->getRate(); } $rateBadges = self::handleCondition($badges[$type], $rate); if (!empty($rateBadges['result'])) { $earnedBadges[] = $rateBadges['result']; } } break; case 'sale_count': if (!empty($courses) and !$courses->isEmpty()) { $saleCount = $user->salesCount(); $saleBadges = self::handleCondition($badges[$type], $saleCount); if (!empty($saleBadges['result'])) { $earnedBadges[] = $saleBadges['result']; } if (!$user->isUser() and count($saleBadges['nextBadge'])) { $nextBadge = $saleBadges['nextBadge']; $nextBadge['earned'] = $saleBadges['result']; $nextBadges[] = $nextBadge; } } break; case 'support_rate': if (!empty($courses) and !$courses->isEmpty()) { $webinarIds = $courses->pluck('id')->toArray(); $supportsRate = webinarReview::whereIn('webinar_id', $webinarIds) ->where('status', 'active') ->avg('support_quality'); $supportBadges = self::handleCondition($badges[$type], $supportsRate); if (!empty($supportBadges['result'])) { $earnedBadges[] = $supportBadges['result']; } } break; case 'product_sale_count': $products = $user->products; if (!empty($products) and !$products->isEmpty()) { $saleCount = $user->productsSalesCount(); $productsSaleBadges = self::handleCondition($badges[$type], $saleCount); if (!empty($productsSaleBadges['result'])) { $earnedBadges[] = $productsSaleBadges['result']; } } break; case 'make_topic': $forumTopics = $user->forumTopics; if (!empty($forumTopics) and !$forumTopics->isEmpty()) { $forumTopicsBadges = self::handleCondition($badges[$type], $forumTopics->count()); if (!empty($forumTopicsBadges['result'])) { $earnedBadges[] = $forumTopicsBadges['result']; } } break; case 'send_post_in_topic': $forumTopicPosts = $user->forumTopicPosts; if (!empty($forumTopicPosts) and !$forumTopicPosts->isEmpty()) { $forumTopicPostsBadges = self::handleCondition($badges[$type], $forumTopicPosts->count()); if (!empty($forumTopicPostsBadges['result'])) { $earnedBadges[] = $forumTopicPostsBadges['result']; } } break; case 'instructor_blog': $blogCount = $user->blog()->where('status', 'publish')->count(); if ($blogCount) { $blogBadges = self::handleCondition($badges[$type], $blogCount); if (!empty($blogBadges['result'])) { $earnedBadges[] = $blogBadges['result']; } } break; } } } if ($customBadges) { $customs = $user->customBadges()->with('badge')->get(); if (!empty($customs) and !$customs->isEmpty()) { $earnedBadges = $customs->merge($earnedBadges); } } foreach ($earnedBadges as $earnedBadge) { if (!empty($earnedBadge->badge_id)) { self::handleBadgeReward($earnedBadge->badge, $user->id); sendNotification('new_badge', ['[u.b.title]' => $earnedBadge->badge->title], $user->id); } else { self::handleBadgeReward($earnedBadge, $user->id); sendNotification('new_badge', ['[u.b.title]' => $earnedBadge->title], $user->id); } } if (!empty($nextBadges) and count($nextBadges)) { foreach ($nextBadges as $next) { if (!empty($nextBadge) and $nextBadge['percent'] < $next['percent']) { $nextBadge = $next; } else { $nextBadge = $next; } } } if ($getNext) { return $nextBadge; } return $earnedBadges; } static function handleCondition($badges, $entry) { $result = null; $earnedBadges = []; $nextBadge = []; foreach ($badges as $badge) { $condition = json_decode($badge->condition); if ($entry >= $condition->from) { $earnedBadges[$condition->from] = $badge; } else { if (!empty($nextBadge) and !empty($nextBadge['badge'])) { $nextCondition = json_decode($nextBadge['badge']->condition); if ($nextCondition->from > $condition->from) { $nextBadge['badge'] = $badge; $nextBadge['percent'] = round(($entry > 0 ? $entry : 1) / ($condition->from > 0 ? $condition->from : 1) * 100, 2); } } else { $nextBadge['badge'] = $badge; $nextBadge['percent'] = round(($entry > 0 ? $entry : 1) / ($condition->from > 0 ? $condition->from : 1) * 100, 2); } } } if (!empty($earnedBadges) and count($earnedBadges)) { $result = $earnedBadges[max(array_keys($earnedBadges))]; if (count($nextBadge) < 1) { $resultCondition = json_decode($result->condition); $percent = round(($entry > 0 ? $entry : 1) / ($resultCondition->to > 0 ? $resultCondition->to : 1) * 100, 2); $nextBadge['percent'] = ($percent > 100) ? 100 : $percent; } } return [ 'result' => $result, 'nextBadge' => $nextBadge ]; } static function handleBadgeReward($badge, $userId) { if (!empty($badge->score)) { $rewardScore = RewardAccounting::calculateScore(Reward::BADGE, $badge->score); RewardAccounting::makeRewardAccounting($userId, $rewardScore, Reward::BADGE, $badge->id, true); } return true; } } Quiz.php 0000644 00000005243 15102516312 0006205 0 ustar 00 <?php namespace App\Models; use App\Models\Traits\SequenceContent; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Quiz extends Model implements TranslatableContract { use Translatable; use SequenceContent; const ACTIVE = 'active'; const INACTIVE = 'inactive'; public $timestamps = false; protected $table = 'quizzes'; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function quizQuestions() { return $this->hasMany('App\Models\QuizzesQuestion', 'quiz_id', 'id'); } public function quizResults() { return $this->hasMany('App\Models\QuizzesResult', 'quiz_id', 'id'); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function teacher() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function certificates() { return $this->hasMany('App\Models\Certificate', 'quiz_id', 'id'); } public function chapter() { return $this->belongsTo('App\Models\WebinarChapter', 'chapter_id', 'id'); } public function increaseTotalMark($grade) { $total_mark = $this->total_mark + $grade; return $this->update(['total_mark' => $total_mark]); } public function decreaseTotalMark($grade) { $total_mark = $this->total_mark - $grade; return $this->update(['total_mark' => $total_mark]); } public function getUserCertificate($user, $quiz_result) { if (!empty($user) and !empty($quiz_result)) { return Certificate::where('quiz_id', $this->id) ->where('student_id', $user->id) ->where('quiz_result_id', $quiz_result->id) ->first(); } return null; } public function canAccessToEdit($user = null) { if (empty($user)) { $user = auth()->user(); } $result = false; if (!empty($user)) { $webinar = null; if (!empty($this->webinar_id)) { $webinar = Webinar::query()->find($this->webinar_id); } if ($this->creator_id == $user->id or (!empty($webinar) and $webinar->canAccess($user))) { $result = true; } } return $result; } } WebinarAssignmentHistoryMessage.php 0000644 00000001107 15102516312 0013557 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class WebinarAssignmentHistoryMessage extends Model { protected $table = 'webinar_assignment_history_messages'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function sender() { return $this->belongsTo('App\User', 'sender_id', 'id'); } public function getDownloadUrl($assignmentId) { return "/course/assignment/{$assignmentId}/history/{$this->assignment_history_id}/message/{$this->id}/downloadAttach"; } } .php 0000644 00000000304 15102516312 0005325 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class FAQ extends Model { protected $table = 'faqs'; public $timestamps = false; protected $guarded = ['id']; } ProductFile.php 0000644 00000002206 15102516312 0007471 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class ProductFile extends Model implements TranslatableContract { use Translatable; protected $table = 'product_files'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $Active = 'active'; static $Inactive = 'inactive'; static $fileStatus = ['active', 'inactive']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function getDownloadUrl() { return '/panel/store/products/files/' . $this->id . '/download'; } public function getOnlineViewUrl() { return url($this->path); } } ProductSpecification.php 0000644 00000002024 15102516312 0011370 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class ProductSpecification extends Model implements TranslatableContract { use Translatable; protected $table = 'product_specifications'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $inputTypes = ['textarea', 'multi_value']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function categories() { return $this->hasMany('App\Models\ProductSpecificationCategory', 'specification_id', 'id'); } public function multiValues() { return $this->hasMany('App\Models\ProductSpecificationMultiValue', 'specification_id', 'id'); } public function createName() { return str_replace(' ', '_', $this->title); } } DiscountGroup.php 0000644 00000000702 15102516312 0010055 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class DiscountGroup extends Model { protected $table = 'discount_groups'; public $timestamps = false; protected $guarded = ['id']; public function discount() { return $this->belongsTo('App\Models\Discount', 'discount_id', 'id'); } public function group() { return $this->belongsTo('App\Models\Group', 'group_id', 'id'); } } CertificateTemplate.php 0000644 00000001464 15102516312 0011174 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class CertificateTemplate extends Model implements TranslatableContract { use Translatable; protected $table = "certificates_templates"; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'body']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getBodyAttribute() { return getTranslateAttributeValue($this, 'body'); } public function getRtlAttribute() { return getTranslateAttributeValue($this, 'rtl'); } } ProductOrder.php 0000644 00000002011 15102516312 0007657 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ProductOrder extends Model { protected $table = 'product_orders'; public $timestamps = false; protected $guarded = ['id']; static $status = ['pending', 'waiting_delivery', 'shipped', 'success', 'canceled']; static $waitingDelivery = 'waiting_delivery'; static $shipped = 'shipped'; static $success = 'success'; static $canceled = 'canceled'; static $pending = 'pending'; public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function seller() { return $this->belongsTo('App\User', 'seller_id', 'id'); } public function buyer() { return $this->belongsTo('App\User', 'buyer_id', 'id'); } public function sale() { return $this->belongsTo('App\Models\Sale', 'sale_id', 'id'); } public function gift() { return $this->belongsTo('App\Models\Gift', 'gift_id', 'id'); } } NotificationStatus.php 0000644 00000000403 15102516312 0011100 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class NotificationStatus extends Model { protected $table = 'notifications_status'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } TextLessonAttachment.php 0000644 00000000566 15102516312 0011401 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class TextLessonAttachment extends Model { protected $table = 'text_lessons_attachments'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function file() { return $this->belongsTo('App\Models\File', 'file_id', 'id'); } } ProductDiscount.php 0000644 00000002005 15102516312 0010377 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ProductDiscount extends Model { protected $table = 'product_discounts'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function getRemainingTimes() { $current_time = time(); $date = $this->end_date; $difference = $date - $current_time; return time2string($difference); } public function discountRemain() { $count = $this->count; $orderItems = ProductOrder::where('discount_id', $this->id) ->whereHas('sale', function ($query) { $query->whereNull('refund_at'); }) ->count(); return ($count > 0) ? $count - $orderItems : 0; } } CourseNoticeboardStatus.php 0000644 00000000417 15102516312 0012071 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class CourseNoticeboardStatus extends Model { protected $table = 'course_noticeboard_status'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id'];// } Newsletter.php 0000644 00000000362 15102516312 0007406 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Newsletter extends Model { protected $table = 'newsletters'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } UserRegistrationPackage.php 0000644 00000000417 15102516312 0012040 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UserRegistrationPackage extends Model { protected $table = 'users_registration_packages'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } ForumFeaturedTopic.php 0000644 00000000572 15102516312 0011024 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ForumFeaturedTopic extends Model { protected $table = 'forum_featured_topics'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function topic() { return $this->belongsTo('App\Models\ForumTopic', 'topic_id', 'id'); } } AffiliateCode.php 0000644 00000000531 15102516312 0007727 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class AffiliateCode extends Model { protected $table = 'affiliates_codes'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function getAffiliateUrl() { return url('/reff/' . $this->code); } } Section.php 0000644 00000000421 15102516312 0006652 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Section extends Model { public $timestamps = false; protected $guarded = ['id']; public function children() { return $this->hasMany($this, 'section_group_id', 'id'); } } TicketUser.php 0000644 00000000731 15102516312 0007334 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class TicketUser extends Model { public $timestamps = false; protected $guarded = ['id']; public static function useTicket($orderItem) { if ($orderItem->ticket_id) { TicketUser::create([ 'ticket_id' => $orderItem->ticket_id, 'user_id' => $orderItem->user_id, 'created_at' => time() ]); } } } Webinar.php 0000644 00000075054 15102516312 0006653 0 ustar 00 <?php namespace App\Models; use App\Mixins\Certificate\MakeCertificate; use App\User; use Cviebrock\EloquentSluggable\Services\SlugService; use Illuminate\Database\Eloquent\Model; use Cviebrock\EloquentSluggable\Sluggable; use Jorenvh\Share\ShareFacade; use Spatie\CalendarLinks\Link; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Webinar extends Model implements TranslatableContract { use Translatable; use Sluggable; protected $table = 'webinars'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $active = 'active'; static $pending = 'pending'; static $isDraft = 'is_draft'; static $inactive = 'inactive'; static $webinar = 'webinar'; static $course = 'course'; static $textLesson = 'text_lesson'; static $statuses = [ 'active', 'pending', 'is_draft', 'inactive' ]; static $videoDemoSource = ['upload', 'youtube', 'vimeo', 'external_link']; public $translatedAttributes = ['title', 'description', 'seo_description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function getSeoDescriptionAttribute() { return getTranslateAttributeValue($this, 'seo_description'); } public function getPriceAttribute() { $result = $this->attributes['price'] ?? null; $user = auth()->user(); if (!empty($this->attributes['organization_price']) and !empty($user) and $this->creator->isOrganization() and $user->organ_id == $this->creator_id) { $result = $this->attributes['organization_price']; } return $result; } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function teacher() { return $this->belongsTo('App\User', 'teacher_id', 'id'); } public function category() { return $this->belongsTo('App\Models\Category', 'category_id', 'id'); } public function filterOptions() { return $this->hasMany('App\Models\WebinarFilterOption', 'webinar_id', 'id'); } public function tickets() { return $this->hasMany('App\Models\Ticket', 'webinar_id', 'id'); } public function chapters() { return $this->hasMany('App\Models\WebinarChapter', 'webinar_id', 'id'); } public function sessions() { return $this->hasMany('App\Models\Session', 'webinar_id', 'id'); } public function files() { return $this->hasMany('App\Models\File', 'webinar_id', 'id'); } public function assignments() { return $this->hasMany('App\Models\WebinarAssignment', 'webinar_id', 'id'); } public function textLessons() { return $this->hasMany('App\Models\TextLesson', 'webinar_id', 'id'); } public function faqs() { return $this->hasMany('App\Models\Faq', 'webinar_id', 'id'); } public function webinarExtraDescription() { return $this->hasMany('App\Models\WebinarExtraDescription', 'webinar_id', 'id'); } public function prerequisites() { return $this->hasMany('App\Models\Prerequisite', 'webinar_id', 'id'); } public function quizzes() { return $this->hasMany('App\Models\Quiz', 'webinar_id', 'id'); } public function webinarPartnerTeacher() { return $this->hasMany('App\Models\WebinarPartnerTeacher', 'webinar_id', 'id'); } public function tags() { return $this->hasMany('App\Models\Tag', 'webinar_id', 'id'); } public function purchases() { return $this->hasMany('App\Models\Purchase', 'webinar_id', 'id'); } public function comments() { return $this->hasMany('App\Models\Comment', 'webinar_id', 'id'); } public function reviews() { return $this->hasMany('App\Models\WebinarReview', 'webinar_id', 'id'); } public function sales() { return $this->hasMany('App\Models\Sale', 'webinar_id', 'id') ->whereNull('refund_at') ->where('type', 'webinar'); } public function feature() { return $this->hasOne('App\Models\FeatureWebinar', 'webinar_id', 'id'); } public function noticeboards() { return $this->hasMany('App\Models\CourseNoticeboard', 'webinar_id', 'id'); } public function forums() { return $this->hasMany('App\Models\CourseForum', 'webinar_id', 'id'); } public function getRate() { $rate = 0; if (!empty($this->avg_rates)) { $rate = $this->avg_rates; } else { $reviews = $this->reviews() ->where('status', 'active') ->get(); if (!empty($reviews) and $reviews->count() > 0) { $rate = number_format($reviews->avg('rates'), 2); } } if ($rate > 5) { $rate = 5; } return $rate > 0 ? number_format($rate, 2) : 0; } /** * Return the sluggable configuration array for this model. * * @return array */ public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public static function makeSlug($title) { return SlugService::createSlug(self::class, 'slug', $title); } public function bestTicket($with_percent = false) { $ticketPercent = 0; $bestTicket = $this->price; $activeSpecialOffer = $this->activeSpecialOffer(); if ($activeSpecialOffer) { $bestTicket = $this->price - ($this->price * $activeSpecialOffer->percent / 100); $ticketPercent = $activeSpecialOffer->percent; } else { foreach ($this->tickets as $ticket) { if ($ticket->isValid()) { $discount = $this->price - ($this->price * $ticket->discount / 100); if ($bestTicket > $discount) { $bestTicket = $discount; $ticketPercent = $ticket->discount; } } } } if ($with_percent) { return [ 'bestTicket' => $bestTicket, 'percent' => $ticketPercent ]; } return $bestTicket; } public function getDiscount($ticket = null, $user = null) { $activeSpecialOffer = $this->activeSpecialOffer(); $discountOut = $activeSpecialOffer ? $this->price * $activeSpecialOffer->percent / 100 : 0; if (!empty($user) and !empty($user->getUserGroup()) and isset($user->getUserGroup()->discount) and $user->getUserGroup()->discount > 0) { $discountOut += $this->price * $user->getUserGroup()->discount / 100; } if (!empty($ticket) and $ticket->isValid()) { $discountOut += $this->price * $ticket->discount / 100; } return $discountOut; } public function getDiscountPercent() { $percent = 0; $activeSpecialOffer = $this->activeSpecialOffer(); if (!empty($activeSpecialOffer)) { $percent += $activeSpecialOffer->percent; } $tickets = Ticket::where('webinar_id', $this->id)->get(); foreach ($tickets as $ticket) { if (!empty($ticket) and $ticket->isValid()) { $percent += $ticket->discount; } } return $percent; } public function getWebinarCapacity() { $salesCount = !empty($this->sales_count) ? $this->sales_count : $this->sales()->count(); $capacity = $this->capacity - $salesCount; return $capacity > 0 ? $capacity : 0; } public function getExpiredAccessDays($purchaseDate, $giftId = null) { if (!empty($giftId)) { $gift = Gift::query()->where('id', $giftId) ->where('status', 'active') ->first(); if (!empty($gift) and !empty($gift->date)) { $purchaseDate = $gift->date; } } return strtotime("+{$this->access_days} days", $purchaseDate); } public function checkHasExpiredAccessDays($purchaseDate, $giftId = null) { // true => has access // false => not access (expired) if (!empty($giftId)) { $gift = Gift::query()->where('id', $giftId) ->where('status', 'active') ->first(); if (!empty($gift) and !empty($gift->date)) { $purchaseDate = $gift->date; } } $time = time(); return strtotime("+{$this->access_days} days", $purchaseDate) > $time; } public function getSaleItem($user = null) { if (empty($user)) { $user = auth()->user(); } if (!empty($user)) { return Sale::query()->where('buyer_id', $user->id) ->where('webinar_id', $this->id) ->where('type', 'webinar') ->whereNull('refund_at') ->where('access_to_purchased_item', true) ->orderBy('created_at', 'desc') ->first(); } return null; } public function checkUserHasBought($user = null, $checkExpired = true, $test = false): bool { $hasBought = false; if (empty($user) and auth()->check()) { $user = auth()->user(); } if (!empty($user)) { $sale = $this->getSaleItem($user); if (!empty($sale)) { $hasBought = true; if ($sale->payment_method == Sale::$subscribe) { $subscribe = $sale->getUsedSubscribe($sale->buyer_id, $sale->webinar_id); if (!empty($subscribe)) { $subscribeSaleCreatedAt = null; if (!empty($subscribe->installment_order_id)) { $installmentOrder = InstallmentOrder::query()->where('user_id', $user->id) ->where('id', $subscribe->installment_order_id) ->where('status', 'open') ->whereNull('refund_at') ->first(); if (!empty($installmentOrder)) { $subscribeSaleCreatedAt = $installmentOrder->created_at; if ($installmentOrder->checkOrderHasOverdue()) { $overdueIntervalDays = getInstallmentsSettings('overdue_interval_days'); if (empty($overdueIntervalDays) or $installmentOrder->overdueDaysPast() > $overdueIntervalDays) { $hasBought = false; } } } } else { $subscribeSale = Sale::where('buyer_id', $user->id) ->where('type', Sale::$subscribe) ->where('subscribe_id', $subscribe->id) ->whereNull('refund_at') ->latest('created_at') ->first(); if (!empty($subscribeSale)) { $subscribeSaleCreatedAt = $subscribeSale->created_at; } } if (!empty($subscribeSaleCreatedAt)) { $usedDays = (int)diffTimestampDay(time(), $subscribeSaleCreatedAt); if ($usedDays > $subscribe->days) { $hasBought = false; } } } else { $hasBought = false; } } if ($hasBought and !empty($this->access_days) and $checkExpired) { $hasBought = $this->checkHasExpiredAccessDays($sale->created_at, $sale->gift_id); } } if (!$hasBought) { $hasBought = ($this->creator_id == $user->id or $this->teacher_id == $user->id); if (!$hasBought) { $partnerTeachers = !empty($this->webinarPartnerTeacher) ? $this->webinarPartnerTeacher->pluck('teacher_id')->toArray() : []; $hasBought = in_array($user->id, $partnerTeachers); } } if (!$hasBought) { $hasBought = $user->isAdmin(); } if (!$hasBought) { $bundleWebinar = BundleWebinar::where('webinar_id', $this->id) ->with([ 'bundle' ])->get(); if ($bundleWebinar->isNotEmpty()) { foreach ($bundleWebinar as $item) { if (!empty($item->bundle) and $item->bundle->checkUserHasBought($user)) { $hasBought = true; } } } } /* Check Installment */ if (!$hasBought) { $installmentOrder = $this->getInstallmentOrder(); if (!empty($installmentOrder)) { $hasBought = true; if ($installmentOrder->checkOrderHasOverdue()) { $overdueIntervalDays = getInstallmentsSettings('overdue_interval_days'); if (empty($overdueIntervalDays) or $installmentOrder->overdueDaysPast() > $overdueIntervalDays) { $hasBought = false; } } } } /* Check Gift */ if (!$hasBought) { $gift = Gift::query()->where('email', $user->email) ->where('status', 'active') ->where('webinar_id', $this->id) ->where(function ($query) { $query->whereNull('date'); $query->orWhere('date', '<', time()); }) ->whereHas('sale') ->first(); if (!empty($gift)) { $hasBought = true; } } } return $hasBought; } public function getInstallmentOrder() { $user = auth()->user(); if (!empty($user)) { return InstallmentOrder::query()->where('user_id', $user->id) ->where('webinar_id', $this->id) ->where('status', 'open') ->whereNull('refund_at') ->first(); } return null; } public function getFilesLearningProgressStat($userId = null) { $passed = 0; if (empty($userId)) { $userId = auth()->id(); } $files = $this->files() ->where('status', 'active') ->get(); foreach ($files as $file) { $status = CourseLearning::where('user_id', $userId) ->where('file_id', $file->id) ->first(); if (!empty($status)) { $passed += 1; } } return [ 'passed' => $passed, 'count' => count($files) ]; } public function getSessionsLearningProgressStat($userId = null) { $passed = 0; if (empty($userId)) { $userId = auth()->id(); } $sessions = $this->sessions() ->where('status', 'active') ->get(); foreach ($sessions as $session) { $status = CourseLearning::where('user_id', $userId) ->where('session_id', $session->id) ->first(); if (!empty($status)) { $passed += 1; } } return [ 'passed' => $passed, 'count' => count($sessions) ]; } public function getTextLessonsLearningProgressStat($userId = null) { $passed = 0; if (empty($userId)) { $userId = auth()->id(); } $textLessons = $this->textLessons() ->where('status', 'active') ->get(); foreach ($textLessons as $textLesson) { $status = CourseLearning::where('user_id', $userId) ->where('text_lesson_id', $textLesson->id) ->first(); if (!empty($status)) { $passed += 1; } } return [ 'passed' => $passed, 'count' => count($textLessons) ]; } public function getAssignmentsLearningProgressStat($userId = null) { $passed = 0; if (empty($userId)) { $userId = auth()->id(); } $assignments = $this->assignments() ->where('status', 'active') ->get(); foreach ($assignments as $assignment) { $assignmentHistory = WebinarAssignmentHistory::where('assignment_id', $assignment->id) ->where('student_id', $userId) ->where('status', WebinarAssignmentHistory::$passed) ->first(); if (!empty($assignmentHistory)) { $passed += 1; } } return [ 'passed' => $passed, 'count' => count($assignments) ]; } public function getQuizzesLearningProgressStat($userId = null) { $passed = 0; if (empty($userId)) { $userId = auth()->id(); } $quizzes = $this->quizzes() ->where('status', 'active') ->get(); foreach ($quizzes as $quiz) { $quizHistory = QuizzesResult::where('quiz_id', $quiz->id) ->where('user_id', $userId) ->where('status', QuizzesResult::$passed) ->first(); if (!empty($quizHistory)) { $passed += 1; } } return [ 'passed' => $passed, 'count' => count($quizzes) ]; } public function getProgress($isLearningPage = false) { $progress = 0; if ( auth()->check() and $this->checkUserHasBought() and ( !$this->isWebinar() or ($this->isWebinar() and $this->isProgressing()) or $isLearningPage ) ) { $user_id = auth()->id(); $filesStat = $this->getFilesLearningProgressStat($user_id); $sessionsStat = $this->getSessionsLearningProgressStat($user_id); $textLessonsStat = $this->getTextLessonsLearningProgressStat($user_id); $assignmentsStat = $this->getAssignmentsLearningProgressStat($user_id); $quizzesStat = $this->getQuizzesLearningProgressStat($user_id); $passed = $filesStat['passed'] + $sessionsStat['passed'] + $textLessonsStat['passed'] + $assignmentsStat['passed'] + $quizzesStat['passed']; $count = $filesStat['count'] + $sessionsStat['count'] + $textLessonsStat['count'] + $assignmentsStat['count'] + $quizzesStat['count']; if ($passed > 0 and $count > 0) { $progress = ($passed * 100) / $count; $this->handleLearningProgress100Reward($progress, $user_id, $this->id); } } else if (!is_null($this->capacity)) { $salesCount = !empty($this->sales_count) ? $this->sales_count : $this->sales()->count(); if ($salesCount > 0) { $progress = ($salesCount * 100) / $this->capacity; } } return round($progress, 2); } public function checkShowProgress($isLearningPage = false) { $show = false; if ( auth()->check() and $this->checkUserHasBought() and ( !$this->isWebinar() or ($this->isWebinar() and $this->isProgressing()) or $isLearningPage ) ) { $show = true; } else if (!is_null($this->capacity)) { $show = true; } return $show; } public function handleLearningProgress100Reward($progress, $userId, $itemId) { if ($progress >= 100) { $rewardScore = RewardAccounting::calculateScore(Reward::LEARNING_PROGRESS_100); RewardAccounting::makeRewardAccounting($userId, $rewardScore, Reward::LEARNING_PROGRESS_100, $itemId, true); } } public function getImageCover() { return $this->image_cover; } public function getImage() { return $this->thumbnail; } public function getUrl() { return url('/course/' . $this->slug); } public function getLearningPageUrl() { return url('/course/learning/' . $this->slug); } public function getNoticeboardsPageUrl() { return $this->getLearningPageUrl() . '/noticeboards'; } public function getForumPageUrl() { return $this->getLearningPageUrl() . '/forum'; } public function isCourse() { return ($this->type == 'course'); } public function isTextCourse() { return ($this->type == 'text_lesson'); } public function isWebinar() { return ($this->type == 'webinar'); } public function canAccess($user = null) { $result = false; if (!$user) { $user = auth()->user(); } if (!empty($user)) { if ($this->creator_id == $user->id or $this->teacher_id == $user->id) { $result = true; } // Allow Access To Partner Teachers if (!$result and $this->isPartnerTeacher($user->id)) { $result = true; } } return $result; } public function canSale() { $result = true; if (!is_null($this->capacity)) { $salesCount = !empty($this->sales_count) ? $this->sales_count : $this->sales()->count(); $result = $salesCount < $this->capacity; } if ($result and $this->type == 'webinar') { $result = ($this->start_date > time()); } return $result; } public function canJoinToWaitlist() { $hasBought = $this->checkUserHasBought(); return ($this->enable_waitlist and !$hasBought and !$this->canSale()); } public function cantSaleStatus($hasBought) { $status = ''; if ($hasBought) { $status = 'js-course-has-bought-status'; } else { if (!is_null($this->capacity)) { $salesCount = !empty($this->sales_count) ? $this->sales_count : $this->sales()->count(); if ($salesCount >= $this->capacity) { $status = 'js-course-not-capacity-status'; } } elseif ($this->type == 'webinar' and $this->start_date <= time()) { $status = 'js-course-has-started-status'; } } return $status; } public function addToCalendarLink() { $date = \DateTime::createFromFormat('j M Y H:i', dateTimeFormat($this->start_date, 'j M Y H:i', false)); $link = Link::create($this->title, $date, $date); //->description('Cookies & cocktails!') return $link->google(); } public function activeSpecialOffer() { $activeSpecialOffer = SpecialOffer::where('webinar_id', $this->id) ->where('status', SpecialOffer::$active) ->where('from_date', '<', time()) ->where('to_date', '>', time()) ->first(); return $activeSpecialOffer ?? false; } public function nextSession() { $sessions = $this->sessions() ->orderBy('date', 'asc') ->get(); $time = time(); foreach ($sessions as $session) { if ($session->date > $time) { return $session; } } return null; } public function lastSession() { $session = $this->sessions() ->orderBy('date', 'desc') ->first(); return $session; } public function isProgressing() { $lastSession = $this->lastSession(); //$nextSession = $this->nextSession(); $isProgressing = false; if (!empty($lastSession)) { $agoraHistory = AgoraHistory::where('session_id', $lastSession->id) ->first(); if ( ($lastSession->session_api != "agora" and $lastSession->date > time()) or ($lastSession->session_api == "agora" and ($lastSession->date > time() and (empty($agoraHistory) or empty($agoraHistory->end_at)))) ) { $isProgressing = true; } } if ($this->start_date > time()) { $isProgressing = true; } return $isProgressing; } public function getShareLink($social) { $link = ShareFacade::page($this->getUrl(), $this->title) ->facebook() ->twitter() ->whatsapp() ->telegram() ->getRawLinks(); return !empty($link[$social]) ? $link[$social] : ''; } public function isDownloadable() { $downloadable = $this->downloadable; if ($this->files->count() > 0) { $downloadableFiles = $this->files->where('downloadable', true)->count(); if ($downloadableFiles > 0) { $downloadable = true; } } return $downloadable; } public function isOwner($userId = null) { if (empty($userId)) { $userId = auth()->id(); } return (($this->creator_id == $userId) or ($this->teacher_id == $userId)); } public function isPartnerTeacher($userId = null) { if (empty($userId)) { $userId = auth()->id(); } $partnerTeachers = !empty($this->webinarPartnerTeacher) ? $this->webinarPartnerTeacher->pluck('teacher_id')->toArray() : []; return in_array($userId, $partnerTeachers); } public function getPrice() { $price = $this->price; $specialOffer = $this->activeSpecialOffer(); if (!empty($specialOffer)) { $price = $price - ($price * $specialOffer->percent / 100); } return $price; } public function getStudentsIds() { $studentsIds = Sale::query()->where('webinar_id', $this->id) ->whereNull('refund_at') ->whereHas('buyer') ->pluck('buyer_id') ->toArray(); // get users by installments $installmentOrders = InstallmentOrder::query() ->where('webinar_id', $this->id) ->where('status', 'open') ->whereNull('refund_at') ->get(); foreach ($installmentOrders as $installmentOrder) { if (!empty($installmentOrder)) { $hasBought = true; if ($installmentOrder->checkOrderHasOverdue()) { $overdueIntervalDays = getInstallmentsSettings('overdue_interval_days'); if (empty($overdueIntervalDays) or $installmentOrder->overdueDaysPast() > $overdueIntervalDays) { $hasBought = false; } } if ($hasBought) { $studentsIds[] = $installmentOrder->user_id; } } } // get users by gifts $gifts = Gift::query() ->where('status', 'active') ->where('webinar_id', $this->id) ->where(function ($query) { $query->whereNull('date'); $query->orWhere('date', '<', time()); }) ->whereHas('sale') ->get(); foreach ($gifts as $gift) { $user = User::query()->select('id', 'email')->where('email', $gift->email)->first(); if (!empty($user)) { $studentsIds[] = $user->id; } } // get users by bundle $bundleWebinar = BundleWebinar::where('webinar_id', $this->id) ->with([ 'bundle' ])->get(); if ($bundleWebinar->isNotEmpty()) { foreach ($bundleWebinar as $item) { if (!empty($item->bundle)) { $bundleStudents = $item->bundle->getStudentsIds(); $studentsIds = array_merge($studentsIds, $bundleStudents); } } } return array_unique($studentsIds); } public function sendNotificationToAllStudentsForNewQuizPublished($quiz) { $studentsIds = $this->getStudentsIds(); $notifyOptions = [ '[q.title]' => $quiz->title, '[c.title]' => $this->title ]; if (count($studentsIds)) { foreach ($studentsIds as $studentId) { sendNotification("new_quiz", $notifyOptions, $studentId); } } $gifts = Gift::query() ->where('status', 'active') ->where('webinar_id', $this->id) ->where(function ($query) { $query->whereNull('date'); $query->orWhere('date', '<', time()); }) ->whereHas('sale') ->get(); foreach ($gifts as $gift) { $user = User::query()->select('id', 'email')->where('email', $gift->email)->first(); if (empty($user)) { sendNotificationToEmail("new_quiz", $notifyOptions, $gift->email); } } } public function makeCourseCertificateForUser($user) { if (!empty($user) and $this->certificate and $this->getProgress(true) >= 100) { $check = Certificate::where('type', 'course') ->where('student_id', $user->id) ->where('webinar_id', $this->id) ->first(); if (empty($check)) { $makeCertificate = new MakeCertificate(); $userCertificate = $makeCertificate->saveCourseCertificate($user, $this); $certificateReward = RewardAccounting::calculateScore(Reward::CERTIFICATE); RewardAccounting::makeRewardAccounting($userCertificate->student_id, $certificateReward, Reward::CERTIFICATE, $userCertificate->id, true); } } } } Waitlist.php 0000644 00000000651 15102516312 0007053 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Waitlist extends Model { protected $table = "waitlists"; public $timestamps = false; protected $guarded = ['id']; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } WebinarChapter.php 0000644 00000004727 15102516312 0010161 0 ustar 00 <?php namespace App\Models; use App\Models\Traits\SequenceContent; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class WebinarChapter extends Model implements TranslatableContract { use Translatable; use SequenceContent; protected $table = 'webinar_chapters'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $chapterFile = 'file'; static $chapterSession = 'session'; static $chapterTextLesson = 'text_lesson'; static $chapterActive = 'active'; static $chapterInactive = 'inactive'; static $chapterTypes = ['file', 'session', 'text_lesson']; static $chapterStatus = ['active', 'inactive']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function sessions() { return $this->hasMany('App\Models\Session', 'chapter_id', 'id'); } public function files() { return $this->hasMany('App\Models\File', 'chapter_id', 'id'); } public function textLessons() { return $this->hasMany('App\Models\TextLesson', 'chapter_id', 'id'); } public function assignments() { return $this->hasMany('App\Models\WebinarAssignment', 'chapter_id', 'id'); } public function quizzes() { return $this->hasMany('App\Models\Quiz', 'chapter_id', 'id'); } public function chapterItems() { return $this->hasMany('App\Models\WebinarChapterItem', 'chapter_id', 'id'); } public function webinar() { return $this->hasOne('App\Models\Webinar', 'webinar_id', 'id'); } public function getDuration() { $time = 0; $time += $this->sessions->sum('duration'); $time += $this->textLessons->sum('study_time'); return $time; } public function getTopicsCount($withQuiz = false) { $count = 0; $count += $this->files->where('status', 'active')->count(); $count += $this->sessions->where('status', 'active')->count(); $count += $this->textLessons->where('status', 'active')->count(); $count += $this->assignments->where('status', 'active')->count(); if ($withQuiz) { $count += $this->quizzes->where('status', 'active')->count(); } return $count; } } SelectedInstallment.php 0000644 00000005707 15102516312 0011225 0 ustar 00 <?php namespace App\Models; use App\User; use Illuminate\Database\Eloquent\Model; class SelectedInstallment extends Model { protected $table = 'selected_installments'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo(User::class, 'user_id', 'id'); } public function installment() { return $this->belongsTo(Installment::class, 'installment_id', 'id'); } public function steps() { return $this->hasMany(SelectedInstallmentStep::class, 'selected_installment_id', 'id'); } public function order() { return $this->belongsTo(InstallmentOrder::class, 'installment_order_id', 'id'); } /******** * Helpers * */ public function reachedCapacityPercent() { $orders = InstallmentOrder::query() ->where('id', $this->installment_order_id) ->whereIn('status', ['open', 'pending_verification']) ->count(); $percent = 0; if ($orders > 0 and $this->installment->capacity > 0) { $percent = ($orders / $this->installment->capacity) * 100; } return $percent; } public function hasCapacity() { $result = true; if (!empty($this->installment->capacity)) { $orders = InstallmentOrder::query() ->where('id', $this->installment_order_id) ->whereIn('status', ['open', 'pending_verification']) ->count(); if ($orders >= $this->installment->capacity) { $result = false; } } return $result; } public function getUpfront($itemPrice = 1) { $result = 0; if (!empty($this->upfront) and $this->upfront > 0) { if ($this->upfront_type == 'percent') { $result = ($itemPrice * $this->upfront) / 100; } else { $result = $this->upfront; } } return $result; } public function totalPayments($itemPrice = 1, $withUpfront = true) { $total = 0; if (!empty($this->upfront) and $withUpfront) { if ($this->upfront_type == 'percent') { $total += ($itemPrice * $this->upfront) / 100; } else { $total += $this->upfront; } } foreach ($this->steps as $step) { $total += $step->getPrice($itemPrice); } return $total; } public function totalInterest($itemPrice = 1, $totalPayments = null) { if (empty($totalPayments)) { $totalPayments = $this->totalPayments($itemPrice); } $result = 0; $tmp = ($totalPayments - $itemPrice); if ($tmp > 0) { $tmp2 = ($tmp / $itemPrice) * 100; if ($tmp2 > 0) { $result = number_format($tmp2, 2); } } return $result; } } ProductCategory.php 0000644 00000003104 15102516312 0010365 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class ProductCategory extends Model implements TranslatableContract { use Translatable; protected $table = 'product_categories'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function category() { return $this->belongsTo('App\Models\ProductCategory', 'parent_id', 'id'); } public function subCategories() { return $this->hasMany($this, 'parent_id', 'id')->orderBy('order', 'asc'); } public function filters() { return $this->hasMany('App\Models\ProductFilter', 'category_id', 'id'); } public function products() { return $this->hasMany('App\Models\Product', 'category_id', 'id'); } public function getUrl() { return '/products?category_id=' . $this->id; } public function getSelfAndChideProductsCount($productType = null) { $ids = [$this->id]; $subCategoriesIds = $this->subCategories->pluck('id')->toArray(); $ids = array_merge($ids, $subCategoriesIds); $query = Product::whereIn('category_id', $ids); if (!empty($productType)) { $query->where('type', $productType); } return $query->count(); } } Verification.php 0000644 00000001364 15102516312 0007677 0 ustar 00 <?php namespace App\Models; use App\Notifications\SendVerificationEmailCode; use App\Notifications\SendVerificationSMSCode; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; class Verification extends Model { use Notifiable; protected $table = 'verifications'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; const EXPIRE_TIME = 3600; // second => 1 hour public function user() { return $this->belongsTo('App\User'); } public function sendEmailCode() { $this->notify(new SendVerificationEmailCode($this)); } public function sendSMSCode() { $this->notify(new SendVerificationSMSCode($this)); } } ProductSelectedSpecificationMultiValue.php 0000644 00000001124 15102516312 0015051 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ProductSelectedSpecificationMultiValue extends Model { protected $table = 'product_selected_specification_multi_values'; public $timestamps = false; protected $guarded = ['id']; public function selectedSpecification() { return $this->belongsTo('App\Models\ProductSelectedSpecification','selected_specification_id','id'); } public function multiValue() { return $this->belongsTo('App\Models\ProductSpecificationMultiValue','specification_multi_value_id','id'); } } RegistrationPackage.php 0000644 00000002770 15102516312 0011205 0 ustar 00 <?php namespace App\Models; use App\Mixins\RegistrationPackage\UserPackage; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class RegistrationPackage extends Model implements TranslatableContract { use Translatable; protected $table = 'registration_packages'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function sales() { return $this->hasMany('App\Models\Sale','registration_package_id','id'); } public function activeSpecialOffer() { $activeSpecialOffer = SpecialOffer::where('registration_package_id', $this->id) ->where('status', SpecialOffer::$active) ->where('from_date', '<', time()) ->where('to_date', '>', time()) ->first(); return $activeSpecialOffer ?? false; } public function getPrice() { $price = $this->price; $specialOffer = $this->activeSpecialOffer(); if (!empty($specialOffer)) { $price = $price - ($price * $specialOffer->percent / 100); } return $price; } } Session.php 0000644 00000007542 15102516312 0006704 0 ustar 00 <?php namespace App\Models; use App\Models\Traits\SequenceContent; use Illuminate\Database\Eloquent\Model; use Spatie\CalendarLinks\Link; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Session extends Model implements TranslatableContract { use Translatable; use SequenceContent; public $timestamps = false; protected $guarded = ['id']; protected $table = 'sessions'; protected $dateFormat = 'U'; static $Active = 'active'; static $Inactive = 'inactive'; static $Status = ['active', 'inactive']; static $sessionApis = ['local', 'big_blue_button', 'zoom', 'agora', 'jitsi', 'google_meet']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function creator() { return $this->hasOne('App\User', 'user_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function sessionReminds() { return $this->hasMany('App\Models\SessionRemind', 'session_id', 'id'); } public function learningStatus() { return $this->hasOne('App\Models\CourseLearning', 'session_id', 'id'); } public function chapter() { return $this->belongsTo('App\Models\WebinarChapter', 'chapter_id', 'id'); } public function agoraHistory() { return $this->hasOne('App\Models\AgoraHistory', 'session_id', 'id'); } public function addToCalendarLink() { try { $date = \DateTime::createFromFormat('j M Y H:i', dateTimeFormat($this->date, 'j M Y H:i', false)); $link = Link::create($this->title, $date, $date); //->description('Cookies & cocktails!') return $link->google(); } catch (\Exception $exception) { return ''; } } public function getJoinLink($zoom_start_link = false) { $link = $this->link; if ($this->session_api == 'big_blue_button') { $link = url('panel/sessions/' . $this->id . '/joinToBigBlueButton'); } /*if ($zoom_start_link and auth()->check() and auth()->id() == $this->creator_id and $this->session_api == 'zoom') { $link = $this->zoom_start_link; }*/ if ($this->session_api == 'agora') { $link = url('panel/sessions/' . $this->id . '/joinToAgora'); } if ($this->session_api == 'jitsi') { $link = url('panel/sessions/' . $this->id . '/joinToJitsi'); } return $link; } public function isFinished(): bool { $agoraHistory = $this->agoraHistory; $finished = (!empty($agoraHistory) and !empty($agoraHistory->end_at)); if (!$finished) { $finished = (time() > (($this->duration * 60) + $this->date)); } return $finished; } public function checkPassedItem() { $result = false; if (auth()->check()) { $check = $this->learningStatus()->where('user_id', auth()->id())->count(); $result = ($check > 0); } return $result; } public function getSessionStreamType() { $setting = null; if (!empty($this->reserve_meeting_id)) { $setting = getFeaturesSettings('meeting_live_stream_type'); } else { $setting = getFeaturesSettings('course_live_stream_type'); } $sessionStreamType = 'single'; if (!empty($setting) and in_array($setting, ['single', 'multiple'])) { $sessionStreamType = $setting; } return $sessionStreamType; } } QuizzesQuestion.php 0000644 00000003043 15102516312 0010453 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class QuizzesQuestion extends Model implements TranslatableContract { use Translatable; protected $table = 'quizzes_questions'; public $timestamps = false; protected $guarded = ['id']; static $multiple = 'multiple'; static $descriptive = 'descriptive'; public $translatedAttributes = ['title', 'correct']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getCorrectAttribute() { return getTranslateAttributeValue($this, 'correct'); } public function quizzesQuestionsAnswers() { return $this->hasMany('App\Models\QuizzesQuestionsAnswer', 'question_id', 'id'); } public function canAccessToEdit($user = null) { if (empty($user)) { $user = auth()->user(); } $result = false; if (!empty($user)) { $quiz = Quiz::find($this->quiz_id); $webinar = null; if (!empty($quiz->webinar_id)) { $webinar = Webinar::query()->find($quiz->webinar_id); } if ($quiz->creator_id != $user->id and (!empty($webinar) and $webinar->canAccess($user))) { $quiz = null; } if (!empty($quiz)) { $result = true; } } return $result; } } InstallmentOrder.php 0000644 00000014775 15102516312 0010555 0 ustar 00 <?php namespace App\Models; use App\User; use Illuminate\Database\Eloquent\Model; class InstallmentOrder extends Model { protected $table = 'installment_orders'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo(User::class, 'user_id', 'id'); } public function installment() { return $this->belongsTo(Installment::class, 'installment_id', 'id'); } public function selectedInstallment() { return $this->hasOne(SelectedInstallment::class, 'installment_order_id', 'id'); } public function webinar() { return $this->belongsTo(Webinar::class, 'webinar_id', 'id'); } public function product() { return $this->belongsTo(Product::class, 'product_id', 'id'); } public function bundle() { return $this->belongsTo(Bundle::class, 'bundle_id', 'id'); } public function subscribe() { return $this->belongsTo(Subscribe::class, 'subscribe_id', 'id'); } public function registrationPackage() { return $this->belongsTo(RegistrationPackage::class, 'registration_package_id', 'id'); } public function payments() { return $this->hasMany(InstallmentOrderPayment::class, 'installment_order_id', 'id'); } public function attachments() { return $this->hasMany(InstallmentOrderAttachment::class, 'installment_order_id', 'id'); } /******** * Helpers * */ public function getItem() { $item = null; if (!empty($this->webinar_id)) { $item = $this->webinar; } else if (!empty($this->bundle_id)) { $item = $this->bundle; } else if (!empty($this->product_id)) { $item = $this->product; } else if (!empty($this->subscribe_id)) { $item = $this->subscribe; } else if (!empty($this->registration_package_id)) { $item = $this->registrationPackage; } return $item; } public function getItemType() { $type = null; if (!empty($this->webinar_id)) { $type = 'course'; } else if (!empty($this->bundle_id)) { $type = "bundle"; } else if (!empty($this->product_id)) { $type = "product"; } else if (!empty($this->subscribe_id)) { $type = "subscribe"; } else if (!empty($this->registration_package_id)) { $type = "registrationPackage"; } return $type; } public function getItemPrice() { return $this->attributes['item_price']; } public function isCompleted() { $result = false; if ($this->status == "open") { $installment = $this->selectedInstallment; $installmentSteps = $installment->steps; $paid = true; foreach ($installmentSteps as $step) { if ($paid) { $payment = InstallmentOrderPayment::query() ->where('installment_order_id', $this->id) ->where('selected_installment_step_id', $step->id) ->where('status', 'paid') ->first(); if (empty($payment)) { $paid = false; } } } $result = $paid; } return $result; } public function checkOrderHasOverdue() { $result = false; $time = time(); if ($this->status == 'open') { foreach ($this->selectedInstallment->steps as $step) { $dueAt = ($step->deadline * 86400) + $this->created_at; if ($time > $dueAt) { $payment = InstallmentOrderPayment::query() ->where('installment_order_id', $this->id) ->where('selected_installment_step_id', $step->id) ->where('status', 'paid') ->first(); if (empty($payment)) { $result = true; } } } } return $result; } public function getOrderOverdueCountAndAmount() { $count = 0; $amount = 0; $time = time(); $itemPrice = $this->getItemPrice(); if ($this->status == 'open' and !empty($itemPrice)) { foreach ($this->selectedInstallment->steps as $step) { $dueAt = ($step->deadline * 86400) + $this->created_at; if ($time > $dueAt) { $payment = InstallmentOrderPayment::query() ->where('installment_order_id', $this->id) ->where('selected_installment_step_id', $step->id) ->where('status', 'paid') ->first(); if (empty($payment)) { $count += 1; $amount += $step->getPrice($itemPrice); } } } } return [ 'count' => $count, 'amount' => $amount, ]; } public function overdueDaysPast() { $result = 0; $time = time(); if ($this->status == 'open') { foreach ($this->selectedInstallment->steps as $step) { $dueAt = ($step->deadline * 86400) + $this->created_at; if ($time > $dueAt) { $payment = InstallmentOrderPayment::query() ->where('installment_order_id', $this->id) ->where('selected_installment_step_id', $step->id) ->where('status', 'paid') ->first(); if (empty($payment)) { $daysPast = ($time - $dueAt) / (86400); $result = $daysPast > 0 ? $daysPast : 0; } } } } return $result; } public function getCompletePrice($itemPrice = null) { if (empty($itemPrice)) { $itemPrice = $this->getItemPrice(); } $amount = 0; $installment = $this->selectedInstallment; if (!empty($installment)) { $amount = $installment->getUpfront($itemPrice); foreach ($installment->steps as $step) { $amount += $step->getPrice($itemPrice); } } return $amount; } } Follow.php 0000644 00000000456 15102516312 0006520 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Follow extends Model { public static $requested = "requested"; public static $accepted = "accepted"; public static $rejected = "rejected"; public $timestamps = false; protected $guarded = ['id']; } AdvertisingBanner.php 0000644 00000001756 15102516312 0010667 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class AdvertisingBanner extends Model implements TranslatableContract { use Translatable; protected $table = 'advertising_banners'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'image']; static $positions = [ 'home1', 'home2', 'course', 'course_sidebar', 'product_show', 'bundle', 'bundle_sidebar', 'upcoming_course', 'upcoming_course_sidebar' ]; static $size = [ '12' => 'full', '6' => '1/2', '4' => '1/3', '3' => '1/4' ]; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getImageAttribute() { return getTranslateAttributeValue($this, 'image'); } } Promotion.php 0000644 00000001520 15102516312 0007235 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Promotion extends Model implements TranslatableContract { use Translatable; protected $table = 'promotions'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function sales() { return $this->hasMany('App\Models\Sale', 'promotion_id', 'id')->whereNull('refund_at'); } } PaymentChannel.php 0000644 00000004373 15102516312 0010166 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class PaymentChannel extends Model { protected $table = 'payment_channels'; protected $guarded = ['id']; public $timestamps = false; static $classes = [ 'Alipay', 'Authorizenet', 'Bitpay', 'Braintree', 'Cashu', 'Flutterwave', 'Instamojo', 'Iyzipay', 'Izipay', 'KlarnaCheckout', 'MercadoPago', 'Midtrans', 'Mollie', 'Ngenius', 'Payfort', 'Payhere', 'Payku', 'Paylink', 'Paypal', 'Paysera', 'Paystack', 'Paytm', 'Payu', 'Razorpay', 'Robokassa', 'Sslcommerz', 'Stripe', 'Toyyibpay', 'Voguepay', 'YandexCheckout', 'Zarinpal', 'JazzCash', 'Redsys' ]; static $gatewayIgnoreRedirect = [ 'Paytm', 'Payu', 'Zarinpal', 'Stripe', 'Paysera', 'Cashu', 'MercadoPago', 'Payhere', 'Authorizenet', 'Voguepay', 'Payku', 'KlarnaCheckout', 'Izipay', 'Iyzipay', 'JazzCash', 'Redsys' ]; static $paypal = 'Paypal'; static $paystack = 'Paystack'; static $paytm = 'Paytm'; static $payu = 'Payu'; static $razorpay = 'Razorpay'; static $zarinpal = 'Zarinpal'; static $stripe = 'Stripe'; static $paysera = 'Paysera'; static $fastpay = 'Fastpay'; static $yandexcheckout = 'YandexCheckout'; static $twoCheckout = '2checkout'; static $bitpay = 'Bitpay'; static $midtrans = 'Midtrans'; static $adyen = 'Adyen'; static $flutterwave = 'Flutterwave'; static $payfort = 'Payfort'; static $sslcommerz = 'Sslcommerz'; static $instamojo = 'Instamojo'; static $payhere = 'Payhere'; static $ngenius = 'Ngenius'; static $authorizenet = 'Authorizenet'; static $voguepay = 'Voguepay'; static $payku = 'Payku'; static $toyyibpay = 'Toyyibpay'; static $robokassa = 'Robokassa'; static $klarnaCheckout = 'KlarnaCheckout'; static $mollie = 'Mollie'; static $alipay = 'Alipay'; static $braintree = 'Braintree'; static $izipay = 'Izipay'; static $paylink = 'Paylink'; static $jazzCash = 'JazzCash'; static $redsys = 'Redsys'; public function getCurrenciesAttribute() { if (!empty($this->attributes['currencies'])) { return json_decode($this->attributes['currencies'], true); } return []; } } UserMeta.php 0000644 00000000460 15102516312 0006776 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UserMeta extends Model { protected $table = 'users_metas'; protected $guarded = ['id']; public $timestamps = false; // education, // experience // gender => man | woman // birthday // address } ReserveMeeting.php 0000644 00000004043 15102516312 0010176 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Spatie\CalendarLinks\Link; class ReserveMeeting extends Model { protected $table = "reserve_meetings"; public static $open = "open"; public static $finished = "finished"; public static $pending = "pending"; public static $canceled = "canceled"; public $timestamps = false; protected $guarded = ['id']; public function meetingTime() { return $this->belongsTo('App\Models\MeetingTime', 'meeting_time_id', 'id'); } public function meeting() { return $this->belongsTo('App\Models\Meeting', 'meeting_id', 'id'); } public function sale() { return $this->belongsTo('App\Models\Sale', 'sale_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function session() { return $this->hasOne('App\Models\Session', 'reserve_meeting_id', 'id'); } public function getDiscountPrice($user) { $price = $this->paid_amount; $totalDiscount = 0; if (!empty($this->discount)) { $totalDiscount += ($price * $this->discount) / 100; } if (!empty($user) and !empty($user->getUserGroup()) and isset($user->getUserGroup()->discount) and $user->getUserGroup()->discount > 0) { $totalDiscount += ($price * $user->getUserGroup()->discount) / 100; } return $totalDiscount; } public function addToCalendarLink() { $day = $this->day; $times = $this->meetingTime->time; $times = explode('-', $times); $start_time = date("H:i", strtotime($times[0])); $end_time = date("H:i", strtotime($times[1])); $startDate = \DateTime::createFromFormat('Y-m-d H:i', $day . ' ' . $start_time); $endDate = \DateTime::createFromFormat('Y-m-d H:i', $day . ' ' . $end_time); $link = Link::create('Meeting', $startDate, $endDate); //->description('Cookies & cocktails!') return $link->google(); } } Payout.php 0000644 00000001022 15102516312 0006525 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Payout extends Model { public static $waiting = 'waiting'; public static $done = 'done'; public static $reject = 'reject'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function userSelectedBank() { return $this->belongsTo('App\Models\UserSelectedBank', 'user_selected_bank_id', 'id'); } } ForumTopicReport.php 0000644 00000001135 15102516312 0010534 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ForumTopicReport extends Model { protected $table = 'forum_topic_reports'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function topic() { return $this->belongsTo('App\Models\ForumTopic', 'topic_id', 'id'); } public function topicPost() { return $this->belongsTo('App\Models\ForumTopicPost', 'topic_post_id', 'id'); } } ForumTopic.php 0000644 00000003262 15102516312 0007343 0 ustar 00 <?php namespace App\Models; use Cviebrock\EloquentSluggable\Services\SlugService; use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Model; class ForumTopic extends Model { use Sluggable; protected $table = 'forum_topics'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function sluggable() { return [ 'slug' => [ 'source' => 'title' ] ]; } public static function makeSlug($title) { return SlugService::createSlug(self::class, 'slug', $title); } public function creator() { return $this->belongsTo('App\User', 'creator_id', 'id'); } public function forum() { return $this->belongsTo('App\Models\Forum', 'forum_id', 'id'); } public function attachments() { return $this->hasMany('App\Models\ForumTopicAttachment', 'topic_id', 'id'); } public function likes() { return $this->hasMany('App\Models\ForumTopicLike', 'topic_id', 'id'); } public function posts() { return $this->hasMany('App\Models\ForumTopicPost', 'topic_id', 'id'); } public function getPostsUrl() { return "/forums/{$this->forum->slug}/topics/{$this->slug}/posts"; } public function getLikeUrl() { return "/forums/{$this->forum->slug}/topics/{$this->slug}/likeToggle"; } public function getBookmarkUrl() { return "/forums/{$this->forum->slug}/topics/{$this->slug}/bookmark"; } public function getEditUrl() { return "/forums/{$this->forum->slug}/topics/{$this->slug}/edit"; } } Favorite.php 0000644 00000000612 15102516312 0007027 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Favorite extends Model { public $timestamps = false; protected $guarded = ['id']; public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } ForumRecommendedTopicItem.php 0000644 00000000423 15102516312 0012321 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ForumRecommendedTopicItem extends Model { protected $table = 'forum_recommended_topic_items'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; } UserZoomApi.php 0000644 00000000534 15102516312 0007470 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class UserZoomApi extends Model { protected $table = 'users_zoom_api'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } ForumRecommendedTopic.php 0000644 00000000704 15102516312 0011504 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class ForumRecommendedTopic extends Model { protected $table = 'forum_recommended_topics'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function topics() { return $this->belongsToMany('App\Models\ForumTopic', 'forum_recommended_topic_items', 'recommended_topic_id', 'topic_id'); } } CommentReport.php 0000644 00000001457 15102516312 0010056 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class CommentReport extends Model { protected $table = 'comments_reports'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function comment() { return $this->belongsTo('App\Models\Comment', 'comment_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function blog() { return $this->belongsTo('App\Models\Blog', 'blog_id', 'id'); } public function product() { return $this->belongsTo('App\Models\Product', 'product_id', 'id'); } } InstallmentStep.php 0000644 00000002624 15102516312 0010403 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class InstallmentStep extends Model implements TranslatableContract { use Translatable; protected $table = 'installment_steps'; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getAmountAttribute() { return $this->attributes['amount'] + 0; } /********* * Relations * */ public function installment() { return $this->belongsTo(Installment::class, 'installment_id', 'id'); } /********* * Helpers * */ public function getPrice($itemPrice = 1) { if ($this->amount_type == 'percent') { return ($itemPrice * $this->amount) / 100; } else { return $this->amount; } } public function getDeadlineTitle($itemPrice = 1) { $percentText = ($this->amount_type == 'percent') ? "({$this->amount}%)" : ''; // $100 after 30 days return trans('update.amount_after_n_days', ['amount' => handlePrice($this->getPrice($itemPrice)), 'days' => $this->deadline, 'percent' => $percentText]); } } OfflinePayment.php 0000644 00000001234 15102516312 0010171 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class OfflinePayment extends Model { public static $waiting = 'waiting'; public static $approved = 'approved'; public static $reject = 'reject'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function offlineBank() { return $this->belongsTo('App\Models\OfflineBank', 'offline_bank_id', 'id'); } public function getAttachmentPath() { return '/store/' . $this->user_id . '/offlinePayments/' . $this->attachment; } } FloatingBar.php 0000644 00000002760 15102516312 0007446 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Http\Request; class FloatingBar extends Model implements TranslatableContract { use Translatable; protected $table = 'floating_bars'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'description', 'btn_text']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function getBtnTextAttribute() { return getTranslateAttributeValue($this, 'btn_text'); } public static function getFloatingBar(Request $request) { $testPreview = !empty($request->get('preview_floating_bar')); $time = time(); $query = FloatingBar::query(); $query->where(function ($query) use ($time) { $query->whereNull('start_at'); $query->orWhere('start_at', '<', $time); }); $query->where(function ($query) use ($time) { $query->whereNull('end_at'); $query->orWhere('end_at', '>', $time); }); if (!$testPreview) { $query->where('enable', true); } return $query->first(); } } ProductFaq.php 0000644 00000001273 15102516312 0007324 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class ProductFaq extends Model implements TranslatableContract { use Translatable; protected $table = 'product_faqs'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'answer']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getAnswerAttribute() { return getTranslateAttributeValue($this, 'answer'); } } SelectedInstallmentStep.php 0000644 00000002413 15102516312 0012050 0 ustar 00 <?php namespace App\Models; use App\User; use Illuminate\Database\Eloquent\Model; class SelectedInstallmentStep extends Model { protected $table = 'selected_installment_steps'; public $timestamps = false; protected $guarded = ['id']; public function selectedInstallment() { return $this->belongsTo(SelectedInstallment::class, 'selected_installment_id', 'id'); } public function installmentStep() { return $this->belongsTo(InstallmentStep::class, 'installment_step_id', 'id'); } public function orderPayment() { return $this->hasOne(InstallmentOrderPayment::class, 'selected_installment_step_id', 'id'); } /******** * Helpers * */ public function getPrice($itemPrice = 1) { if ($this->amount_type == 'percent') { return ($itemPrice * $this->amount) / 100; } else { return $this->amount; } } public function getDeadlineTitle($itemPrice = 1) { $percentText = ($this->amount_type == 'percent') ? "({$this->amount}%)" : ''; // $100 after 30 days return trans('update.amount_after_n_days', ['amount' => handlePrice($this->getPrice($itemPrice)), 'days' => $this->deadline, 'percent' => $percentText]); } } FeatureWebinar.php 0000644 00000001417 15102516312 0010157 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class FeatureWebinar extends Model implements TranslatableContract { use Translatable; protected $dateFormat = 'U'; public $timestamps = false; protected $guarded = ['id']; protected $table = 'feature_webinars'; static $pages = ['categories', 'home', 'home_categories']; public $translatedAttributes = ['description']; public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } } Support.php 0000644 00000001324 15102516312 0006725 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Support extends Model { protected $table = 'supports'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public function department() { return $this->belongsTo('App\Models\SupportDepartment', 'department_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function conversations() { return $this->hasMany('App\Models\SupportConversation', 'support_id', 'id'); } } InstallmentReminder.php 0000644 00000000533 15102516312 0011232 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class InstallmentReminder extends Model { protected $table = 'installment_reminders'; public $timestamps = false; protected $guarded = ['id']; } FilterOption.php 0000644 00000001042 15102516312 0007664 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class FilterOption extends Model implements TranslatableContract { use Translatable; protected $table = 'filter_options'; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } } DiscountBundle.php 0000644 00000000707 15102516312 0010177 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class DiscountBundle extends Model { protected $table = 'discount_bundles'; public $timestamps = false; protected $guarded = ['id']; public function discount() { return $this->belongsTo('App\Models\Discount', 'discount_id', 'id'); } public function bundle() { return $this->belongsTo('App\Models\Bundle', 'bundle_id', 'id'); } } GroupUser.php 0000644 00000000602 15102516312 0007202 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class GroupUser extends Model { public $timestamps = false; protected $guarded = ['id']; public function group() { return $this->belongsTo('App\Models\Group', 'group_id', 'id'); } public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } Faq.php 0000644 00000001213 15102516312 0005755 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Faq extends Model implements TranslatableContract { use Translatable; protected $table = 'faqs'; public $timestamps = false; protected $guarded = ['id']; public $translatedAttributes = ['title', 'answer']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getAnswerAttribute() { return getTranslateAttributeValue($this, 'answer'); } } Installment.php 0000644 00000015735 15102516312 0007556 0 ustar 00 <?php namespace App\Models; use App\User; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class Installment extends Model implements TranslatableContract { use Translatable; protected $table = 'installments'; public $timestamps = false; protected $guarded = ['id']; static $optionsExplodeKey = "8888"; // Enums static $targetTypes = ['all', 'courses', 'store_products', 'bundles', 'meetings', 'registration_packages', 'subscription_packages']; static $courseTargets = ['all_courses', 'live_classes', 'video_courses', 'text_courses', 'specific_categories', 'specific_instructors', 'specific_courses']; static $productTargets = ['all_products', 'virtual_products', 'physical_products', 'specific_categories', 'specific_sellers', 'specific_products']; static $bundleTargets = ['all_bundles', 'specific_categories', 'specific_instructors', 'specific_bundles']; static $meetingTargets = ['all_meetings', 'specific_instructors']; static $subscriptionTargets = ['all_packages', 'specific_packages']; static $registrationPackagesTargets = ['all_packages', 'specific_packages']; public $translatedAttributes = ['title', 'main_title', 'description', 'banner', 'options', 'verification_description', 'verification_banner', 'verification_video']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getMainTitleAttribute() { return getTranslateAttributeValue($this, 'main_title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function getBannerAttribute() { return getTranslateAttributeValue($this, 'banner'); } public function getOptionsAttribute() { return getTranslateAttributeValue($this, 'options'); } public function getVerificationDescriptionAttribute() { return getTranslateAttributeValue($this, 'verification_description'); } public function getVerificationBannerAttribute() { return getTranslateAttributeValue($this, 'verification_banner'); } public function getVerificationVideoAttribute() { return getTranslateAttributeValue($this, 'verification_video'); } public function getUpfrontAttribute() { return $this->attributes['upfront'] + 0; } // ############# // Relations // ############ public function userGroups() { return $this->hasMany(InstallmentUserGroup::class, 'installment_id', 'id'); } public function specificationItems() // used just in query { return $this->hasMany(InstallmentSpecificationItem::class, 'installment_id', 'id'); } public function categories() { return $this->belongsToMany(Category::class, 'installment_specification_items', 'installment_id', 'category_id'); } public function instructors() { return $this->belongsToMany(User::class, 'installment_specification_items', 'installment_id', 'instructor_id'); } public function sellers() { return $this->belongsToMany(User::class, 'installment_specification_items', 'installment_id', 'seller_id'); } public function webinars() { return $this->belongsToMany(Webinar::class, 'installment_specification_items', 'installment_id', 'webinar_id'); } public function products() { return $this->belongsToMany(Product::class, 'installment_specification_items', 'installment_id', 'product_id'); } public function bundles() { return $this->belongsToMany(Bundle::class, 'installment_specification_items', 'installment_id', 'bundle_id'); } public function subscribes() { return $this->belongsToMany(Subscribe::class, 'installment_specification_items', 'installment_id', 'subscribe_id'); } public function registrationPackages() { return $this->belongsToMany(RegistrationPackage::class, 'installment_specification_items', 'installment_id', 'registration_package_id'); } public function steps() { return $this->hasMany(InstallmentStep::class, 'installment_id', 'id'); } public function orders() { return $this->hasMany(InstallmentOrder::class, 'installment_id', 'id'); } // ############# // Helpers // ############ public function reachedCapacityPercent() { $orders = InstallmentOrder::query() ->where('installment_id', $this->id) ->whereIn('status', ['open', 'pending_verification']) ->count(); $percent = 0; if ($orders > 0 and $this->capacity > 0) { $percent = ($orders / $this->capacity) * 100; } return $percent; } public function hasCapacity() { $result = true; if (!empty($this->capacity)) { $orders = InstallmentOrder::query() ->where('installment_id', $this->id) ->whereIn('status', ['open', 'pending_verification']) ->count(); if ($orders >= $this->capacity) { $result = false; } } return $result; } public function getUpfront($itemPrice = 1) { $result = 0; if (!empty($this->upfront) and $this->upfront > 0) { if ($this->upfront_type == 'percent') { $result = ($itemPrice * $this->upfront) / 100; } else { $result = $this->upfront; } } return $result; } public function totalPayments($itemPrice = 1, $withUpfront = true) { $total = 0; if (!empty($this->upfront) and $withUpfront) { if ($this->upfront_type == 'percent') { $total += ($itemPrice * $this->upfront) / 100; } else { $total += $this->upfront; } } foreach ($this->steps as $step) { $total += $step->getPrice($itemPrice); } return $total; } public function totalInterest($itemPrice = 1, $totalPayments = null) { if (empty($totalPayments)) { $totalPayments = $this->totalPayments($itemPrice); } $result = 0; $tmp = ($totalPayments - $itemPrice); if ($tmp > 0) { $tmp2 = ($tmp / $itemPrice) * 100; if ($tmp2 > 0) { $result = number_format($tmp2, 2); } } return $result; } public function needToVerify($user = null) { $result = false; if (empty($user)) { $user = auth()->user(); } if ($this->verification) { $result = true; if (!empty($user) and $this->bypass_verification_for_verified_users and $user->installment_approval) { $result = false; } } return $result; } } ProductSelectedSpecification.php 0000644 00000002064 15102516312 0013045 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class ProductSelectedSpecification extends Model implements TranslatableContract { use Translatable; protected $table = 'product_selected_specifications'; public $timestamps = false; protected $guarded = ['id']; static $inputTypes = ['textarea', 'multi_value']; static $Active = 'active'; static $Inactive = 'inactive'; static $itemsStatus = ['active', 'inactive']; public $translatedAttributes = ['value']; public function getValueAttribute() { return getTranslateAttributeValue($this, 'value'); } public function specification() { return $this->belongsTo('App\Models\ProductSpecification', 'product_specification_id', 'id'); } public function selectedMultiValues() { return $this->hasMany('App\Models\ProductSelectedSpecificationMultiValue', 'selected_specification_id', 'id'); } } Page.php 0000644 00000001507 15102516312 0006130 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class Page extends Model implements TranslatableContract { use Translatable; protected $table = 'pages'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'seo_description', 'content']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getSeoDescriptionAttribute() { return getTranslateAttributeValue($this, 'seo_description'); } public function getContentAttribute() { return getTranslateAttributeValue($this, 'content'); } } TextLesson.php 0000644 00000003204 15102516312 0007360 0 ustar 00 <?php namespace App\Models; use App\Models\Traits\SequenceContent; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class TextLesson extends Model implements TranslatableContract { use Translatable; use SequenceContent; protected $table = 'text_lessons'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; static $Active = 'active'; static $Inactive = 'inactive'; static $Status = ['active', 'inactive']; public $translatedAttributes = ['title', 'summary', 'content']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getSummaryAttribute() { return getTranslateAttributeValue($this, 'summary'); } public function getContentAttribute() { return getTranslateAttributeValue($this, 'content'); } public function attachments() { return $this->hasMany('App\Models\TextLessonAttachment', 'text_lesson_id', 'id'); } public function learningStatus() { return $this->hasOne('App\Models\CourseLearning', 'text_lesson_id', 'id'); } public function chapter() { return $this->belongsTo('App\Models\WebinarChapter', 'chapter_id', 'id'); } public function checkPassedItem() { $result = false; if (auth()->check()) { $check = $this->learningStatus()->where('user_id', auth()->id())->count(); $result = ($check > 0); } return $result; } } DeleteAccountRequest.php 0000644 00000000515 15102516312 0011342 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class DeleteAccountRequest extends Model { protected $table = 'delete_account_requests'; public $timestamps = false; protected $guarded = ['id']; public function user() { return $this->belongsTo('App\User', 'user_id', 'id'); } } error_log 0000644 00000011354 15102516312 0006461 0 ustar 00 [04-Nov-2025 19:36:40 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/UserSelectedBankSpecification.php:9 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/UserSelectedBankSpecification.php on line 9 [04-Nov-2025 19:45:34 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/OrderItem.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/OrderItem.php on line 7 [04-Nov-2025 20:07:43 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/ProductSpecificationCategory.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/ProductSpecificationCategory.php on line 7 [04-Nov-2025 20:45:28 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/SupportConversation.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/SupportConversation.php on line 7 [04-Nov-2025 20:55:12 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/SelectedInstallment.php:8 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/SelectedInstallment.php on line 8 [04-Nov-2025 20:55:41 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/InstallmentReminder.php:9 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/InstallmentReminder.php on line 9 [04-Nov-2025 21:47:27 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Comment.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Comment.php on line 7 [04-Nov-2025 21:47:44 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Support.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Support.php on line 7 [04-Nov-2025 21:48:39 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Session.php:11 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Session.php on line 11 [04-Nov-2025 21:49:41 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/SaleLog.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/SaleLog.php on line 7 [04-Nov-2025 21:50:47 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/UserMeta.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/UserMeta.php on line 7 [04-Nov-2025 21:51:47 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Waitlist.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Waitlist.php on line 7 [04-Nov-2025 21:54:48 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Meeting.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Meeting.php on line 7 [04-Nov-2025 21:55:52 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/Contact.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/Contact.php on line 7 [04-Nov-2025 23:03:52 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/UpcomingCourseFollower.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/UpcomingCourseFollower.php on line 7 [04-Nov-2025 23:18:48 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/AffiliateCode.php:7 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/AffiliateCode.php on line 7 [05-Nov-2025 00:15:51 UTC] PHP Fatal error: Uncaught Error: Class "Illuminate\Database\Eloquent\Model" not found in /home/vielwcom/www3.vielw.com/app/Models/CashbackRuleSpecificationItem.php:9 Stack trace: #0 {main} thrown in /home/vielwcom/www3.vielw.com/app/Models/CashbackRuleSpecificationItem.php on line 9 WebinarAssignment.php 0000644 00000004403 15102516312 0010672 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use App\Models\Traits\SequenceContent; class WebinarAssignment extends Model implements TranslatableContract { use Translatable; use SequenceContent; protected $table = 'webinar_assignments'; public $timestamps = false; protected $dateFormat = 'U'; protected $guarded = ['id']; public $translatedAttributes = ['title', 'description']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function getDescriptionAttribute() { return getTranslateAttributeValue($this, 'description'); } public function webinar() { return $this->belongsTo('App\Models\Webinar', 'webinar_id', 'id'); } public function chapter() { return $this->belongsTo('App\Models\WebinarChapter', 'chapter_id', 'id'); } public function attachments() { return $this->hasMany('App\Models\WebinarAssignmentAttachment', 'assignment_id', 'id'); } public function assignmentHistory() { return $this->hasOne('App\Models\WebinarAssignmentHistory', 'assignment_id', 'id'); } public function instructorAssignmentHistories() { return $this->hasMany('App\Models\WebinarAssignmentHistory', 'assignment_id', 'id'); } public function getAssignmentHistoryByStudentId($studentId) { return $this->assignmentHistory() ->where('student_id', $studentId) ->first(); } public function getDeadlineTimestamp($user = null) { $deadline = null; // default can access if (empty($user)) { $user = auth()->user(); } if (!empty($this->deadline)) { $sale = Sale::where('buyer_id', $user->id) ->where('webinar_id', $this->webinar_id) ->whereNull('refund_at') ->first(); if (!empty($sale)) { $deadline = strtotime("+{$this->deadline} days", $sale->created_at); } else { $deadline = false; } } return $deadline; } } Ticket.php 0000644 00000003523 15102516312 0006477 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; class Ticket extends Model implements TranslatableContract { use Translatable; public $timestamps = false; protected $table = 'tickets'; protected $guarded = ['id']; public $translatedAttributes = ['title']; public function getTitleAttribute() { return getTranslateAttributeValue($this, 'title'); } public function isValid() { $now = time(); $ticket = $this; $valid = true; if ($ticket->start_date > $now or $this->end_date < $now) { $valid = false; } if ($ticket->capacity) { $ticketUserCount = TicketUser::where('ticket_id', $ticket->id)->count(); if ($ticketUserCount and $ticket->capacity <= $ticketUserCount) { $valid = false; } } return $valid; } public function getSubTitle() { $title = ''; if (!empty($this->end_date) and !empty($this->capacity)) { $title = trans('public.ticket_for_students_until_date', ['students' => $this->capacity, 'date' => dateTimeFormat($this->end_date, 'j F Y')]); } elseif (!empty($this->end_date)) { $title = trans('public.ticket_until_date', ['date' => dateTimeFormat($this->end_date, 'j F Y')]); } return $title; } public function getPriceWithDiscount($price, $activeSpecialOffer = null) { $percent = $this->discount; if (!empty($activeSpecialOffer)) { $percent = $percent + $activeSpecialOffer->percent; } if ($percent > 0) { $price = $price - ($price * $percent / 100); } return $price; } } InstallmentSpecificationItem.php 0000644 00000000557 15102516312 0013072 0 ustar 00 <?php namespace App\Models; use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract; use Astrotomic\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; class InstallmentSpecificationItem extends Model { protected $table = 'installment_specification_items'; public $timestamps = false; protected $guarded = ['id']; } BundleFilterOption.php 0000644 00000000343 15102516312 0011021 0 ustar 00 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class BundleFilterOption extends Model { protected $table = 'bundle_filter_option'; public $timestamps = false; protected $guarded = ['id']; }
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка