first(); $features = Features::all(); return [ 'content' => $content, 'features' => $features ]; } public function getAppsFeatures() { $features = AppsFeature::all(); $content = AppsPage::select('section_feature_desc', 'section_feature_big_title', 'section_feature_small_title')->first(); return [ 'content' => $content, 'features' => $features ]; } public function getAppsPricing() { $content = AppsPagePricing::first(); return $content; } public function getAppsProject() { $projects = Project::orderBy('id', 'DESC')->limit(9)->get(); $project_count = Project::count(); $project_category = Project::select('category')->distinct()->get(['category']); $content = AppsPage::first(); return ['projects' => $projects, 'count' => $project_count, 'category' => $project_category, 'content' => $content]; } public function getAndroidFeatures() { $features = AndroidFeature::all(); $content = AndroidPage::select('section_feature_desc', 'section_feature_big_title', 'section_feature_small_title')->first(); return [ 'features' => $features, 'content' => $content ]; } public function getAndroidPricing() { $content = AndroidPagePricing::first(); return $content; } public function getAndroidProject() { $projects = AndroidProject::orderBy('id', 'DESC')->limit(9)->get(); $project_count = AndroidProject::count(); $project_category = AndroidProject::select('category')->distinct()->get(['category']); $content = AndroidPage::first(); return [ 'projects' => $projects, 'project_count' => $project_count, 'project_category' => $project_category, 'content' => $content ]; } public function loadMoreAndroidProject(Request $request) { $last_id = $request->get('last_id'); $category = $request->get('category'); if($category == 'all') { $projects = AndroidProject::where('id', '<' , $last_id)->limit(9)->orderBy('id', 'DESC')->get(); } else { $projects = AndroidProject::where([['id', '<' , $last_id],['category', $category]])->limit(9)->orderBy('id', 'DESC')->get(); } return $projects; } public function loadMoreAndroidProjectByCategory(Request $request) { $category = $request->get('category'); if($category == 'all') { $projects = AndroidProject::orderBy('id', 'DESC')->limit(9)->get(); $project_count = AndroidProject::count(); } else { $projects = AndroidProject::where('category', $category)->orderBy('id', 'DESC')->limit(9)->get(); $project_count = AndroidProject::where('category', $category)->count(); } return [ 'projects' => $projects, 'project_count' => $project_count ]; } public function loadMoreAppsProject(Request $request) { $last_id = $request->get('last_id'); $category = $request->get('category'); if($category == 'all') { $projects = Project::where('id', '<' , $last_id)->limit(9)->orderBy('id', 'DESC')->get(); } else { $projects = Project::where([['id', '<' , $last_id],['category', $category]])->limit(9)->orderBy('id', 'DESC')->get(); } return $projects; } public function loadAppsProjectByCategory(Request $request) { $category = $request->get('category'); if($category == 'all') { $projects = Project::orderBy('id', 'DESC')->limit(9)->get(); $project_count = Project::count(); } else { $projects = Project::where('category', $category)->orderBy('id', 'DESC')->limit(9)->get(); $project_count = Project::where('category', $category)->count(); } return ['projects' => $projects, 'count' => $project_count]; } public function appsProjectDetail(Request $request) { $content = AppsPage::first(); $slug = $request->get('slug'); $project = Project::where('slug', $slug)->with('detail', 'images')->first(); $related_projects = Project::where([['category', $project->category], ['id', '!=', $project->id]])->orderBy('id', 'DESC')->limit(3)->get(); return ['project' => $project, 'related' => $related_projects, 'content' => $content]; } public function getAsetFeatures() { $content = AsetPage::select('section_feature_desc', 'section_feature_big_title', 'section_feature_small_title')->first(); $features = AsetFeature::all(); return [ 'content' => $content, 'features' => $features ]; } public function getAsetPricing() { $pricing = AsetPagePricing::first(); return $pricing; } public function getEmkaFeatures() { $features = EmkaFeature::all(); $content = EmkaPage::select('section_feature_desc', 'section_feature_big_title', 'section_feature_small_title')->first(); return [ 'features' => $features, 'content' => $content ]; } public function getEmkaPricing() { $pricing = EmkaPagePricing::first(); return $pricing; } public function getTeams() { $teams = TeamCategory::with('team')->get(); return $teams; } public function getHomePage() { $content = HomePage::first(); $services = Services::all(); $faqs = FaqHome::all(); $features = HomePageFeature::all(); $testi = json_decode($content->testimonial, true); if($testi) { $testimonials = Testimonial::whereIn('id', $testi)->get(); } else { $testimonials = NULL; } return [ 'content' => $content, 'services' => $services, 'faqs' => $faqs, 'features' => $features, 'testimonials' => $testimonials ]; } public function getAboutPage() { $content = AboutPage::with('testimonial1', 'testimonial2', 'testimonial3')->first(); $timeline = TimelineYear::orderBy('year')->with('desc')->get(); $teams = Team::all(); $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where('status', 'post')->orderBy('post', 'DESC')->limit(3)->with('user', 'category')->get(); return [ 'content' => $content, 'timeline' => $timeline, 'teams' => $teams, 'blogs' => $blogs ]; } public function getBlogPage(Request $request) { $content = BlogPage::first(); $category = BlogCategory::whereHas('blog', function($q) { $q->where('status', 'post'); })->get(); $recent_post = Blog::select('title','slug', 'image', 'post')->where('status', 'post')->orderBy('post', 'DESC')->limit(3)->get(); // tags $tags = []; $tag = Blog::select('tags')->where('status', 'post')->get(); if($tag) { foreach($tag as $t) { $tags = array_unique(array_merge($tags, json_decode($t->tags, true))); } } if(isset($_GET['category']) && $_GET['category']) { $slug_category = $_GET['category']; $blogs = Blog::whereHas('category', function ($q) use($slug_category) { $q->where('slug', $slug_category); })->select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where('status', 'post')->orderBy('post', 'DESC')->limit(5)->with('category', 'user')->get(); $blogs_count = Blog::whereHas('category', function ($q) use($slug_category) { $q->where('slug', $slug_category); })->where('status', 'post')->count(); } else if(isset($_GET['tag']) && $_GET['tag']) { $tag_name = $_GET['tag']; $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where([['status', 'post'],['tags', 'LIKE', "%".$tag_name."%"]])->orderBy('post', 'DESC')->limit(5)->with('category', 'user')->get(); $blogs_count = Blog::where([['status', 'post'],['tags', 'LIKE', "%".$tag_name."%"]])->count(); } else if(isset($_GET['title']) && $_GET['title']) { $title = $_GET['title']; $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where([['status', 'post'],['title', 'LIKE', "%".$title."%"]])->orderBy('post', 'DESC')->limit(5)->with('category', 'user')->get(); $blogs_count = Blog::where([['status', 'post'],['title', 'LIKE', "%".$title."%"]])->count(); } else { $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where('status', 'post')->orderBy('post', 'DESC')->limit(5)->with('category', 'user')->get(); $blogs_count = Blog::where('status', 'post')->count(); } $post_count = []; foreach($category as $c) { $post_count[$c->id] = Blog::where([['blog_category_id', $c->id],['status', 'post']])->count(); } return [ 'content' => $content, 'blogs' => $blogs, 'category' => $category, 'recent_post' => $recent_post, 'tags' => $tags, 'blogs_count' => $blogs_count, 'post_count' => $post_count ]; } public function loadMoreBlog(Request $request) { $last_post = $request->get('last_post'); if(isset($_GET['category']) && $_GET['category']) { $slug_category = $_GET['category']; $blogs = Blog::whereHas('category', function ($q) use($slug_category) { $q->where('slug', $slug_category); })->select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where([['status', 'post'],['post', '<', $last_post]])->orderBy('post', 'DESC')->limit(5)->with('user')->get(); $blogs_count = Blog::whereHas('category', function ($q) use($slug_category) { $q->where('slug', $slug_category); })->where([['status', 'post'],['post', '<', $last_post]])->count(); } else if(isset($_GET['tag']) && $_GET['tag']) { $tag_name = $_GET['tag']; $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where([['status', 'post'],['tags', 'LIKE', "%".$tag_name."%"],['post', '<', $last_post]])->orderBy('post', 'DESC')->limit(5)->with('user')->get(); $blogs_count = Blog::where([['status', 'post'],['tags', 'LIKE', "%".$tag_name."%"],['post', '<', $last_post]])->count(); } else if(isset($_GET['search']) && $_GET['search']) { $title = $_GET['search']; $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where([['status', 'post'],['title', 'LIKE', "%".$title."%"],['post', '<', $last_post]])->orderBy('post', 'DESC')->limit(5)->with('user')->get(); $blogs_count = Blog::where([['status', 'post'],['title', 'LIKE', "%".$title."%"],['post', '<', $last_post]])->count(); } else { $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where([['status', 'post'],['post', '<', $last_post]])->orderBy('post', 'DESC')->limit(5)->with('user')->get(); $blogs_count = Blog::where([['status', 'post'],['post', '<', $last_post]])->count(); } return [ 'blogs' => $blogs, 'blogs_count' => $blogs_count ]; } public function getBlogDetail(Request $request) { $slug = $request->get('slug'); $content = BlogPage::first(); $category = BlogCategory::whereHas('blog', function($q) { $q->where('status', 'post'); })->get(); $blog = Blog::where('slug', $slug)->with('user')->first(); $recent_post = Blog::select('title','slug', 'image', 'post')->where('status', 'post')->orderBy('post', 'DESC')->limit(3)->get(); // tags $tags = []; $tag = Blog::select('tags')->get(); if($tag) { foreach($tag as $t) { $tags = array_unique(array_merge($tags, json_decode($t->tags, true))); } } $post_count = []; foreach($category as $c) { $post_count[$c->id] = Blog::where([['blog_category_id', $c->id],['status', 'post']])->count(); } return [ 'blog' => $blog, 'content' => $content, 'category' => $category, 'recent_post' => $recent_post, 'tags' => $tags, 'post_count' => $post_count ]; } public function getContactPage() { $content = ContactUsPage::first(); return $content; } public function getSitePage() { $content = SitePage::first(); $templates = Template::select('name', 'slug', 'image', 'link_demo')->orderBy('id', 'DESC')->limit(3)->get(); $testi = json_decode($content->testimonial, true); if($testi) { $testimonials = Testimonial::whereIn('id', $testi)->get(); } else { $testimonials = NULL; } return [ 'content' => $content, 'templates' => $templates, 'testimonials' => $testimonials ]; } public function getAndroidPage() { $content = AndroidPage::first(); $teams = Team::all(); $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where('status', 'post')->orderBy('post', 'DESC')->limit(3)->with('user', 'category')->get(); $testi = json_decode($content->testimonial, true); if($testi) { $testimonials = Testimonial::whereIn('id', $testi)->get(); } else { $testimonials = NULL; } return [ 'content' => $content, 'teams' => $teams, 'blogs' => $blogs, 'testimonials' => $testimonials ]; } public function getAsetPage() { $content = AsetPage::first(); $teams = Team::all(); $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where('status', 'post')->orderBy('post', 'DESC')->limit(3)->with('category', 'user')->get(); $testi = json_decode($content->testimonial, true); if($testi) { $testimonials = Testimonial::whereIn('id', $testi)->get(); } else { $testimonials = NULL; } return [ 'content' => $content, 'teams' => $teams, 'testimonials' => $testimonials, 'blogs' => $blogs ]; } public function getEmkaPage() { $content = EmkaPage::first(); $teams = Team::all(); $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where('status', 'post')->orderBy('post', 'DESC')->limit(3)->with('category', 'user')->get(); $testi = json_decode($content->testimonial, true); if($testi) { $testimonials = Testimonial::whereIn('id', $testi)->get(); } else { $testimonials = NULL; } return [ 'content' => $content, 'teams' => $teams, 'blogs' => $blogs, 'testimonials' => $testimonials ]; } public function getAppsPage() { $content = AppsPage::first(); $teams = Team::all(); $blogs = Blog::select('title', 'post', 'user_id', 'title', 'image', 'slug', 'blog_category_id')->where('status', 'post')->orderBy('post', 'DESC')->limit(3)->with('category', 'user')->get(); $testi = json_decode($content->testimonial, true); if($testi) { $testimonials = Testimonial::whereIn('id', $testi)->get(); } else { $testimonials = NULL; } return [ 'content' => $content, 'teams' => $teams, 'blogs' => $blogs, 'testimonials' => $testimonials ]; } public function getSitePricing() { $content = SitePage::select('section_template_desc')->first(); return $content; } public function getHelpSite() { $category = sitehelpcategory::with('help')->get(); return $category; } public function getHelpSiteDetail(Request $request) { $slug = $request->get('slug'); $help = sitehelp::where('slug',$slug)->first(); $category = sitehelpcategory::all(); return [ 'help' => $help, 'category' => $category ]; } public function getHelpEmka() { $category = emkahelpcategory::with('help')->get(); $content = EmkaPage::first(); return [ 'category' => $category, 'content' => $content ]; } public function getHelpEmkaDetail(Request $request) { $slug = $request->get('slug'); $content = EmkaPage::first(); $help = emkahelp::where('slug',$slug)->first(); $category = emkahelpcategory::with('help')->get(); return [ 'content' => $content, 'help' => $help, 'category' => $category ]; } public function getAndroidProjectDetail(Request $request) { $slug = $request->get('slug'); $project = AndroidProject::where('slug', $slug)->with('images', 'detail')->first(); $content = AndroidPage::first(); $related_projects = AndroidProject::where([['category', $project->category], ['id', '!=', $project->id]])->orderBy('id', 'DESC')->limit(3)->get(); return [ 'project' => $project, 'content' => $content, 'related_projects' => $related_projects ]; } public function orderWebsite() { $content = SitePage::select('section_template_desc')->first(); $templates = Template::select('id','name', 'slug', 'image', 'link_demo')->orderBy('id', 'DESC')->limit(9)->get(); $template_count = Template::count(); $template_category = Template::select('category')->distinct()->get(['category']); return [ 'content' => $content, 'templates' => $templates, 'template_count' => $template_count, 'template_category' => $template_category ]; } public function orderBinggo(Request $request) { $profile = Whmcs::GetClientsDetails([ 'clientid' => $request->get('whmcs_id') ]); $product = Whmcs::GetProducts([ 'pid' => $request->get('pid') ]); $template_id = $request->get('template_id'); $template_name = strtolower(str_replace(' ', '_', Template::findOrFail($template_id)->name)); $template_dashboard_type = Template::findOrFail($template_id)->dashboard; $agent_domain = $request->get('agent_domain'); $agent_id = Agent::where('domain', $agent_domain)->first()->id; $order = new OrderAgent(); $order->agent_id = $agent_id; $order->order_agent_id = $request->get('order_id'); $order->domain = $request->get('domain'); $order->template_id = $template_id; $order->name = $profile['client']['fullname']; $order->email = $profile['client']['email']; $order->template = $template_name; $order->dashboard = $template_dashboard_type; $order->service = $product['products']['product'][0]['name']; $order->pid = $request->get('pid'); $order->status = 'Unpaid'; $order->whmcs_client_id = $request->get('whmcs_id'); $order->created_at = date('Y-m-d H:i:s'); $order->save(); return 'true'; } public function getTemplateDetail(Request $request) { $template_id = $request->get('template_id'); $template = Template::findOrFail($template_id); return $template; } public function deleteOrder(Request $request) { $id = $request->get('id'); $order = OrderAgent::where('order_agent_id', $id)->first(); if($order->whmcs_order_id) { Whmcs::DeleteOrder([ 'orderid' => $order->whmcs_order_id ]); } OrderAgent::where('order_agent_id', $id)->delete(); return 'true'; } public function getAltMedia(Request $request) { $image = $request->get('image'); $media = Media::where('name', $image)->first(); if($media) { return $media->alt; } else { return ''; } } public function unpaidToInactive(Request $request) { $domain = $request->get('domain'); $agent_id = Agent::where('domain', $domain)->first()->id; $order_id = $request->get('order_id'); $order = OrderAgent::where([['agent_id', $agent_id], ['order_agent_id', $order_id]])->first(); $order->status = 'waiting for whmcs'; $order->save(); return 'true'; } public function getDepositAgent(Request $request) { $domain = $request->get('domain'); $agent = Agent::where('domain', $domain)->first(); return [ 'deposit' => $agent->deposit, 'income' => $agent->income ]; } public function switchingIncome(Request $request) { $domain = $request->get('domain'); $agent = Agent::where('domain', $domain)->first(); $agent->deposit = $request->get('deposit'); $agent->income = $request->get('income'); $agent->save(); return 'true'; } public function getWithdrawRequest(Request $request) { $domain = $request->get('domain'); $agent = Agent::where('domain', $domain)->first(); $withdraw = AgentWithdraw::where([['agent_id', $agent->id], ['bukti_pembayaran', NULL]])->orderBy('id', 'desc')->get(); return $withdraw; } public function addWithdrawRequest(Request $request) { $domain = $request->get('domain'); $agent = Agent::where('domain', $domain)->first(); $amount = str_replace(',', '.', str_replace('.', '', $request->get('amount'))); $withdraw = new AgentWithdraw(); $withdraw->agent_id = $agent->id; $withdraw->amount = $amount; $withdraw->status = 'unpaid'; $withdraw->created_at = date('Y-m-d H:i:s'); $withdraw->save(); return [ 'response' => 'success', 'created_at' => date('Y-m-d H:i:s'), 'amount' => number_format($amount, 0, ',', '.') ]; } }