408 lines
14 KiB
PHP
408 lines
14 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Articles;
|
|
use App\Models\Banners;
|
|
use App\Models\Benefits;
|
|
use App\Models\Blogs;
|
|
use App\Models\Countries;
|
|
use App\Models\Faqs;
|
|
use App\Models\Features;
|
|
use App\Models\Galleries;
|
|
use App\Models\Institutions;
|
|
use App\Models\Popups;
|
|
use App\Models\Preparationclasses;
|
|
use App\Models\Preparationclassoffers;
|
|
use App\Models\Quicklinks;
|
|
use App\Models\Services;
|
|
use App\Models\Settings;
|
|
use App\Models\Success_stories;
|
|
use App\Models\Teams;
|
|
use App\Models\Testimonials;
|
|
use App\Models\Visa_grants;
|
|
use App\Models\Visagrantposts;
|
|
use CCMS;
|
|
use Illuminate\Http\Request; // Import the Request class
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class WebsiteController extends Controller
|
|
{
|
|
private $path;
|
|
public function __construct()
|
|
{
|
|
$this->path = config('app.client_path');
|
|
$setting = Settings::where('status', 1)->first();
|
|
|
|
View::share([
|
|
'setting' => $setting,
|
|
]);
|
|
}
|
|
|
|
public function home()
|
|
{
|
|
$channelId = env('CHANNEL_ID');
|
|
$videos = fetchVideosByChannel($channelId);
|
|
|
|
return view('landing.index', [
|
|
'videos' => $videos,
|
|
'banners' => Banners::get(),
|
|
'benefits' => Benefits::get(),
|
|
'success_stories' => Success_stories::get(),
|
|
'visa_grants' => Visa_grants::get(),
|
|
]);
|
|
}
|
|
|
|
public function showTeam()
|
|
{
|
|
$teamList = Teams::orderBy('display_order', 'asc')->get();
|
|
return view("$this->path.pages.team", compact('teamList'));
|
|
}
|
|
|
|
public function storeRegisterForm(Request $request)
|
|
{
|
|
$validator = Validator::make($request->all(), [
|
|
'name' => 'required|min:3',
|
|
'email' => 'required|email',
|
|
'phone' => 'required',
|
|
'preferred_class' => 'required',
|
|
'agree_term' => 'required',
|
|
]);
|
|
|
|
if ($validator->fails());
|
|
}
|
|
|
|
public function showTestimonals()
|
|
{
|
|
$testimonials = Testimonials::where("status", 1)->latest()->get();
|
|
return view("$this->path.pages.testimonial", compact('testimonials'));
|
|
}
|
|
|
|
public static function index(Request $request, $menu_id = "")
|
|
{
|
|
$pathInfo = ltrim($request->getPathInfo(), '/');
|
|
$r = explode('/', $pathInfo);
|
|
$menu_alias = end($r);
|
|
$menu_alias1 = str_replace("_", "-", $menu_alias);
|
|
$menuItem = DB::table("menuitems")->where("alias", $menu_alias)->orWhere("alias", $menu_alias1)->get()[0];
|
|
switch ($menuItem->type) {
|
|
case 'tbl_contacts':
|
|
$contact = DB::table("contacts")->where("contact_id", $menuItem->ref)->get()[0];
|
|
|
|
return view("client.jupiter.inside.contact", compact('contact'));
|
|
// break;
|
|
case 'tbl_countries':
|
|
//$countries=DB::table("countries")->where("article_id",$menuItem->ref)->get()[0];
|
|
//return view("client.jupiter.inside.article",compact('article'));
|
|
//break;
|
|
case 'tbl_articles':
|
|
$article = DB::table("articles")->where("article_id", $menuItem->ref)->get()[0];
|
|
return view("client.jupiter.inside.article", compact('article'));
|
|
//break;
|
|
case '':
|
|
default:
|
|
// echo $menuItem->alias;die;
|
|
if ($menuItem->ref == "/") {
|
|
return view("client.jupiter.welcome");
|
|
} else if ($menuItem->ref == "#") {
|
|
return view("client.jupiter.welcome");
|
|
} else {
|
|
return view("client.jupiter.inside" . ltrim($menuItem->ref));
|
|
}
|
|
}
|
|
}
|
|
|
|
public function showRegisterForm(Request $request)
|
|
{
|
|
$preparationclass_id = $request->id;
|
|
$preparation_classes = Preparationclassoffers::where('status', 1)->get();
|
|
return view($this->path . ".register", compact('preparation_classes', 'preparationclass_id'));
|
|
}
|
|
|
|
public function showCareersList()
|
|
{
|
|
$class = Preparationclasses::where('alias', 'careers')->where('parent_preparationclass', 0)->where('status', 1)->with('children')->first();
|
|
if (!$class) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
return view($this->path . ".careers.careers-list", compact('class'));
|
|
}
|
|
public function showSkillsList()
|
|
{
|
|
$class = Preparationclasses::where('alias', 'skills')->where('parent_preparationclass', 0)->where('status', 1)->with('children')->first();
|
|
if (!$class) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
return view($this->path . ".skills.skills-list", compact('class'));
|
|
}
|
|
|
|
public function showDestinations(Request $r)
|
|
{
|
|
return view($this->path . ".destinations");
|
|
}
|
|
|
|
public function showDestination($alias = null, $subalias = null)
|
|
{
|
|
if ($alias) {
|
|
$destination = Countries::where('alias', $alias)->with(['articles', 'institutions'])->first();
|
|
if (!$destination) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
return view("$this->path.pages.destination", compact('destination'));
|
|
}
|
|
}
|
|
|
|
public function showPreparationClasses(Request $r)
|
|
{
|
|
$course = Preparationclasses::where('alias', 'courses')->where('parent_preparationclass', 0)->where('status', 1)->with('children')->first();
|
|
|
|
if (!$course) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
$classes = $course->children;
|
|
return view($this->path . ".preparationclasses.preparationclasses", compact('classes'));
|
|
}
|
|
|
|
public function showPreparationClass(Request $r, $alias, $subalias = null)
|
|
{
|
|
$data = Preparationclasses::where('alias', $alias)->where('status', 1)->first();
|
|
if (!$data) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
return view("$this->path.pages.class", compact('data'));
|
|
}
|
|
|
|
public function showVisaSuccess()
|
|
{
|
|
$visaSuccessPosts = Visagrantposts::latest()->get();
|
|
return view("$this->path.pages.visa-success", compact('visaSuccessPosts'));
|
|
}
|
|
|
|
public function showresources(Request $r, $alias = null, $subalias = null)
|
|
{
|
|
try {
|
|
if ($alias) {
|
|
$data = DB::table("resources")->where("alias", $alias)->first();
|
|
$data->Childrens = DB::table("resources")->where("parent_resource", $data->resource_id)->get();
|
|
|
|
if ($subalias) {
|
|
$data->Article = DB::table("resources")->where("alias", $subalias)->first();
|
|
|
|
$siblings = DB::table("resources")
|
|
->where("parent_resource", $data->resource_id)
|
|
->where("resource_id", "<>", $data->Article->resource_id)
|
|
->whereNotIn("resource_id", function ($query) {
|
|
$query->select("parent_resource")
|
|
->from("resources");
|
|
})
|
|
->get();
|
|
|
|
$data->Siblings = $siblings;
|
|
return view($this->path . ".resources.inside", compact('data'));
|
|
}
|
|
|
|
return view($this->path . ".resources.single", compact('data'));
|
|
}
|
|
return view($this->path . ".resources.resources");
|
|
} catch (\Exception $e) {
|
|
|
|
echo $e->getMessage();
|
|
// return view($this->path.".preparationclasses");
|
|
}
|
|
}
|
|
|
|
public function showBlogs($alias = null)
|
|
{
|
|
if ($alias) {
|
|
$blog = Blogs::where('alias', $alias)->first();
|
|
if (!$blog) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
return view("$this->path.pages.blog-single", compact('blog'));
|
|
} else {
|
|
$blogList = Blogs::latest()->paginate(6);
|
|
return view("$this->path.pages.blog-list", compact('blogList'));
|
|
}
|
|
}
|
|
|
|
public function showFaqs()
|
|
{
|
|
$faqs = Faqs::latest()->get();
|
|
return view("$this->path.pages.faq", compact('faqs'));
|
|
}
|
|
|
|
public function showServices($alias = null)
|
|
{
|
|
if ($alias) {
|
|
$service = Services::where('alias', $alias)->first();
|
|
if (!$service) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
return view("$this->path.pages.service-single", compact('service'));
|
|
} else {
|
|
|
|
$serviceList = Services::orderBy('display_order', 'asc')->take(15)->get();
|
|
return view("$this->path.pages.service-list", compact('serviceList'));
|
|
}
|
|
}
|
|
|
|
public function showArticle($parent = null, $alias = null)
|
|
{
|
|
if ($alias) {
|
|
$data = Articles::where("alias", $alias)->where('status', 1)->with('children')->first();
|
|
if (!$data) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
return view("$this->path.pages.$alias", compact('data'));
|
|
}
|
|
}
|
|
|
|
public function showevents(Request $r, $alias = null, $subalias = null)
|
|
{
|
|
try {
|
|
if ($alias) {
|
|
$data = DB::table("events")->where("alias", $alias)->first();
|
|
$data->Childrens = DB::table("events")->where("parent_event", $data->event_id)->get();
|
|
|
|
if ($subalias) {
|
|
$data->Article = DB::table("events")->where("alias", $subalias)->first();
|
|
|
|
$siblings = DB::table("events")
|
|
->where("parent_event", $data->blog_id)
|
|
->where("event_id", "<>", $data->Article->event_id)
|
|
->whereNotIn("event_id", function ($query) {
|
|
$query->select("parent_event")
|
|
->from("events");
|
|
})
|
|
->get();
|
|
|
|
$data->Siblings = $siblings;
|
|
return view($this->path . ".events.inside", compact('data'));
|
|
}
|
|
|
|
return view($this->path . ".events.single", compact('data'));
|
|
}
|
|
return view($this->path . ".events.events");
|
|
} catch (\Exception $e) {
|
|
|
|
echo $e->getMessage();
|
|
// return view($this->path.".preparationclasses");
|
|
}
|
|
}
|
|
public function shownews(Request $r, $alias = null, $subalias = null)
|
|
{
|
|
try {
|
|
if ($alias) {
|
|
$data = DB::table("news")->where("alias", $alias)->first();
|
|
$data->Childrens = DB::table("news")->where("parent_news", $data->news_id)->get();
|
|
|
|
if ($subalias) {
|
|
$data->Article = DB::table("news")->where("alias", $subalias)->first();
|
|
|
|
$siblings = DB::table("news")
|
|
->where("parent_news", $data->blog_id)
|
|
->where("news_id", "<>", $data->Article->news_id)
|
|
->whereNotIn("news_id", function ($query) {
|
|
$query->select("parent_news")
|
|
->from("news");
|
|
})
|
|
->get();
|
|
|
|
$data->Siblings = $siblings;
|
|
return view($this->path . ".news.inside", compact('data'));
|
|
}
|
|
|
|
return view($this->path . ".news.single", compact('data'));
|
|
}
|
|
return view($this->path . ".news.list");
|
|
} catch (\Exception $e) {
|
|
|
|
echo $e->getMessage();
|
|
// return view($this->path.".preparationclasses");
|
|
}
|
|
}
|
|
|
|
public function showsuccessstories(Request $r, $alias = null, $subalias = null)
|
|
{
|
|
try {
|
|
if ($alias) {
|
|
$data = DB::table("successstories")->where("alias", $alias)->first();
|
|
return view($this->path . ".successstories.single", compact('data'));
|
|
}
|
|
return view($this->path . ".successstories.list");
|
|
} catch (\Exception $e) {
|
|
createErrorLog("WebsiteController", "showsuccessstories", $e->getMessage());
|
|
echo $e->getMessage();
|
|
}
|
|
}
|
|
public function showoffices(Request $r, $alias = null, $subalias = null)
|
|
{
|
|
try {
|
|
if ($alias) {
|
|
$data = DB::table("branches")->where("alias", $alias)->first();
|
|
$data->Childrens = DB::table("brancharticles")->where("status", 1)->where("branches_id", $data->branch_id)->get();
|
|
|
|
if ($subalias) {
|
|
$data->Article = DB::table("articles")->where("alias", $subalias)->first();
|
|
|
|
$siblings = DB::table("articles")
|
|
->where("parent_article", $data->article_id)
|
|
->where("article_id", "<>", $data->Article->article_id)
|
|
->whereNotIn("article_id", function ($query) {
|
|
$query->select("parent_article")
|
|
->from("articles");
|
|
})
|
|
->get();
|
|
|
|
$data->Siblings = $siblings;
|
|
return view($this->path . ".articles.inside", compact('data'));
|
|
}
|
|
|
|
return view($this->path . ".offices.single", compact('data'));
|
|
}
|
|
return view($this->path . ".offices.list");
|
|
} catch (\Exception $e) {
|
|
|
|
echo $e->getMessage();
|
|
// return view($this->path.".preparationclasses");
|
|
}
|
|
}
|
|
public function showcontact()
|
|
{
|
|
return view("$this->path.pages.contact-us");
|
|
}
|
|
|
|
public function showapplyform(Request $r, $alias = null, $subalias = null)
|
|
{
|
|
try {
|
|
return view($this->path . ".forms.apply");
|
|
} catch (\Exception $e) {
|
|
|
|
echo $e->getMessage();
|
|
// return view($this->path.".preparationclasses");
|
|
}
|
|
}
|
|
|
|
public function showGalleries($alias = null)
|
|
{
|
|
if ($alias) {
|
|
$gallery = Galleries::where('alias', $alias)->first();
|
|
if (!$gallery) {
|
|
return view("$this->path.pages.404");
|
|
}
|
|
return view("$this->path.pages.gallery-single", compact('gallery'));
|
|
} else {
|
|
$galleryList = Galleries::where('status', 1)->latest()->select(['title', 'alias', 'thumb'])->paginate(12);
|
|
return view("$this->path.pages.gallery-list", compact('galleryList'));
|
|
}
|
|
}
|
|
|
|
public function fallback()
|
|
{
|
|
return view("$this->path.pages.404");
|
|
}
|
|
}
|