infojune/app/Http/Controllers/ContentController.php

45 lines
998 B
PHP
Raw Normal View History

2020-10-10 12:12:44 +02:00
<?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){
2020-10-15 12:22:51 +02:00
$content = Content::where('path', $path)->firstOrFail();
2020-10-10 12:12:44 +02:00
return view('softbox')->with('content', $content);
}
2020-10-15 12:22:51 +02:00
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();
2020-10-25 18:37:31 +01:00
//dd($contents);
2020-10-15 12:22:51 +02:00
return view('search')->with('contents', $contents);
}
2020-10-10 12:12:44 +02:00
}