@risalah whats in your app/Repositories/Setting/SettingRepositoryImplement.php
May 12, 2023
15
Level 1
php artisan migrate gives error
In terminal, when I try to migrate using php artisan migrate, I get this sql error:
Illuminate\Database\QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_sample.settings' doesn't exist (Connection: mysql, SQL: select * from `settings` where `key` = github_client_id limit 1)
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:793
789▕ // If an exception occurs when attempting to run a query, we'll format the error
790▕ // message to include the bindings with SQL, which will make this exception a
791▕ // lot more helpful to the developer instead of just the database's errors.
792▕ catch (Exception $e) {
➜ 793▕ throw new QueryException(
794▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
795▕ );
796▕ }
797▕ }
i A table was not found: You might have forgotten to run your database migrations.
https://laravel.com/docs/master/migrations#running-migrations
1 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()
+12 vendor frames
14 app/Repositories/Setting/SettingRepositoryImplement.php:26
Illuminate\Database\Eloquent\Builder::first()
I believe that I've setup my .env file correctly:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:pUEmW+LfwGvK+n1SD29CZv6iso71gRhKB1ILaYn+vTs=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db_sample
DB_USERNAME=root
DB_PASSWORD=unknown
Has anyone ever had a problem like this, and how do I fix it?
Level 24
if (! app()->runningInConsole()) {
// in your case, when you run `php artisan migrate`
// all the code here won't fired
}
1 like
Please or to participate in this conversation.