douyouzheng2209 2016-04-19 18:14
浏览 88
已采纳

laravel - 在调用视图时生成的空白页

I have the following routes:

       <?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'PagesController@index');
Route::get('item', 'ItemController@index');
Route::get('item/create', 'ItemController@create');
Route::get('item/{id}', 'ItemController@show');

Route::get('welcome', function() {
    return view('welcome');
});
Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/home', 'HomeController@index');
});

And this is what my Item controller looks like:

@section('content');
<h1>Add a  new item</h1>
<hr />
<content>
    <div class="form-group">
    {!! Form::open() !!}
        {!! Form::label('name', "Name") !!}
        {!! Form::text('name', null, ['class' => 'form-control']) !!}
    {!! Form::close() !!}
</content>

@stopttp\Requests;

use App\Item;
class ItemController extends Controller
{
public function index()
{
    //fetch all items from the database
    $items = Item::All();
    return $items;
}

public function show($id) {

    $item = Item::FindOrFail($id);
}

public function create() {
    return view::make('item.create');
}

}

create.blade.phpHere is my view located at /resources/views/item/create.blade.php: @section('content');

Add a new item


{!! Form::open() !!} {!! Form::label('name', "Name") !!} {!! Form::text('name', null, ['class' => 'form-control']) !!} {!! Form::close() !!} @stop

I am trying to load a item creation method for this laravel based e-commerce I am building. I can't seem to access the item.create view when I visit the route in the specified page, just a blank page when I load the view; I do not see the view's HTML. Any help, please?

Heres a copoy of my log files:

[2016-04-19 17:44:41] local.ERROR: exception 'InvalidArgumentException' with message 'View [articles.create] not found.' in /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php:137 Stack trace:

0 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php(79): Illuminate\View\FileViewFinder->findInPaths('articles.create', Array)

1 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/View/Factory.php(165): Illuminate\View\FileViewFinder->find('articles.create')

2 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(783): Illuminate\View\Factory->make('articles.create', Array, Array)

3 /home/thomas/ushop/app/Http/Controllers/ItemController.php(25): view('articles.create')

4 [internal function]: App\Http\Controllers\ItemController->create()

5 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(80): call_user_func_array(Array, Array)

6 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(146): Illuminate\Routing\Controller->callAction('create', Array)

7 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(94): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\ItemController), Object(Illuminate\Routing\Route), 'create')

8 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

9 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

10 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

11 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

12 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(96): Illuminate\Pipeline\Pipeline->then(Object(Closure))

13 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(54): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\ItemController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'create')

14 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Route.php(174): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\Http\Contro...', 'create')

15 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Route.php(140): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))

16 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(724): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))

17 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

18 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

19 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

20 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

21 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\Pipeline\Pipeline->then(Object(Closure))

22 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(699): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))

23 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))

24 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(246): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))

25 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))

26 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

27 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

28 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))

29 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)

30 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

31 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

32 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

33 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

34 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))

35 /home/thomas/ushop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))

36 /home/thomas/ushop/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))

37 {main}

  • 写回答

3条回答 默认 最新

  • duanjiao7440 2016-04-19 18:59
    关注
    1. You said return view::make('item.create');, it should be return View::make('item.create'); or return view('item.create');

    2. Logs and code are saying different things. Logs talk about a View [articles.create] not found, your code talks about a item.create View. Are you sure you pointing to the correct route <=> controller ? Maybe try to clear cache

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?