Raffales-LMS/app/Http/Controllers/WebsiteController.php
2024-04-16 15:43:24 +05:45

422 lines
18 KiB
PHP

<?php
namespace App\Http\Controllers;
use CCMS;
use Exception;
use Illuminate\Http\Request; // Import the Request class
use Illuminate\Support\Facades\DB;
class WebsiteController extends Controller
{
private $path;
public function __construct(){
$this->path = config("app.client_path");
}
public function home(){
return view($this->path.".home");
}
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));
}
}
function showDestinations(Request $r)
{
return view(env("CLIENT_PATH") . ".destinations");
}
function showDestination(Request $r, $alias, $subalias = null)
{
$data = DB::table("countries")->where("alias", $alias)->first();
$data->Childrens = DB::table("countryarticles")
->where("countries_id", $data->country_id)
->whereNotIn("article_id", function ($query) {
$query->select("parent_article")
->from("countryarticles");
})
->whereNotIn("article_id", function ($query) use ($alias) {
$query->select("article_id")
->from("countryarticles")->where("parent_article", function ($query) use ($alias) {
$query->select("article_id")
->from("countryarticles")->where("alias", "top-reasons-to-" . $alias);
});
})
->get();
if ($subalias) {
$data->Article = DB::table("countryarticles")->where("alias", $subalias)->first();
$siblings = DB::table("countryarticles")
->where("countries_id", $data->country_id)
->where("article_id", "<>", $data->Article->article_id)
->whereNotIn("article_id", function ($query) {
$query->select("parent_article")
->from("countryarticles");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".destination.inside", compact('data'));
}
switch ($alias) {
case 'study-in-new-zealand':
return view(env("CLIENT_PATH") . ".destination.new-zealand", compact('data'));
case 'study-in-australia':
return view(env("CLIENT_PATH") . ".destination.australia", compact('data'));
case 'study-in-canada':
return view(env("CLIENT_PATH") . ".destination.canada", compact('data'));
case 'study-in-uk':
return view(env("CLIENT_PATH") . ".destination.uk", compact('data'));
case 'study-in-usa':
return view(env("CLIENT_PATH") . ".destination.usa", compact('data'));
default:
return view(env("CLIENT_PATH") . ".destination.single",compact('data'));
}
}
function showpreparationclasses(Request $r)
{
return view(env("CLIENT_PATH") . ".preparationclasses.preparationclasses");
}
function showpreparationclass(Request $r, $alias, $subalias = null)
{
try {
$data = DB::table("preparationclasses")->where("alias", $alias)->first();
$data->Childrens = DB::table("preparationclasses")->where("parent_preparationclass", $data->preparationclass_id)->get();
if ($subalias) {
$data->Article = DB::table("preparationclasses")->where("alias", $subalias)->first();
$siblings = DB::table("preparationclasses")
->where("parent_preparationclass", $data->preparationclass_id)
->where("preparationclass_id", "<>", $data->Article->preparationclass_id)
->whereNotIn("preparationclass_id", function ($query) {
$query->select("parent_preparationclass")
->from("preparationclasses");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".preparationclasses.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".preparationclasses.single", compact('data'));
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
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(env("CLIENT_PATH") . ".resources.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".resources.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".resources.resources");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showblogs(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("blogs")->where("alias", $alias)->first();
$data->Childrens = DB::table("blogs")->where("parent_blog", $data->blog_id)->get();
if ($subalias) {
$data->Article = DB::table("blogs")->where("alias", $subalias)->first();
$siblings = DB::table("blogs")
->where("parent_blog", $data->blog_id)
->where("blog_id", "<>", $data->Article->blog_id)
->whereNotIn("blog_id", function ($query) {
$query->select("parent_blog")
->from("blogs");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".blogs.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".blogs.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".blogs.blogs");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showfaqs(Request $r, $alias = null, $subalias = null)
{
try {
return view(env("CLIENT_PATH") . ".faqs");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showservices(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("services")->where("alias", $alias)->first();
$data->Childrens = DB::table("services")->where("parent_service", $data->service_id)->get();
if ($subalias) {
$data->Article = DB::table("services")->where("alias", $subalias)->first();
$siblings = DB::table("services")
->where("parent_service", $data->service_id)
->where("service_id", "<>", $data->Article->service_id)
->whereNotIn("service_id", function ($query) {
$query->select("parent_service")
->from("services");
})
->get();
$data->Siblings = $siblings;
return view(env("CLIENT_PATH") . ".services.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".services.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".services.services");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
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(env("CLIENT_PATH") . ".events.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".events.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".events.events");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
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(env("CLIENT_PATH") . ".news.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".news.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".news.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showprofile(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("articles")->where("alias", $alias)->first();
$data->Childrens = DB::table("articles")->where("parent_article", $data->article_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(env("CLIENT_PATH") . ".articles.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".articles.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".articles.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showsuccessstories(Request $r, $alias = null, $subalias = null)
{
try {
if ($alias) {
$data = DB::table("successstories")->where("alias", $alias)->first();
return view(env("CLIENT_PATH") . ".successstories.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".successstories.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showsuccessstories", $e->getMessage());
echo $e->getMessage();
}
}
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(env("CLIENT_PATH") . ".articles.inside", compact('data'));
}
return view(env("CLIENT_PATH") . ".offices.single", compact('data'));
}
return view(env("CLIENT_PATH") . ".offices.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showcontact(Request $r, $alias = null, $subalias = null)
{
try {
return view(env("CLIENT_PATH") . ".contact");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showgalleries(Request $r, $alias = null, $subalias = null)
{
try {
return view(env("CLIENT_PATH") . ".galleries.list");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
function showapplyform(Request $r, $alias = null, $subalias = null)
{
try {
return view(env("CLIENT_PATH") . ".forms.apply");
} catch (\Exception $e) {
createErrorLog("WebsiteController", "showpreparationclass", $e->getMessage());
echo $e->getMessage();
// return view(env("CLIENT_PATH").".preparationclasses");
}
}
}