Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 试图获得财产';图像';非对象拉威尔的研究_Php_Laravel_Laravel 5.5 - Fatal编程技术网

Php 试图获得财产';图像';非对象拉威尔的研究

Php 试图获得财产';图像';非对象拉威尔的研究,php,laravel,laravel-5.5,Php,Laravel,Laravel 5.5,我的控制器中有以下代码: public function getBycountryCategory($country,$category) { $category = TourCategory::where('slug',$category)->first(); $country = Country::where('name','=',$country)->first(); $tours = $country->tours()->with(

我的控制器中有以下代码:

    public function getBycountryCategory($country,$category)
{
    $category = TourCategory::where('slug',$category)->first();
    $country = Country::where('name','=',$country)->first();
    $tours = $country->tours()->with('region')->get(['region_id']);
    $regions = $tours->pluck('region')->unique();

        return view('public.pages.region-list')
        ->withRegions($regions)
        ->withCategory($category)
        ->withCountry($country);
 }

@foreach($regions as $region)
  <div class="col-md-4">
    <a href="{{ route('getByregion',[$category->slug,$region->slug]) }}">
      <img src="{{ asset($region->image) }}" alt="">
      <div class="location-item" style="background-image: url({{ asset($region->image) }});">

        <div class="location-term">{{ucfirst(str_replace("-", " ", $region->name))}}</div>
      </div>
    </a>
  </div>  
@endforeach
公共函数getBycountryCategory($country,$category)
{
$category=TourCategory::where('slug',$category)->first();
$country=country::其中('name','=',$country)->first();
$tours=$country->tours()->with('region')->get(['region_id']);
$regions=$tours->pull('region')->unique();
返回视图(“public.pages.region列表”)
->withRegions($regions)
->withCategory($category)
->withCountry($国家);
}
@foreach($regions作为$region)
@endforeach
上面的代码在我的本地机器上运行得很好,但在live server中,它返回了一条错误消息,
试图获取非对象
的属性“image”或我想从
$region
获取的任何内容。当我转储并死亡$region变量时,它会显示该变量的所有属性


我唯一不能理解的是,代码在本地开发服务器中没有给出任何错误,但在生产服务器中给出了错误。

您好,您能检查一下这是否有效吗$regions=$tours->pull('region')->unique()->first()@ashish我发现了错误。集合中的null是导致错误的原因。