Sounds to me like you are doing Schema::table('categories', instead of Schema::create('categories' in a migration
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wkaranjarealtorsdb.categories' doesn't exist on php artisan migrate
am getting this error when I run PHP artisan migrate when I want to send add the migration tables to the database in my laravel project. already i have created all the migration tables, when I run PHP artisan migrate am getting this
.I haven't figured out where the error is coming from, how can I fix it.
@Sinnbeck the schema is correct
public function up()
{
Schema::create('rental_categories', function (Blueprint $table) {
$table->id();
$table->String('rentalcat_title');
$table->String('rentalcat_url');
$table->String('status')->default(1);
$table->timestamps();
});
}
@stephen waweru Just read the error again. Are perhaps doing a query somewhere in a constructor or service provider ?
@stephen waweru this is a SELECT query - you probably are making a query in a service provider to share data with all views? If this is the case; and you are trying to run/re-run your migrations in a new database; you will first need to check that the table exists:
if (Illuminate\Support\Facades\Schema::hasTable('categories ')) {
View::share('categories' // ...
}
Otherwise, you could just check if the Application is running in console:
if (! app()->runningInConsole()) {
View::share('categories' // ...
}
@tykus yes I have viewed the F:\Local Server2\mysql\data folder the database folder is present but no table. what a trying to do is to create the tables.
@stephen waweru no, you missed my point; the problem I believe you have is a SELECT query in one of your application's ServiceProviders. This is being executed as part of the application bootstrapping the framework; even when attempting to execute Artisan commands.
Check your ServiceProviders for something using the rental_categories table, or RentalCategory model; for example:
View::share('rental_categories', RentalCategory::where('status', 1)->pluck('rentalcat_url'))
@tykus in my provider directories i have checked all the service providers and cant see to see where i used a similar select query
@stephen waweru show us the rest of that error stacktrace
here have a look
#0 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php(368): PDO->prepare('select `rentalc...') #1 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php(705): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select `rentalc...', Array) #2 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php(672): Illuminate\\Database\\Connection->runQueryCallback('select `rentalc...', Array, Object(Closure)) #3 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php(376): Illuminate\\Database\\Connection->run('select `rentalc...', Array, Object(Closure)) #4 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Query\\Builder.php(2414): Illuminate\\Database\\Connection->select('select `rentalc...', Array, true) #5 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Query\\Builder.php(2402): Illuminate\\Database\\Query\\Builder->runSelect() #6 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Query\\Builder.php(2936): Illuminate\\Database\\Query\\Builder->Illuminate\\Database\\Query\\{closure}() #7 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Query\\Builder.php(2403): Illuminate\\Database\\Query\\Builder->onceWithColumns(Array, Object(Closure)) #8 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Builder.php(625): Illuminate\\Database\\Query\\Builder->get(Array) #9 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Builder.php(609): Illuminate\\Database\\Eloquent\\Builder->getModels(Array) #10 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\ outes\\web.php(113): Illuminate\\Database\\Eloquent\\Builder->get() #11 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RouteFileRegistrar.php(35): require('F:\\\\Local Server...') #12 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(425): Illuminate\\Routing\\RouteFileRegistrar->register('F:\\\\Local Server...') #13 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(382): Illuminate\\Routing\\Router->loadRoutes('F:\\\\Local Server...') #14 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RouteRegistrar.php(163): Illuminate\\Routing\\Router->group(Array, 'F:\\\\Local Server...') #15 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\app\\Providers\\RouteServiceProvider.php(48): Illuminate\\Routing\\RouteRegistrar->group('F:\\\\Local Server...') #16 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(36): App\\Providers\\RouteServiceProvider->App\\Providers\\{closure}() #17 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #18 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(81): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure)) #19 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Object(Closure), Object(Closure)) #20 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(653): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Object(Closure), Array, NULL) #21 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider.php(120): Illuminate\\Container\\Container->call(Object(Closure)) #22 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider.php(45): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->loadRoutes() #23 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(36): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->Illuminate\\Foundation\\Support\\Providers\\{closure}() #24 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #25 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(81): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure)) #26 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Object(Closure), Object(Closure)) #27 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(653): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Object(Closure), Array, NULL) #28 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\ServiceProvider.php(119): Illuminate\\Container\\Container->call(Object(Closure)) #29 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(927): Illuminate\\Support\\ServiceProvider->callBootedCallbacks() #30 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(905): Illuminate\\Foundation\\Application->bootProvider(Object(App\\Providers\\RouteServiceProvider)) #31 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}(Object(App\\Providers\\RouteServiceProvider), 29) #32 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(906): array_walk(Array, Object(Closure)) #33 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Bootstrap\\BootProviders.php(17): Illuminate\\Foundation\\Application->boot() #34 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(237): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap(Object(Illuminate\\Foundation\\Application)) #35 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(310): Illuminate\\Foundation\\Application->bootstrapWith(Array) #36 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(127): Illuminate\\Foundation\\Console\\Kernel->bootstrap() #37 F:\\Local Server2\\htdocs\\karanjawebappsrealtors\\artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #38 {main}
@stephen waweru need to see your routes file(s) now... any quer(y|ies) in there?
@stephen waweru Mark the best answer
Please or to participate in this conversation.