9 months ago

Not working show function in Laravel 5.7

Posted 9 months ago by Msoft

I have table studentcource and store students cource data using studentcourceController store function here

public function store(Request $request)
        $studentcource = New Studentcource;
        $studentcource->name = $request->input('name');
        $studentcource->address = $request->input('address');
        $studentcource->telephone = $request->input('telephone');
        $studentcource->cource = $request->input('cource');
        return redirect()->route('studentcourcedata');

data storing is working fine. but I need redirect to studentcourcedata.blade.php after storing the data. show function is here in same controller,

public function show($id)
        $studentcources = Studentcource::find($id);
        return view('studentcourcedata')->WithStudentcources($studentcources);

and studentcourcedata.blade.php is like this

<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">Student Cource Data</div>

                <div class="card-body">
                    <table class="table">

                      @foreach ($studentcources as $studentcource)



and my route is

Route::get('studentcourcedata','[email protected]')->name('studentcourcedata');

but I got following error here

Too few arguments to function App\Http\Controllers\StudentcourceController::show(), 0 passed and exactly 1 expected

how can I fix this problem?

Please sign in or create an account to participate in this conversation.