Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 18.216.122.2
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : BlogController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Banner;
use App\Models\Post;
use App\Models\Comment;
use App\Models\CommentReplay;
use App\Models\User;

class BlogController extends Controller
{
    //
    public function index()
    {
        // Banner
        $data['banner'] = DB::table('banners')->where('banner_id',4)->first();

        // CMS
        $data['sec_1'] = collect(DB::select("SELECT * FROM `cms` WHERE `cms_id` = 4 && `cms_status` = 1"))->first();

        // Posts
        // $data['posts'] = DB::select("SELECT * FROM `posts` WHERE `post_status` = 1 order by `post_id` desc");
        $data['posts'] = Post::orderBy('post_id', 'DESC')->get();
        // $data['posts'] = Post::latest()->get();
        
        return view('blog',$data);
    }

    public function post_detail($id)
    {
        // Banner
        $data['banner'] = DB::table('banners')->where('banner_id',10)->first();
        
        $data['data'] = Post::find($id);
        $data['comments'] = Comment::where('post_id', $id)->get();
        // $data['reply'] = CommentReplay::all();
        $data['reply'] = DB::select("SELECT r.`id`, r.`comment_id`, r.`user_id`, r.`comment`, r.`created_at`, u.`name` as userName from `comment_replies` as r left join `users` u on u.`id` = r.`user_id`");

        return view('blog_detail',$data);
    }
}
© 2025 GrazzMean-Shell