Php 如何为返回空结果的现有单行输出查询
我有一个页面显示一篇文章的全部细节。但这是一个错误 试图获取非对象的属性“title”(视图:C:\xampp\htdocs\myapp\resources\views\public area\View.blade.php) https://localhost/myapp/public/post/the-duchess-took-her-choice-and-was-going-to-begi/7 在blade中显示MySQL结果之前,一切似乎都很正常 这是我的密码: 逻辑: WEB.PHP:Php 如何为返回空结果的现有单行输出查询,php,laravel,Php,Laravel,我有一个页面显示一篇文章的全部细节。但这是一个错误 试图获取非对象的属性“title”(视图:C:\xampp\htdocs\myapp\resources\views\public area\View.blade.php) https://localhost/myapp/public/post/the-duchess-took-her-choice-and-was-going-to-begi/7 在blade中显示MySQL结果之前,一切似乎都很正常 这是我的密码: 逻辑: WEB.PHP:
Route::get('/post/{postTitle?}/{postId}', [PublicController::class, 'postView3'])->name('postView3')->where(['post-title' => '[A-Za-z]+', 'post-id' => '[0-9]+']);
公共控制员:
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Str;
class PublicController extends Controller
{
/**
* Show a user listing page.
* @return \Illuminate\Contracts\Support\Renderable
*/
public function postView3($postId)
{
...
//Fetch required classified-ad posts
$posts = (new \App\Logic\Listings\PostData)->singlePost_full_data3($postId);
/* Display page */
return view('public-area.view', [
..., 'posts'=>$posts
]);
}
VIEW.BLADE.PHP
<?php
$pageTitle = $posts->title; ?>
@extends('templates.template-public')
@section('page_title') {{$pageTitle}} @endsection
@section('main_content')
...
<h1>{{$pageTitle}} Listings</h1>
...
<?php
dd($posts);
$pageTitle = $posts->title; ?>
@extends('templates.template-public')
@section('page_title') {{$pageTitle}} @endsection
@section('main_content')
...
<?php
dd($posts);
$pageTitle = $posts->title; ?>
@extends('templates.template-public')
@section('page_title') {{$pageTitle}} @endsection
@section('main_content')
...
null