Does the Form Builder know that you are using a non-conventional namespace for the route? Possibly you need:
{{ Form::open(['action' => 'Vanguard\Http\Controllers\WebCompaniesController@store']) }}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am trying to build a form using laravel. I continue to get this error... Action CompaniesController@store not defined ...
When I take out the action route on the form open I can view the page without error. Below is my code.
Routes:
Route::get('companies', 'CompaniesController@index');
Route::get('companies/create', 'CompaniesController@create');
CompaniesController
<?php
namespace Vanguard\Http\Controllers\Web;
use Vanguard\Http\Controllers\Controller;
use Vanguard\Companies;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use DB;
/**
* Class CompaniesController
* @package Vanguard\Http\Controllers
*/
class CompaniesController extends Controller
{
public function index()
{
// Fetch users from database
$companies = Companies::select('companies.*')->get();
// Uncomment the following line if you want to see the info you get from the database
// dd($users);
// Load appropriate view for displaying the users
// Note: compact('users') is the same as ['users' => $users]
return view('companies.index', compact('companies'));
}
public function store(Request $request)
{
$this-> validate($request, [
'company_name'=> 'required',
'phone'=> 'required',
'email'=> 'required'
]);
return 123;
}
public function show(){
//
}
public function create()
{
return view('companies.create');
}
}
create.blade.php
@extends('layouts.app')
@section('page-title', trans('app.dashboard'))
@section('page-heading', trans('app.dashboard'))
@section('breadcrumbs')
<li class="breadcrumb-item active">
@lang('Companies')
</li>
@stop
@section('content')
{{ Form::open(['action' => 'CompaniesController@store']) }}
//
{{ Form::close() }}
@stop
Does the Form Builder know that you are using a non-conventional namespace for the route? Possibly you need:
{{ Form::open(['action' => 'Vanguard\Http\Controllers\WebCompaniesController@store']) }}
Please or to participate in this conversation.