Attendize/app/Helpers/helpers.php

107 lines
2.9 KiB
PHP
Raw Normal View History

2016-02-29 15:59:36 +00:00
<?php
2020-04-30 10:19:16 +00:00
use App\Models\HelpTopic;
2016-09-06 20:39:27 +00:00
if (!function_exists('money')) {
/**
* Format a given amount to the given currency
*
* @param $amount
* @param \App\Models\Currency $currency
* @return string
*/
2019-08-24 06:55:14 +00:00
function money($amount, \App\Models\Currency $currency = null)
{
2019-08-24 06:55:14 +00:00
if(!$currency){
2020-04-09 09:40:19 +00:00
return number_format($amount,2,'.',',').trans('ClientSide.currency_code');
2019-08-24 06:55:14 +00:00
}
2016-09-06 20:39:27 +00:00
return $currency->symbol_left . number_format($amount, $currency->decimal_place, $currency->decimal_point,
$currency->thousand_point) . $currency->symbol_right;
}
2016-03-05 00:18:10 +00:00
}
2019-08-24 06:55:14 +00:00
if(!function_exists('main_categories')){
2019-08-24 06:55:14 +00:00
/**
* return main categories
* @return mixed
*/
function main_categories(){
2020-02-07 15:10:36 +00:00
return \App\Models\Category::main()->pluck('title_ru','id');
2019-08-24 06:55:14 +00:00
}
}
2019-11-02 10:32:23 +00:00
if(!function_exists('venues_list')){
function venues_list(){
2020-04-06 07:55:30 +00:00
return \App\Models\Venue::select('venue_name_'.config('app.locale'),'id')
2020-03-05 13:58:32 +00:00
->where('active',1)
2020-04-06 07:55:30 +00:00
->pluck('venue_name_'.config('app.locale'),'id');
2019-11-02 10:32:23 +00:00
}
}
if(!function_exists('sections_list')){
function sections_list($venue_id){
2020-03-05 13:58:32 +00:00
return \App\Models\Section::select('id','section_no_ru')
->where('venue_id',$venue_id)
->pluck('section_no_ru','id');
2019-11-02 10:32:23 +00:00
}
}
2019-08-28 06:34:37 +00:00
if(!function_exists('category_menu')){
/**
* make menu from categories
*/
function category_menu(){
2019-10-02 14:08:07 +00:00
return \App\Models\Category::main()->select('id','title_tk','title_ru')->get();
2019-09-14 12:27:41 +00:00
// $categories = main_categories();
// if(count($categories)>6){
// //todo implement top category menu
// }
2019-08-28 06:34:37 +00:00
}
}
2019-08-24 06:55:14 +00:00
if(! function_exists('sub_categories')){
/**
* return sub categoreies
*/
function sub_categories(){
return \App\Models\Category::sub()
->select(trans('Category.category_title'),'id','parent_id')
->get();
}
}
2019-08-26 13:17:34 +00:00
if(!function_exists('organisers')){
2019-08-26 13:17:34 +00:00
function organisers(){
if(Illuminate\Support\Facades\Auth::user()->is_admin)
return \App\Models\Organiser::all();
else
return \Illuminate\Support\Facades\Auth::user()->account->organisers;
}
}
2019-11-05 12:28:51 +00:00
if(!function_exists('zanitlananlar')){
function zanitlananlar($ticket){
$reserved = $ticket->reserved->pluck('seat_no')
->transform(function ($item,$key){
return [$item => 'reserved'];
});
2019-11-05 12:28:51 +00:00
$booked = $ticket->booked->pluck('seat_no')
->transform(function ($item,$key){
return [$item =>'booked'];
});
2019-11-16 11:26:11 +00:00
return $booked->merge($reserved)->toJson();
2019-11-05 12:28:51 +00:00
}
}
2020-04-30 10:19:16 +00:00
if(!function_exists('help_topics')){
function help_topics(){
2020-05-01 11:32:41 +00:00
$topics = HelpTopic::where('active',1)
2020-04-30 10:19:16 +00:00
->select(['id','title_'.config('app.locale').' as title'])
->orderBy('position','asc')
->pluck('title','id');
2020-05-01 11:32:41 +00:00
2020-05-01 11:48:45 +00:00
return $topics->append(0 , trans('ClientSide.other'));
2020-04-30 10:19:16 +00:00
}
}