Support the ongoing development of →
Configuration Eloquent
Last updated 1 year ago.

maartenscholz said: This creates a SQL error (Table 'gks.types' doesn't exist) when migrating.

When migrating? No, this wouldn't cause an error when you're migrating. If you're trying to run

php artisan migrate

and you're getting an error that the table doesn't exist that means you're probably doing something wrong in the migration file that creates the table.

Last updated 1 year ago.

Sorry, I should have been more specific, if I do a migrate:reset and then migrate the error occurs. There is nothing wrong with my migration. If i remove

->where(['type' => implode('|',\Gks\Models\Type::getAllSlugs())]);

the migrate command works correct.

Laravel probably loads routes.php before migrating, and then throw an error because of trying to execute

Last updated 1 year ago.

What does the function getAllSlugs() do ? If it takes info from the db and before migrating you don't have any records, maybe that's the problem.

Last updated 1 year ago.

I forgot. I recently did something silimar. Just check for this in your routes.php

if (!App::runningInConsole()) {
    // code with model calls
Last updated 1 year ago.


In my humble opinion, you shouldn't do it in the routes.php file.

  1. Add a "slug" field in your "types" database table

  2. In your ProjectController@index, start by creating a validation rule like:

public function index( $type ) {
   $rule = array ( 'type' => 'required|exists:types,slug');
   $validator = Validator::make( array('type'=>$type), $rule );
   if ( $validator->passes() ){
      // whatever
  // keep going



Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.