Я пытаюсь открыть страницу / messages, на которой отображается таблица, связанная с некоторыми методами / представлениями CRUD, но я получаю сообщение об ошибке «Не найдено». Я прикрепил снимок экрана своей mysql страницы, на котором показаны данные, которые я пытаюсь выполнить. для экономии я чувствую, что я неправильно сделал контроллер и получаю сообщение об ошибке. Однако, когда я вставляю полностью рабочий, я все равно получаю не найденное представление. внутри моей сети. php:
Route::group(['middleware' => ['auth', 'web', 'role:admin'], 'namespace' => '\App\Http\Controllers'], function () {
Route::resource('messages', 'MessagesController', [
'names' => [
'index' => 'messages',
'destroy' => 'message.destroy',
],
]);
Route::post('search-messages', '\App\Http\Controllers\MessagesController@search')->name('search-messages');
мое представление находится внутри resources / views / messages.blade. php и все мои представления выглядят в порядке, вот мой контроллер:
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Validator;
class MessagesController extends Controller
{
private $_authEnabled;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->_authEnabled = config('laravelmessages.authEnabled');
if ($this->_authEnabled) {
$this->middleware('auth');
}
}
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$pagintaionEnabled = config('laravelmessages.enablePagination');
if ($pagintaionEnabled) {
$messages = config('laravelmessages.defaultmessageModel')::paginate(config('laravelmessages.paginateListSize'));
} else {
$messages = config('laravelmessages.defaultmessageModel')::all();
}
$data = [
'messages' => $messages,
'pagintaionEnabled' => $pagintaionEnabled,
];
return view(config('laravelmessages.showmessagesBlade'), $data);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
return view(config('laravelmessages.createmessageBlade'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return Response
*/
public function store(Request $request)
{
$messages = [
'direction.required' => trans('laravelmessages::laravelmessages.messages.messageDirectionRequired'),
'account_id.required' => 'account_id is required',
'recipient_id.required' => trans('laravelmessages::laravelmessages.messages.recipient_idRequired'),
'content_id.email' => trans('laravelmessages::laravelmessages.messages.content_idInvalid'),
'source_id.required' => trans('laravelmessages::laravelmessages.messages.source_idRequired'),
];
$validator = Validator::make($request->all(), $messages);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput();
}
$message = config('laravelmessages.defaultmessageModel')::create([
'account_id' => $request->input('account_id'),
'recipient_id' => $request->input('recipient_id'),
'content_id' => $request->input('content_id'),
'source_id' => bcrypt($request->input('source_id')),
]);
return redirect('messages')->with('success', trans('laravelmessages::laravelmessages.messages.message-creation-success'));
}
/**
* Display the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show($id)
{
$message = config('laravelmessages.defaultmessageModel')::find($id);
return view(config('laravelmessages.showIndividualmessageBlade'))->withmessage($message);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
{
$message = config('laravelmessages.defaultmessageModel')::findOrFail($id);
$data = [
'message' => $message,
];
return view(config('laravelmessages.editIndividualmessageBlade'))->with($data);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return Response
*/
public function update(Request $request, $id)
{
$message = config('laravelmessages.defaultmessageModel')::find($id);
$validator = Validator::make($request->all());
if ($validator->fails()) {
return back()->withErrors($validator)->withInput();
}
$message->save();
return back()->with('success', trans('laravelmessages::laravelmessages.messages.update-message-success'));
}
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
{
$currentmessage = Auth::message();
$message = config('laravelmessages.defaultmessageModel')::findOrFail($id);
if ($currentmessage->id != $message->id) {
$message->delete();
return redirect('messages')->with('success', trans('laravelmessages::laravelmessages.messages.delete-success'));
}
return back()->with('error', trans('laravelmessages::laravelmessages.messages.cannot-delete-yourself'));
}
/**
* Method to search the messages.
*
* @param Request $request
*
* @return Response
*/
public function search(Request $request)
{
$searchTerm = $request->input('message_search_box');
$searchRules = [
'message_search_box' => 'required|string|max:255',
];
$searchMessages = [
'message_search_box.required' => 'Search term is required',
'message_search_box.string' => 'Search term has invalid characters',
'message_search_box.max' => 'Search term has too many characters - 255 allowed',
];
$validator = Validator::make($request->all(), $searchRules, $searchMessages);
if ($validator->fails()) {
return response()->json([
json_encode($validator),
], Response::HTTP_UNPROCESSABLE_ENTITY);
}
$results = config('laravelmessages.defaultmessageModel')::where('id', 'like', $searchTerm . '%')
->orWhere('account_id', 'like', $searchTerm . '%')
->orWhere('content_id', 'like', $searchTerm . '%')
->orWhere('status_id', 'like', $searchTerm . '%')->get();
return response()->json([
json_encode($results),
], Response::HTTP_OK);
}
}
laravelmessages. php внутри моего файла конфигурации:
<?php
return [
/*
|--------------------------------------------------------------------------
| Laravel-messages setting
|--------------------------------------------------------------------------
*/
// The parent blade file
'laravelmessagesBladeExtended' => 'adminlte::page', //'laravelmessages::layouts.app', // 'layouts.app'
// Enable `auth` middleware
'authEnabled' => true,
// Enable Optional Roles Middleware on the messages assignments
'rolesEnabled' => true,
/*
| Enable Roles Middlware on the usability of this package.
| This requires the middleware from the roles package to be registered in `App\Http\Kernel.php`
| An Example: of roles middleware entry in protected `$routeMiddleware` array would be:
| 'role' => \jeremykenedy\LaravelRoles\Middleware\VerifyRole::class,
*/
'rolesMiddlwareEnabled' => true,
// // Optional Roles Middleware
// 'rolesMiddlware' => 'role:admin',
//
// // Optional Role Model
// 'roleModel' => 'jeremykenedy\LaravelRoles\Models\Role',
// Enable Soft Deletes - Not yet setup - on the roadmap. -- Im lazy on this :P - jk
'softDeletedEnabled' => false,
// Laravel Default message Model
'defaultMessageModel' => 'App\Message',
// Use the provided blade templates or extend to your own templates.
'showmessagesBlade' => 'messagesmanagement.show-messages', //'laravelmessages::messagesmanagement.show-messages',
'createmessageBlade' => 'messagesmanagement.create-message', //'laravelmessages::messagesmanagement.create-message',
'showIndividualmessageBlade' => 'messagesmanagement.show-message', // 'laravelmessages::messagesmanagement.show-message',
'editIndividualmessageBlade' => 'messagesmanagement.edit-message', //'laravelmessages::messagesmanagement.edit-message',
// Use Package Bootstrap Flash Alerts
'enablePackageBootstapAlerts' => true,
// messages List Pagination
'enablePagination' => true,
'paginateListSize' => 25,
// Enable Search messages- Uses jQuery Ajax
'enableSearchmessages' => true,
// messages List JS DataTables - not recommended use with pagination
'enabledDatatablesJs' => false,
'datatablesJsStartCount' => 25,
'datatablesCssCDN' => 'https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css',
'datatablesJsCDN' => 'https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js',
'datatablesJsPresetCDN' => 'https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js',
// Bootstrap Tooltips
'tooltipsEnabled' => true,
'enableBootstrapPopperJsCdn' => true,
'bootstrapPopperJsCdn' => 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js',
// Icons
'fontAwesomeEnabled' => true,
'fontAwesomeCdn' => 'https://use.fontawesome.com/releases/v5.0.6/css/all.css',
// Extended blade options for packages app.blade.php
'enableBootstrapCssCdn' => true,
'bootstrapCssCdn' => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
'enableAppCss' => true,
'appCssPublicFile' => 'css/app.css',
'enableBootstrapJsCdn' => true,
'bootstrapJsCdn' => 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js',
'enableAppJs' => true,
'appJsPublicFile' => 'js/app.js',
'enablejQueryCdn' => true,
'jQueryCdn' => 'https://code.jquery.com/jquery-3.3.1.min.js',
];
Я пробовал поиграться со своим контроллером и представлениями, но, похоже, мне не повезло. Я тоже пробовал и очистка конфигурации через:
php artisan config:cache
Мы будем очень благодарны за любые предложения о том, как обойти это, все, что я могу предоставить, я с радостью сделаю :)