Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action App\Http\Controllers\Controller@action not defined

I want to submit a form, but I always get Action App\Http\Controllers\About@show not defined even though the function show is defined:

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;


class AboutController extends Controller
{
    public function create()
    {
        return view('about.contact');
    }

    public function show()
    {
        return view('about.contactshow');
    }

}

This is my blade template about\contact.blade.php:

{!! Form::open(array('action' => 'About@show', 'method' => 'post')) !!}

    {!! Form::label('username','Username',array('id'=>'user','class'=>'')) !!}
    {!! Form::text('username','user 1',array('id'=>'user','class'=>'', 'placeholder' => 'user 1')) !!}

    {!! Form::submit('Click Me!') !!}


{!! Form::close() !!}

What am I doing wrong?

like image 310
Black Avatar asked Dec 14 '22 00:12

Black


2 Answers

I was able to solve it. First I had to change 'action' => 'About@show' to 'action' => 'AboutController@show'

Then I had to register all Controller Actions in routes.php:

Route::post('contact_show', [
    'uses' => 'AboutController@show'
  ]);

Route::get('contact_create', [
    'uses' => 'AboutController@create'
  ]);
like image 65
Black Avatar answered Feb 20 '23 04:02

Black


That's all, because of routes file web.php . Plz check out you routes file

like image 36
Mr CaT Avatar answered Feb 20 '23 03:02

Mr CaT