infojune/app/Http/Controllers/ContentController.php

45 lines
998 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Content;
use App\Models\Category;
use Illuminate\Http\Request;
class ContentController extends Controller
{
public function index($path){
$category = Category::where('path', $path)->firstOrFail();
//dd($category);
return view('choicebox')->with('category', $category);
}
public function show($path){
$content = Content::where('path', $path)->firstOrFail();
return view('softbox')->with('content', $content);
}
public function home(){
$categories = Category::where("category_id", null)->get();
//dd($category);
return view('home')->with('categories', $categories);
}
public function search(){
$query = request()->input('query');
$contents = Content::where('name','like',"%$query%")->orWhere('description','like',"%$query%")->get();
//dd($contents);
return view('search')->with('contents', $contents);
}
}