我将名为 index.blade.php 的视图放在template2019 / blogs中。但是,当我访问URL:http://inwrite.com/turtle/blogs时,返回了错误:View [template2019.blogs.index] not found
。 BlogListController.php 位于Controllers / Front文件夹中。 BaseController.php位于Controllers文件夹中。
我仔细检查了这些文件,并确保它们没有丢失/放错位置。
我做错了什么?
这是我提供的文件:
BlogListController.php
<?php
namespace App\Http\Controllers\Front;
use Illuminate\Http\Request;
use App\Http\Controllers\BaseController as BaseController;
class BlogListController extends BaseController
{
//
public function handle(Request $request)
{
$blog_list = \App\Models\Posts::where('page_type', 'blog')->where('status', 1)->get();
$blog_cats = \App\Models\BlogCategories::all();
$config = \App\Models\Config::get(['name','value']);
$str_to_json = "";
$config_count = count($config);
$last_config_index = $config_count-1;
foreach($config as $key => $config_item){
if($key == 0){
$str_to_json = $str_to_json."{\"".$config_item->name."\":\"".$config_item->value."\", ";
}
else if($key == $last_config_index){
$str_to_json = $str_to_json."\"".$config_item->name."\":\"".$config_item->value."\"}";
}
else{
$str_to_json = $str_to_json."\"".$config_item->name."\":\"".$config_item->value."\", ";
}
}
$json_to_array = json_decode($str_to_json, true);
$header = \App\Models\Headers::first();
$footer = \App\Models\FooterCms::first();
$viewData = [ 'title' => 'Turtl-E | Blogs',
'blog_list' => $blog_list,
'blog_cats' => $blog_cats,
'header' => $header,
'footer' => $footer,
'config' => $json_to_array ];
return view($this->getFrontViewGroup() . 'blogs.index', $viewData);
}
}
BaseController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class BaseController extends Controller
{
//
protected function beginDbTransaction()
{
\DB::beginTransaction();
}
protected function rollbackDbTransaction()
{
\DB::rollBack();
}
protected function commitDbTransaction()
{
\DB::commit();
}
protected function tryDeleteOldTokens($customerId)
{
$accountPrefix = \App\MasterSettings::getSettings('oauth', 'accountPrefix');
$key = $accountPrefix . $customerId;
$temp = \Redis::get($key);
$tokens = json_decode($temp, true);
if(is_array($tokens) === false) {
return;
}
if(isset($tokens['access_token']) === false) {
return;
}
if(isset($tokens['refresh_token']) === false) {
return;
}
$accessPrefix = \App\MasterSettings::getSettings('oauth', 'accessPrefix');
\Redis::del($accessPrefix . $tokens['access_token']);
$refreshPrefix = \App\MasterSettings::getSettings('oauth', 'refreshPrefix');
\Redis::del($refreshPrefix . $tokens['refresh_token']);
}
protected function trySaveOldTokens($customerId, $accessToken, $refreshToken)
{
$data = [
'access_token' => $accessToken,
'refresh_token' => $refreshToken,
];
# save the tokens in a key with account number
$accountPrefix = \App\MasterSettings::getSettings('oauth', 'accountPrefix');
$key = $accountPrefix . $customerId;
\Redis::set($key, json_encode($data));
# lasts slightly longer than refresh token
$expiry = \App\MasterSettings::getSettings('oauth', 'refreshExpiry') + 10;
\Redis::expire($key, $expiry);
}
protected $logName = '';
protected $code = null;
protected $token = '';
protected function saveTokenForLog($request)
{
$temp = $request->header('authorization');
$token = str_replace('Bearer ', '', $temp);
$this->token = md5($token);
}
protected function logSomething($message)
{
if($this->code === null)
$this->code = str_random(5);
$logName = $this->logName;
$code = $this->code;
$token = $this->token;
\Log::info("$code --- $logName --- $token $message");
}
protected function getDashboardViewGroup()
{
return 'dashboard2019.';
}
protected function getFrontViewGroup()
{
return 'template2019.';
}
}
web.php(路由)
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
/*Route::get('/', function () {
return view('welcome');
});*/
// prevents unauthorized access
$c = [ \App\Http\Middleware\WebAuthMiddleware::class ];
/*ERROR PAGE*/
Route::get( '/error', 'ErrorController@handle');
/*FRONT*/
Route::get( '/', 'Front\FrontController@handle');
Route::get( '/blogs', 'Front\BlogListController@handle');
/*ADMIN*/
Route::get( 'admin/login', 'Dashboard\DashboardLoginController@handle');
Route::post( 'admin/login', 'Dashboard\DashboardLoginPostController@handle');
Route::get( 'admin/logout', 'Dashboard\DashboardLogoutController@handle');
Route::get( '/admin', 'Dashboard\DashboardController@handle')->middleware($c);
Route::get( '/admin/orders', 'Dashboard\OrdersController@handle')->middleware($c);
Route::get( '/admin/customers', 'Dashboard\CustomersController@handle')->middleware($c);
Route::get( '/admin/administrators', 'Dashboard\AdministratorsController@handle')->middleware($c);
Route::post( '/admin/administrators/list', 'Dashboard\AdministratorsListController@handle')->middleware($c);
Route::post( '/admin/administrators/save', 'Dashboard\AdministratorsSaveController@handle')->middleware($c);
Route::post( '/admin/administrators/edit', 'Dashboard\AdministratorsEditController@handle')->middleware($c);
Route::post( '/admin/administrators/delete-many', 'Dashboard\AdministratorsDeleteManyController@handle')->middleware($c);
Route::get( '/admin/services', 'Dashboard\ServicesController@handle')->middleware($c);
Route::post( '/admin/services/list', 'Dashboard\ServicesListController@handle')->middleware($c);
Route::post( '/admin/services/save', 'Dashboard\ServicesSaveController@handle')->middleware($c);
Route::post( '/admin/services/edit', 'Dashboard\ServicesEditController@handle')->middleware($c);
Route::post( '/admin/services/delete-many', 'Dashboard\ServicesDeleteManyController@handle')->middleware($c);
Route::get( '/admin/operations/business-hours', 'Dashboard\OperationsBusinessHoursController@handle')->middleware($c);
Route::post( '/admin/operations/business-hours/list', 'Dashboard\OperationsBusinessHoursListController@handle')->middleware($c);
Route::post( '/admin/operations/business-hours/save', 'Dashboard\OperationsBusinessHoursSaveController@handle')->middleware($c);
Route::post( '/admin/operations/business-hours/edit', 'Dashboard\OperationsBusinessHoursEditController@handle')->middleware($c);
Route::post( '/admin/operations/business-hours/delete-many', 'Dashboard\OperationsBusinessHoursDeleteManyController@handle')->middleware($c);
Route::get( '/admin/operations/dayoffs', 'Dashboard\OperationsDayoffsController@handle')->middleware($c);
Route::post( '/admin/operations/dayoffs/list', 'Dashboard\OperationsDayoffsListController@handle')->middleware($c);
Route::post( '/admin/operations/dayoffs/save', 'Dashboard\OperationsDayoffsSaveController@handle')->middleware($c);
Route::post( '/admin/operations/dayoffs/edit', 'Dashboard\OperationsDayoffsEditController@handle')->middleware($c);
Route::post( '/admin/operations/dayoffs/delete-many', 'Dashboard\OperationsDayoffsDeleteManyController@handle')->middleware($c);
Route::get( '/admin/operations/holidays', 'Dashboard\OperationsHolidaysController@handle')->middleware($c);
Route::post( '/admin/operations/holidays/list', 'Dashboard\OperationsHolidaysListController@handle')->middleware($c);
Route::post( '/admin/operations/holidays/save', 'Dashboard\OperationsHolidaysSaveController@handle')->middleware($c);
Route::post( '/admin/operations/holidays/edit', 'Dashboard\OperationsHolidaysEditController@handle')->middleware($c);
Route::post( '/admin/operations/holidays/delete-many', 'Dashboard\OperationsHolidaysDeleteManyController@handle')->middleware($c);
Route::get( '/admin/products', 'Dashboard\ProductsController@handle')->middleware($c);
Route::post( '/admin/products/list', 'Dashboard\ProductsListController@handle')->middleware($c);
Route::post( '/admin/products/save', 'Dashboard\ProductsSaveController@handle')->middleware($c);
Route::post( '/admin/products/edit', 'Dashboard\ProductsEditController@handle')->middleware($c);
Route::post( '/admin/products/delete-many', 'Dashboard\ProductsDeleteManyController@handle')->middleware($c);
Route::get( '/admin/file-types', 'Dashboard\FileTypesController@handle')->middleware($c);
Route::post( '/admin/file-types/list', 'Dashboard\FileTypesListController@handle')->middleware($c);
Route::post( '/admin/file-types/save', 'Dashboard\FileTypesSaveController@handle')->middleware($c);
Route::post( '/admin/file-types/edit', 'Dashboard\FileTypesEditController@handle')->middleware($c);
Route::post( '/admin/file-types/delete-many', 'Dashboard\FileTypesDeleteManyController@handle')->middleware($c);
Route::get( '/admin/messages', 'Dashboard\MessagesController@handle')->middleware($c);
Route::get( '/admin/configurations', 'Dashboard\ConfigurationsController@handle')->middleware($c);
Route::post( '/admin/configurations/list', 'Dashboard\ConfigurationsListController@handle')->middleware($c);
Route::post( '/admin/configurations/save', 'Dashboard\ConfigurationsSaveController@handle')->middleware($c);
Route::post( '/admin/configurations/edit', 'Dashboard\ConfigurationsEditController@handle')->middleware($c);
Route::post( '/admin/configurations/delete-many', 'Dashboard\ConfigurationsDeleteManyController@handle')->middleware($c);
Route::get( '/admin/cms/header', 'Dashboard\CmsNavbarsController@handle')->middleware($c);
Route::post( '/admin/cms/header/list', 'Dashboard\CmsNavbarsListController@handle')->middleware($c);
Route::post( '/admin/cms/header/save', 'Dashboard\CmsNavbarsSaveController@handle')->middleware($c);
Route::get( '/admin/cms/footer', 'Dashboard\CmsFootersController@handle')->middleware($c);
Route::post( '/admin/cms/footer/list', 'Dashboard\CmsFootersListController@handle')->middleware($c);
Route::post( '/admin/cms/footer/save', 'Dashboard\CmsFootersSaveController@handle')->middleware($c);
Route::post( '/admin/cms/footer/edit', 'Dashboard\CmsFootersEditController@handle')->middleware($c);
Route::post( '/admin/cms/footer/delete-many', 'Dashboard\CmsFootersDeleteManyController@handle')->middleware($c);
Route::get( '/admin/cms/sections', 'Dashboard\CmsSectionsController@handle')->middleware($c);
Route::post( '/admin/cms/sections/list', 'Dashboard\CmsSectionsListController@handle')->middleware($c);
Route::post( '/admin/cms/sections/save', 'Dashboard\CmsSectionsSaveController@handle')->middleware($c);
Route::post( '/admin/cms/sections/edit', 'Dashboard\CmsSectionsEditController@handle')->middleware($c);
Route::post( '/admin/cms/sections/delete-many', 'Dashboard\CmsSectionsDeleteManyController@handle')->middleware($c);
Route::post( '/admin/cms/sections/sort', 'Dashboard\CmsSectionsSortController@handle')->middleware($c);
Route::get( '/admin/cms/testimonials', 'Dashboard\CmsTestimonialsController@handle')->middleware($c);
Route::post( '/admin/cms/testimonials/list', 'Dashboard\CmsTestimonialsListController@handle')->middleware($c);
Route::post( '/admin/cms/testimonials/save', 'Dashboard\CmsTestimonialsSaveController@handle')->middleware($c);
Route::post( '/admin/cms/testimonials/edit', 'Dashboard\CmsTestimonialsEditController@handle')->middleware($c);
Route::post( '/admin/cms/testimonials/delete-many', 'Dashboard\CmsTestimonialsDeleteManyController@handle')->middleware($c);
Route::post( '/admin/cms/testimonials/sort', 'Dashboard\CmsTestimonialsSortController@handle')->middleware($c);
Route::get( '/admin/cms/faqs', 'Dashboard\CmsFaqsController@handle')->middleware($c);
Route::post( '/admin/cms/faqs/list', 'Dashboard\CmsFaqsListController@handle')->middleware($c);
Route::post( '/admin/cms/faqs/save', 'Dashboard\CmsFaqsSaveController@handle')->middleware($c);
Route::post( '/admin/cms/faqs/edit', 'Dashboard\CmsFaqsEditController@handle')->middleware($c);
Route::post( '/admin/cms/faqs/delete-many', 'Dashboard\CmsFaqsDeleteManyController@handle')->middleware($c);
Route::post( '/admin/cms/faqs/sort', 'Dashboard\CmsFaqsSortController@handle')->middleware($c);
Route::get( '/admin/cms/top-sliders', 'Dashboard\CmsTopSlidersController@handle')->middleware($c);
Route::post( '/admin/cms/top-sliders/list', 'Dashboard\CmsTopSlidersListController@handle')->middleware($c);
Route::post( '/admin/cms/top-sliders/save', 'Dashboard\CmsTopSlidersSaveController@handle')->middleware($c);
Route::post( '/admin/cms/top-sliders/edit', 'Dashboard\CmsTopSlidersEditController@handle')->middleware($c);
Route::post( '/admin/cms/top-sliders/delete-many', 'Dashboard\CmsTopSlidersDeleteManyController@handle')->middleware($c);
Route::post( '/admin/cms/top-sliders/sort', 'Dashboard\CmsTopSlidersSortController@handle')->middleware($c);
Route::get( '/admin/cms/external-pages', 'Dashboard\CmsExternalPagesController@handle')->middleware($c);
Route::post( '/admin/cms/external-pages/list', 'Dashboard\CmsExternalPagesListController@handle')->middleware($c);
Route::post( '/admin/cms/external-pages/save', 'Dashboard\CmsExternalPagesSaveController@handle')->middleware($c);
Route::post( '/admin/cms/external-pages/edit', 'Dashboard\CmsExternalPagesEditController@handle')->middleware($c);
Route::post( '/admin/cms/external-pages/delete-many', 'Dashboard\CmsExternalPagesDeleteManyController@handle')->middleware($c);
Route::post( '/admin/cms/external-pages/get-category', 'Dashboard\CmsExternalPagesGetCategoryController@handle')->middleware($c);
Route::get( '/admin/cms/categories', 'Dashboard\CmsCategoriesController@handle')->middleware($c);
Route::post( '/admin/cms/categories/list', 'Dashboard\CmsCategoriesListController@handle')->middleware($c);
Route::post( '/admin/cms/categories/save', 'Dashboard\CmsCategoriesSaveController@handle')->middleware($c);
Route::post( '/admin/cms/categories/edit', 'Dashboard\CmsCategoriesEditController@handle')->middleware($c);
Route::post( '/admin/cms/categories/delete-many', 'Dashboard\CmsCategoriesDeleteManyController@handle')->middleware($c);
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
index.blade.php (位于views / template2019 / blogs文件夹中)
<!DOCTYPE html>
<html>
@include('template2019.layouts.meta')
<body>
@include('template2019.layouts.header')
@include('template2019.layouts.footer_default')
</body>
</html>