36 lines
817 B
PHP
36 lines
817 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Fo;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Models\Articles;
|
||
|
|
|
||
|
|
class NewsController extends Controller
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||
|
|
*/
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
$articles = Articles::where([
|
||
|
|
['status', 1],
|
||
|
|
['category_id', 1]
|
||
|
|
])->orderBy('created_at', 'ASC')->paginate(4);
|
||
|
|
|
||
|
|
return view('fo.news.index', compact('articles'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
* @param string $slug
|
||
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||
|
|
*/
|
||
|
|
public function show(string $slug)
|
||
|
|
{
|
||
|
|
$article = Articles::where('slug', $slug)->firstOrFail();
|
||
|
|
|
||
|
|
return view('fo.news.article', compact('article'));
|
||
|
|
}
|
||
|
|
}
|