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.
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
\Gks\Models\Type::getAllSlugs()
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.
I forgot. I recently did something silimar. Just check for this in your routes.php
if (!App::runningInConsole()) {
// code with model calls
}
Hi,
In my humble opinion, you shouldn't do it in the routes.php file.
Add a "slug" field in your "types" database table
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
}
Regards,
Jeremy
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community