43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Endpoint\Wap\Http\Controllers;
|
|
|
|
use App\Models\Article;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ArticleController extends Controller
|
|
{
|
|
/**
|
|
* 文章详情
|
|
*
|
|
* @param [type] $id
|
|
* @return void
|
|
*/
|
|
public function show($id, Request $request)
|
|
{
|
|
$article = Article::where('is_show', 1)->findOrFail($id);
|
|
|
|
$view = '';
|
|
//区分文章分类ID
|
|
switch ($article->category_id) {
|
|
case app_settings('app.article_agreement'): //如果是协议分类
|
|
$view = 'endpoint.article.agreement';
|
|
break;
|
|
default:
|
|
//区分文章的分类祖先ID
|
|
switch ($article->category->ancestors->first()?->id) {
|
|
case app_settings('app.article_agreement'): //如果是协议
|
|
$view = 'endpoint.article.agreement';
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
if (!$view) {
|
|
abort(404);
|
|
}
|
|
return view($view, compact('article'));
|
|
}
|
|
}
|