Symfony \组件\ HttpKernel \异常\ HttpException没有消息Laravel 5.6

时间:2018-09-02 05:36:26

标签: php laravel laravel-5 error-handling httpexception

最初的问题是,当我使用quickadminpanel.com(Laravel管理员构建器面板)创建应用程序时,在那里出现了两个菜单,即文档菜单和能力菜单。然后,我像往常一样在屏幕上下载并安装。稍后,我想添加一个新菜单,即训练菜单。因此,我在手动编码中添加了培训菜单。但是,当培训结束后,将无法访问培训菜单。还有一个Symfony \ Component \ HttpKernel \ Exception \ HttpException error appears No message

如何处理Laravel 5.6中的此错误。我创建了新方法,但是我无法从浏览器访问此菜单。请帮助我解决此错误。有关详细信息,请单击此图像。

Image Error HttpException

Image Error 401 Unauthorized

Image return abort(401)

DaftarTrainingsController.php     

namespace App\Http\Controllers\Admin;

use App\DaftarTraining;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\StoreDaftarTrainingsRequest;
use App\Http\Requests\Admin\UpdateDaftarTrainingsRequest;
use Yajra\DataTables\DataTables;

class DaftarTrainingsController extends Controller
{
    /**
     * Display a listing of DaftarTraining.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        if (! Gate::allows('daftar_training_access')) {
            return abort(401);
        }



        if (request()->ajax()) {
            $query = DaftarTraining::query();
            $query->with("kategori_training");
            $template = 'actionsTemplate';
            if(request('show_deleted') == 1) {

        if (! Gate::allows('daftar_training_delete')) {
            return abort(401);
        }
                $query->onlyTrashed();
                $template = 'restoreTemplate';
            }
            $query->select([
                'daftar_trainings.id',
                'daftar_trainings.judul_acara_training',
                'daftar_trainings.kategori_training_id',
                'daftar_trainings.pemateri',
                'daftar_trainings.tanggal_mulai_pelaksanaan',
                'daftar_trainings.tanggal_akhir_pelaksanaan',
                'daftar_trainings.jumla_peserta',
                'daftar_trainings.alamat_training',
            ]);
            $table = Datatables::of($query);

            $table->setRowAttr([
                'data-entry-id' => '{{$id}}',
            ]);
            $table->addColumn('massDelete', ' ');
            $table->addColumn('actions', ' ');
            $table->editColumn('actions', function ($row) use ($template) {
                $gateKey  = 'daftar_training_';
                $routeKey = 'admin.daftar_trainings';

                return view($template, compact('row', 'gateKey', 'routeKey'));
            });
            $table->editColumn('judul_acara_training', function ($row) {
                return $row->judul_acara_training ? $row->judul_acara_training : '';
            });
            $table->editColumn('kategori_training.nama_training', function ($row) {
                return $row->kategori_training ? $row->kategori_training->nama_training : '';
            });
            $table->editColumn('pemateri', function ($row) {
                return $row->pemateri ? $row->pemateri : '';
            });
            $table->editColumn('tanggal_mulai_pelaksanaan', function ($row) {
                return $row->tanggal_mulai_pelaksanaan ? $row->tanggal_mulai_pelaksanaan : '';
            });
            $table->editColumn('tanggal_akhir_pelaksanaan', function ($row) {
                return $row->tanggal_akhir_pelaksanaan ? $row->tanggal_akhir_pelaksanaan : '';
            });
            $table->editColumn('jumla_peserta', function ($row) {
                return $row->jumla_peserta ? $row->jumla_peserta : '';
            });
            $table->editColumn('alamat_training', function ($row) {
                return $row->alamat_training ? $row->alamat_training : '';
            });

            $table->rawColumns(['actions','massDelete']);

            return $table->make(true);
        }

        return view('admin.daftar_trainings.index');
    }

    /**
     * Show the form for creating new DaftarTraining.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        if (! Gate::allows('daftar_training_create')) {
            return abort(401);
        }

        $kategori_trainings = \App\KategoriTraining::get()->pluck('nama_training', 'id')->prepend(trans('quickadmin.qa_please_select'), '');

        return view('admin.daftar_trainings.create', compact('kategori_trainings'));
    }

    /**
     * Store a newly created DaftarTraining in storage.
     *
     * @param  \App\Http\Requests\StoreDaftarTrainingsRequest  $request
     * @return \Illuminate\Http\Response
     */
    public function store(StoreDaftarTrainingsRequest $request)
    {
        if (! Gate::allows('daftar_training_create')) {
            return abort(401);
        }
        $daftar_training = DaftarTraining::create($request->all());



        return redirect()->route('admin.daftar_trainings.index');
    }


    /**
     * Show the form for editing DaftarTraining.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        if (! Gate::allows('daftar_training_edit')) {
            return abort(401);
        }

        $kategori_trainings = \App\KategoriTraining::get()->pluck('nama_training', 'id')->prepend(trans('quickadmin.qa_please_select'), '');

        $daftar_training = DaftarTraining::findOrFail($id);

        return view('admin.daftar_trainings.edit', compact('daftar_training', 'kategori_trainings'));
    }

    /**
     * Update DaftarTraining in storage.
     *
     * @param  \App\Http\Requests\UpdateDaftarTrainingsRequest  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(UpdateDaftarTrainingsRequest $request, $id)
    {
        if (! Gate::allows('daftar_training_edit')) {
            return abort(401);
        }
        $daftar_training = DaftarTraining::findOrFail($id);
        $daftar_training->update($request->all());



        return redirect()->route('admin.daftar_trainings.index');
    }


    /**
     * Display DaftarTraining.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        if (! Gate::allows('daftar_training_view')) {
            return abort(401);
        }
        $daftar_training = DaftarTraining::findOrFail($id);

        return view('admin.daftar_trainings.show', compact('daftar_training'));
    }


    /**
     * Remove DaftarTraining from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        if (! Gate::allows('daftar_training_delete')) {
            return abort(401);
        }
        $daftar_training = DaftarTraining::findOrFail($id);
        $daftar_training->delete();

        return redirect()->route('admin.daftar_trainings.index');
    }

    /**
     * Delete all selected DaftarTraining at once.
     *
     * @param Request $request
     */
    public function massDestroy(Request $request)
    {
        if (! Gate::allows('daftar_training_delete')) {
            return abort(401);
        }
        if ($request->input('ids')) {
            $entries = DaftarTraining::whereIn('id', $request->input('ids'))->get();

            foreach ($entries as $entry) {
                $entry->delete();
            }
        }
    }


    /**
     * Restore DaftarTraining from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function restore($id)
    {
        if (! Gate::allows('daftar_training_delete')) {
            return abort(401);
        }
        $daftar_training = DaftarTraining::onlyTrashed()->findOrFail($id);
        $daftar_training->restore();

        return redirect()->route('admin.daftar_trainings.index');
    }

    /**
     * Permanently delete DaftarTraining from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function perma_del($id)
    {
        if (! Gate::allows('daftar_training_delete')) {
            return abort(401);
        }
        $daftar_training = DaftarTraining::onlyTrashed()->findOrFail($id);
        $daftar_training->forceDelete();

        return redirect()->route('admin.daftar_trainings.index');
    }
}

web.php

<?php
    Route::get('/', function () { return redirect('/admin/home'); });

    // Authentication Routes...
    $this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
    $this->post('login', 'Auth\LoginController@login')->name('auth.login');
    $this->post('logout', 'Auth\LoginController@logout')->name('auth.logout');

    // Change Password Routes...
    $this->get('change_password', 'Auth\ChangePasswordController@showChangePasswordForm')->name('auth.change_password');
    $this->patch('change_password', 'Auth\ChangePasswordController@changePassword')->name('auth.change_password');

    // Password Reset Routes...
    $this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('auth.password.reset');
    $this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('auth.password.reset');
    $this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
    $this->post('password/reset', 'Auth\ResetPasswordController@reset')->name('auth.password.reset');

    Route::group(['middleware' => ['auth'], 'prefix' => 'admin', 'as' => 'admin.'], function () {
    Route::get('/home', 'HomeController@index');

    Route::resource('daftar_dokumens', 'Admin\DaftarDokumensController');
    Route::post('daftar_dokumens_mass_destroy', ['uses' => 'Admin\DaftarDokumensController@massDestroy', 'as' => 'daftar_dokumens.mass_destroy']);
    Route::post('daftar_dokumens_restore/{id}', ['uses' => 'Admin\DaftarDokumensController@restore', 'as' => 'daftar_dokumens.restore']);
    Route::delete('daftar_dokumens_perma_del/{id}', ['uses' => 'Admin\DaftarDokumensController@perma_del', 'as' => 'daftar_dokumens.perma_del']);
    Route::resource('kategori_dokumens', 'Admin\KategoriDokumensController');
    Route::post('kategori_dokumens_mass_destroy', ['uses' => 'Admin\KategoriDokumensController@massDestroy', 'as' => 'kategori_dokumens.mass_destroy']);
    Route::post('kategori_dokumens_restore/{id}', ['uses' => 'Admin\KategoriDokumensController@restore', 'as' => 'kategori_dokumens.restore']);
    Route::delete('kategori_dokumens_perma_del/{id}', ['uses' => 'Admin\KategoriDokumensController@perma_del', 'as' => 'kategori_dokumens.perma_del']);
    Route::resource('roles', 'Admin\RolesController');
    Route::post('roles_mass_destroy', ['uses' => 'Admin\RolesController@massDestroy', 'as' => 'roles.mass_destroy']);
    Route::resource('users', 'Admin\UsersController');
    Route::post('users_mass_destroy', ['uses' => 'Admin\UsersController@massDestroy', 'as' => 'users.mass_destroy']);
    Route::resource('basis_kompetensis', 'Admin\BasisKompetensisController');
    Route::post('basis_kompetensis_mass_destroy', ['uses' => 'Admin\BasisKompetensisController@massDestroy', 'as' => 'basis_kompetensis.mass_destroy']);
    Route::post('basis_kompetensis_restore/{id}', ['uses' => 'Admin\BasisKompetensisController@restore', 'as' => 'basis_kompetensis.restore']);
    Route::delete('basis_kompetensis_perma_del/{id}', ['uses' => 'Admin\BasisKompetensisController@perma_del', 'as' => 'basis_kompetensis.perma_del']);
    Route::resource('kategori_trainings', 'Admin\KategoriTrainingsController');
    Route::post('kategori_trainings_mass_destroy', ['uses' => 'Admin\KategoriTrainingsController@massDestroy', 'as' => 'kategori_trainings.mass_destroy']);
    Route::post('kategori_trainings_restore/{id}', ['uses' => 'Admin\KategoriTrainingsController@restore', 'as' => 'kategori_trainings.restore']);
    Route::delete('kategori_trainings_perma_del/{id}', ['uses' => 'Admin\KategoriTrainingsController@perma_del', 'as' => 'kategori_trainings.perma_del']);
    Route::resource('daftar_trainings', 'Admin\DaftarTrainingsController');
    Route::post('daftar_trainings_mass_destroy', ['uses' => 'Admin\DaftarTrainingsController@massDestroy', 'as' => 'daftar_trainings.mass_destroy']);
    Route::post('daftar_trainings_restore/{id}', ['uses' => 'Admin\DaftarTrainingsController@restore', 'as' => 'daftar_trainings.restore']);
    Route::delete('daftar_trainings_perma_del/{id}', ['uses' => 'Admin\DaftarTrainingsController@perma_del', 'as' => 'daftar_trainings.perma_del']);




    });

0 个答案:

没有答案