【发布时间】:2017-02-27 03:15:16
【问题描述】:
您好,我是 Laravel 新手,正在使用 Laravel 5 进行我的第一个项目。当我将数据从控制器传递到视图时,我收到此错误。我被困在最后三天。我已经检查了来自在线博客的所有问题,甚至是 stackoverflow,但找不到解决方案,请帮忙。这是我的代码:
App\Routes\web.php
Route::get('/list', 'CustomerController@list');
App\Http\Controllers\CustomerController.php
public function list(){
$first = 'Mian';
$last = 'Amir';
$fullName = $first . " " . $last;
//dd($fullName);
return view('new')->with("fullName", $fullName);
//return view('new')->withFullName($fullName);
}
Resources\Views\new.blade.php
@extends('master')
@section('content')
<h1>New Content Will Goes Here: {{$fullName}}</h1>
@endsection
我也试过这些:
//return view('new')->with('customer', $customers);
//return View::make('new')->with(array('customers' => $customers));
// return View::make('new', compact('customers'));
/$customers = DB::table('customers')->get();
//return view('new', ['customers' => $customers]);
//return View::make('new', compact('customers'));
//return View::make('new')->with('customers', $customers);
//dd($customers);
//return View::make('new')->with(array('customers' => , $customers));
//$customers = Customer::all();
//dd($customers);
//return View::make('view')->with('customers', $customers);
//return View::make('view', compact('customers'));
//return $view->with('customers', $customers)->with('q', $q);
//return view('view', ['key' => 'The big brown fox jumped over the lazdog']);
//$key = 'If a would chuck can chuck wood,';
//return view('view', compact('key'));
这是错误页面:
【问题讨论】:
-
从您的问题中我看不到您正在设置的错误。请使用错误消息扩展您的问题。
-
在你发布的代码中,是你刚刚发布的那些不同的文件在一起,还是你的控制器和视图在同一个文件中?