Files
UNIT3D-Community-Edition/app/Http/Controllers/ArticleController.php
HDVinnie fd964de6de (Update) Articles System
- add eager loading
- add ability to leave anon comment
- have artle comments count toward achievements
- clean up layout
-  fix lang
2018-11-05 18:02:56 -05:00

43 lines
1.0 KiB
PHP
Executable File

<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
namespace App\Http\Controllers;
use App\Article;
class ArticleController extends Controller
{
/**
* Show All Articles
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function articles()
{
$articles = Article::latest()->paginate(6);
return view('article.articles', ['articles' => $articles]);
}
/**
* Show A Article
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function post($slug, $id)
{
$article = Article::with(['user', 'comments'])->findOrFail($id);
return view('article.article', ['article' => $article]);
}
}