How to fix the error while adding a record to the database?

  • 0
    Hello everyone! Who faced a similar situation. I get an error when adding records to the database.
    SQLSTATE [42S02]: Base table or view not found: 1146
    The table is migrated and listed correctly.
    Here is the model class.
    class EstablishmentOptions extends Model
    {


    protected $ table_cuisines = 'cuisines';

    }

    Controller

    class EstablishmentOptionsController extends Controller
    {
    // public function __construct ()
    // {
    // $ this- & gt; middleware ('auth');
    //}

    public function addCuisine (Request $ request)
    {
    $ this- & gt; validate ($ request, [
    'cuisine' = & gt; ['required', 'string', 'max: 50']
    ]);

    $ cuisines = new EstablishmentOptions;
    $ cuisines- & gt; name = $ request- & gt; cuisine;
    $ cuisines- & gt; save ();


    }
    }
    Laravel Anonymous, Jan 8, 2019

  • 2 Answers
  • 0
    protected $ table_cuisines = 'cuisines';


    what's this?
    Anonymous

  • 0
    $ table_cuisines should be changed to $ table, apparently.

    https://laravel.com/docs/8.x/eloquent#table-names



    And learn to style the code. This is disrespectful to those who will read your footcloths.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!