This commit is contained in:
tanch0
2024-06-21 13:29:04 +05:45
parent 5b3c44aa33
commit 25760ad989
50 changed files with 1180 additions and 111 deletions

View File

@ -11,6 +11,7 @@ use App\Models\Menuitems;
use App\Models\News;
use App\Models\News_type;
use App\Models\Newscategories;
use App\Models\Popups;
use App\Models\Provinces;
use Illuminate\Http\Request;
use App\Models\Teams;
@ -18,6 +19,7 @@ use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Mail;
use App\Models\Videos;
use Share;
class WebsiteController extends Controller
{
@ -28,22 +30,20 @@ class WebsiteController extends Controller
$this->path = config('app.client_path');
$headerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 1])->with('children')->orderBy('display_order')->get();
// dd($headerMenuItems->toArray());
$footerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 2])->with('children')->orderBy('display_order')->get();
$latestNews = News::where('status', 1)->inRandomOrder()->limit(4)->get();
// dd($recentNews);
$ads = Advertisements::where('status', 1)->where('parent_advertisement',0)->get();
// dd($ads->toArray());
$adsWithChildren = Advertisements::where('status',1)->where('parent_advertisement',0)->orderBy('display_order')->with('children')->get();
// dd($adsWithChildren->toArray());
$ads = Advertisements::where('status', 1)->where('parent_advertisement', 0)->get();
$adsWithChildren = Advertisements::where('status', 1)->where('parent_advertisement', 0)->orderBy('display_order')->with('children')->get();
$popup = Popups::where('status',1)->latest()->first();
View::share(
[
'headerMenuItems' => $headerMenuItems,
'footerMenuItems' => $footerMenuItems,
'latestNews' => $latestNews,
'ads' => $ads,
'adsWithChildren' => $adsWithChildren
'adsWithChildren' => $adsWithChildren,
'popup' => $popup
]
);
}
@ -96,11 +96,26 @@ class WebsiteController extends Controller
public function newsDetail($alias)
{
$shareComponent = Share::currentPage()->facebook()->twitter()->whatsapp()->linkedin();
$news = News::where('alias', $alias)->where('status', 1)->first();
$recentNews = News::where('status', 1)->where('news_id', '!=', $news->news_id)->inRandomOrder()->limit(12)->latest()->get();
return view($this->path . '.news-detail', compact('news', 'recentNews'));
if (!$news) {
abort(404, 'News not found');
}
$news->views_count = $news->views_count + 1;
$news->save();
$recentNews = News::where('status', 1)
->where('news_id', '!=', $news->news_id)
->inRandomOrder()
->limit(12)
->latest()
->get();
return view($this->path . '.news-detail', compact('news', 'recentNews','shareComponent'));
}
public function showHororscope()
{
$rashifal = Horoscopes::where('status', 1)->orderBy('display_order')->limit(12)->get();
@ -174,13 +189,14 @@ class WebsiteController extends Controller
public function showProvinces($id)
{
$categoryTitle = Provinces::where('province_id', $id)->pluck('province_nepali_name')->first();
$data = News::where('provinces_id',$id)->where('status',1)->orderBy('display_order')->paginate(9);
return view($this->path . '.single', compact('data','categoryTitle'));
$data = News::where('provinces_id', $id)->where('status', 1)->orderBy('display_order')->paginate(9);
return view($this->path . '.single', compact('data', 'categoryTitle'));
}
public function videoDetail($alias){
public function videoDetail($alias)
{
$data = Videos::where('alias', $alias)->where('status', 1)->first();
$recentNews = News::where('status',1)->inRandomOrder()->limit(12)->latest()->get();
return view($this->path . '.video-detail', compact('data','recentNews'));
$recentNews = News::where('status', 1)->inRandomOrder()->limit(12)->latest()->get();
return view($this->path . '.video-detail', compact('data', 'recentNews'));
}
}