Laravel 5.1视图未找到
这似乎是一个时不时地在Laravel中出现的问题.我正在编写带有此功能的CRUD控制器,但是在测试时出现了InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not found
错误.这是我的代码:
this seems to be an issue that pops up every now and then within Laravel. I was writing a CRUD controller with a view to go with it, however upon testing I got the InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not found
error. Here is my code:
routes.php:
routes.php:
Route::resource('bookingcrud', 'BookingsCrudController');
BookingsCrudController.php
BookingsCrudController.php
use uasc\Http\Requests;
use uasc\Http\Requests\CrudCreateRequest;
use uasc\Http\Requests\CrudUpdateRequest;
use uasc\Http\Controllers\Controller;
use Auth;
use DB;
use Illuminate\Pagination\Paginator;
use Illuminate\Http\Request;
class BookingsCrudController extends Controller {
public function index()
{
if (!Auth::check() || Auth::user()->authority < 1) {
return redirect('/login');
}
$raw = "select * from bookings";
$bookings = DB::select($raw);
$paginatedBookings = new Paginator($bookings, 1);
return view('bookingcrud.index')->with('bookings', $paginatedBookings);
}
}
还有位于~/laravel/resources/views/bookingcrud/index.blade.php
的视图
无论此视图文件中的内容是工作视图中的标记,还是仅是"cheese"一词,我总会得到:
And a view located in ~/laravel/resources/views/bookingcrud/index.blade.php
No matter what is in this view file whether its markup from a working view or just the word "cheese" i will always get:
InvalidArgumentException in FileViewFinder.php line 140:
View [bookingcrud.index] not found.
我在已知的工作控制器中测试了相同的视图,并遇到了相同的错误,但是我在同一CRUD控制器中测试了已知的工作视图,并且它起作用了.我也尝试过更改视图的目录并重命名它,但是在适当更改"View [bookingcrud.index]"时会遇到相同的错误.我确保文件和目录的权限已满,可以进行测试.
I tested the same view in a known working controller and got the same error however I tested a known working view on the same CRUD controller and it worked. I have also tried changing the directory of the view and renaming it but i'll get the same error with the "View [bookingcrud.index]" changing appropriately. I made sure the permissions of the file and directories were full for testing.
自从第一次出现错误以来,我已经从5.0.26升级到5.1.1(这是错误源于我的版本),并运行了作曲家更新.另外,从查看具有相同错误的线程开始,我还运行了artisan config:clear
Since first getting the error I have upgraded to 5.1.1 from 5.0.26 (which is the version the error originated on for me) and ran composer update. Also from looking at threads with the same error I have also ran artisan config:clear
我正在使用Virtual Box部署的Homestead 2.0.17在Windows 8.1上进行开发.
I am developing on Windows 8.1 with Homestead 2.0.17 deployed with Virtual Box.
此时此刻,任何帮助都会为我带来帮助.
Any help would much appriciated at this point it is doing my head in.
原来,我拼写错误的刀片不正确,尽管第二眼却注意到了它.
Turns out I had spelt blade incorrectly, took a second pair of eyes to notice it though.
$ ls resources/views/crud/booking/
crud.balde.php index.balde.php
绝对是一堂课,在调试时总是仔细检查小事情. 感谢您的帮助.
Was definitely a lesson to always double check the small things when debugging. Thanks for the help.