0

This is code from one of my views, create.blade.php

Error: Action PetsController@store not defined.

I think this has something to do with Laravel 8 different way to call controller methods. The controller is PetsController and it was created to be a CRUD (php artisan make:controller PetsController --resource)

using php artisan route:list it says that i should use "App\Http\Controllers\PetsController@store" in 'action', but isn't there a better way to do this?

@extends('layouts.app')


@section('content')


    {!! Form::open([
        'method'=>'post', 'action'=>'PetsController@store'
    ]) !!}

@endsection
Khonshu
  • 15
  • 6
  • You probably need to pass it as an array: `'action' => [PetsController::class, 'store']`. (I say probably because I haven't used this specifically but route actions are declared like that) – yaakov Jan 07 '22 at 22:47
  • 2
    Just use the route name instead. Something like: `{!! Form::open(['route' => 'pets.store']) !!}` – Martin Bean Jan 07 '22 at 22:50
  • @MartinBean thank you that worked, but does it work the same way? – Khonshu Jan 07 '22 at 23:11
  • @Teteeu14 not MartinBean but yes it's working the same – Jack Jan 08 '22 at 09:14

0 Answers0