PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Solved
Solved
solutions

Mar 11th, 2023 09:14 PM

I tried creating BREAD for a new table, once I sa i get the following error

Target class [App\SocialMedia] does not exist.

Please help

bobbyiliev

Mar 12th, 2023 07:39 AM

Hi there,

You will need to change the Model from App\SocialMedia to App\Models\SocialMedia.

Let me know how it goes!

solutions

Mar 13th, 2023 04:38 AM

I used the voyager to create BREAD, So does that mean I should edit the code directly?

bobbyiliev

Mar 13th, 2023 06:11 AM

Hi there,

No, you can do that via Voyager:

  • Go to the Voyager Admin
  • Click on BREAD
  • Click Edit for the BREAD that you want to edit
  • Under the Model Name change the mode accordingly.
solutions

Mar 13th, 2023 07:56 AM

I tried and it gave a similar error

Target class [App\Models\SocialMedia] does not exist.
bobbyiliev

Mar 13th, 2023 08:17 AM

Best Answer

Did you already create the SocialMedia model?

When you add a new Table, you have to add a model as well by clicking the button next to the 'Create model for this table' field:

For more information you can check out the docs here:

https://voyager-docs.devdojo.com/core-concepts/database-manager

Let me know how it goes.

solutions

Mar 13th, 2023 08:22 AM

Oh I thought the button is for "not creating the model" since it was labeled "No Thank you" I will try again

bobbyiliev

Mar 13th, 2023 08:26 AM

I see, yes make sure that it is enabled so that you could have your model automatically created. Let me know how it goes.

solutions

Mar 13th, 2023 08:37 AM

Yay!! it worked. Thank you

solutions

Mar 13th, 2023 08:46 AM

Now I have another issue. when I click to browse, I get the following error

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'zgtumqgvhw.social_media' doesn't exist
select `Social_Media`.* from `social_media` order by `created_at` desc

Am i meant to always run php artisan migrate when I create a new table or is there something wrong on the server?

bobbyiliev

Mar 13th, 2023 11:18 AM

Hi there,

With Voyager you don't have to run php artisan migrate.

The problem is that you are not following the Laravel naming convention.

Your table name should be social_medias with an s at the end, otherwise, Laravel will fail to find the table.

All models should be singular, eg. User, Post, Comment, but the tables should be plural, eg: users,posts,comments

cheerschance

Mar 18th, 2023 01:50 AM

I created table Warehouses with create model switch on - no model was created at the server. So I used compass to create model I checked - the model was created at the app/Models/Warehouse
Now created bread - in the model box I typed app/Models/Warehouse but when I create bread the browser returns error model is not found.
Is there any code I need to change ion the model created by compass?

I uploaded some tables in the database all ending with s - All having primary keys. These tables are showing up in databases. I created models through compass for the tables. But when I am creating bread - all the time the no modl found error comes

bobbyiliev

Mar 19th, 2023 10:06 AM

Hi there,

The correct model definition should be: App\Models\Warehouse rather than app/Models/Warehouse.

Let me know how it goes once you change this.

nashparsons951

May 22nd, 2023 11:39 PM

Use the full namespace in your route files when using the string syntax, for example:

Route::get ('/social-media', 'App\Http\Controllers\SocialMediaController@index')

Report
1