Search code examples
phplaravellaravel-5.3

How to resolve : ReflectionException in Route.php line 333: Method App\Http\Controllers\PerekamanController::show() does not exist" in Laravel 5.3?


My proses.blade.php is like this :

<form method="POST" action="{{ url('/perekamans/proses') }}">
    {!! csrf_field() !!}
    ...
</form>

My routes\web.php is like this :

Route::resource('perekamans', 'PerekamanController');

Route::get('perekamans/proses', ['uses' => 'PerekamanController@listdata']);

My PerekamanController is like this :

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PerekamanController extends Controller
{
    public function index(Request $request)
    {
        return view('perekamans.index');
    }

    public function listData()
    {
        return view('perekamans.show');
    }
}

My show.blade.php is like this :

@extends('layouts.app')

@section('content')

    <section class="content-header">
        <h1 class="pull-left">PEREKAMAN DATA</h1>
    </section>
    <div class="content">
        <div class="clearfix"></div>

        @include('flash::message')

        <div class="clearfix"></div>
        <div class="box box-primary">
            <div class="box-body">
                    @include('perekamans.table')
            </div>
        </div>
    </div>
@endsection

I call from url like this : http://localhost/mysystem/public/perekaman/proses

There exist error like this :

Whoops, looks like something went wrong. 1/1 ReflectionException in Route.php line 333: Method App\Http\Controllers\PerekamanController::show() does not exist

in Route.php line 333
at ReflectionMethod->__construct('App\Http\Controllers\PerekamanController', 'show') in Route.php line 333
at Route->signatureParameters('Illuminate\Database\Eloquent\Model') in Router.php line 789

It looks like my code is correct, but why it is still an error?

Is there any solution to solve my problem?

Update :

Sorry, I can not answer all your questions. every time I write a comment to answer questions with you, and then click the comment button, it can not. there exist message :
question eligible for bounty in 2 days
so you immediately provide any solution


Solution

  • you make mistake at your route:

    Route::get('perekamans/proses', ['uses' => 'PerekamanController@listdata']);
    
    Route::resource('perekamans', 'PerekamanController');
    

    Change the sequence become like that.

    And one more thing at Laravel you can make it simpler.

    Route::get('perekamans/proses', 'PerekamanController@listdata');
    

    you don't need to use uses to set which controller it will use