从laravel中的DB中检索

时间:2017-07-23 17:30:55

标签: laravel-5

我正在尝试使用laravel框架从localhost数据库中检索一个列,我收到此错误:

  

cd582248476d4ab73365f604ce058f390fc48144.php行中的ErrorException   10:未定义的变量:交付(查看:   C:\ XAMPP \ htdocs中\ testt \资源\视图\ Delivered.blade.php)

  @extends('layouts.master')

@section('title')
    Pharmacies
@endsection

@section('content')

<section class="row posts">
        <div class="col-md-6 col-md-offset-3">
            <header><h3>Details of Delivered Orders</h3></header>
            @foreach ($Delivery as $Delivery) {
              echo $Delivery->Address;
          }
          @endforeach
}
        </div>
    </section>
@endsection



<?php
namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Collection;

class DeliveredController extends Controller
{
    public function getDeliveredPage()
    {
      return view('Delivered');
    }
    public function index()
   {
       $Delivery = Delivery::all()->get();

       return view('Delivered' ,['Delivery'=>$Delivery]);
   }

1 个答案:

答案 0 :(得分:0)

您不需要在 Note: Increasing the size of an IDE virtual disk using the vSphere Client is not supported. SCSI virtual disks are the only supported disk that can be expanded via the vSphere Client. 后使用->get()

此外,最好为您的收藏品和物品使用不同的变量。

快速提示Blade中的部分,你可以使用它:

all()

而不是

@section('title', 'Pharmacies')

这是您更新的代码:

@section('title')
    Pharmacies
@endsection

@extends('layouts.master')

@section('title', 'Pharmacies')

@section('content')
<section class="row posts">
    <div class="col-md-6 col-md-offset-3">
        <header><h3>Details of Delivered Orders</h3></header>
        @foreach ($deliveries as $delivery)
           {{ $delivery->Address }}
        @endforeach
    </div>
</section>
@endsection