I'm new to Laravel.
(我是Laravel的新手。)
I keep getting this syntax error:
(我不断收到此语法错误:)
SymfonyComponentDebugExceptionFatalThrowableError
syntax error, unexpected '.'
The line in question is this:
(有问题的行是这样的:)
$post = .DB::table('posts')->where('slug', $slug)->first();
Here's the entire code that is not working:
(这是整个无效的代码:)
<?php
namespace AppHttpControllers;
class PostsController extends Controller
{
public function show($slug)
{
$post = .DB::table('posts')->where('slug', $slug)->first();
dd($post);
// This was to simulate a database
// $posts = [
// 'my-first-post' => 'Hello This is my first blog post',
// 'my-second-post' => 'Hello This is my second blog post',
// ];
// if it doesn't exist then throw this error:
if (! array_key_exists($post, $posts)){
abort(404, 'Sorry, that post was not found.');
}
// return this view:
return view('post', [
'post' => $posts[$post]
]);
}
}
What is it that I am missing here!?
(我在这里想念什么!?)
Thanks
(谢谢)
ask by henry translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…