Voyager: install into existing database - is 'categories' migration needed?

Created on 19 Feb 2017  Â·  10Comments  Â·  Source: the-control-group/voyager

  • Laravel Version: 5.4
  • Voyager Version: 0.11
  • PHP Version: 7.0
  • Database Driver & Version: Mysql 5.6.30-1 - (Debian)

Description: I am installing into an existing project ( which has an existing Category Model and categories table, relating to my Products() in my ecommerce website). When trying to install Voyager I get an error "Base table or view already exists: 1050 Table 'categories' already exists". Please correct me if i'm wrong, but aren't the 'categories' and 'pages' tables just there for an example setup? Is there some way I can leave 'categories' out and get a successful installation?

Steps To Reproduce:

question

All 10 comments

You can easily do this by doing the following before running the installation.

1.- Run php artisan vendor:publish to get the migrations published, then you can modify the migrations of your needs. In this case it is only 2016_02_15_204651_create_categories_table.php. You can change the database table to be voyager_categories.
2.- To make Voyager work with this new table, make a VoyagerCategory model like this:

<?php
namespace App;
class VoyagerCategory extends \TCG\Voyager\Models\Category
{
    protected $table = 'voyager_categories';
}

Then in you AppServiceProvider add Voyager::useModel('Category', VoyagerCategory::class);

Thanks Mark, but i'm getting "Non-static method TCG\Voyager\Voyager::useModel() should not be called statically" using "Voyager::useModel('Category', VoyagerCategory::class);" in the AppServiceProvider.

Use the facade TCG\Voyager\Facades\Voyager.

Ok, I tried the facade. I was unsure which method in AppServiceProvider to use it in but with boot() I get "Class App\ProvidersVoyagerCategory does not exist" and using register() I get "Class voyager does not exist". The Model is supposed to go under App/ isn't it?

Use \AppVoyagerCategory.

On 19. feb. 2017 22.06 +0100, Bulmer notifications@github.com, wrote:
>

Ok, I tried the facade. I was unsure which method in AppServiceProvider to use it in but with boot() I get "Class App\ProvidersVoyagerCategory does not exist" and using register() I get "Class voyager does not exist". The Model is supposed to go under App/ isn't it?

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub (https://github.com/the-control-group/voyager/issues/777#issuecomment-280949057), or mute the thread (https://github.com/notifications/unsubscribe-auth/ACIQ2w-FHwZuV1o8CJoXks5xNYs2gSjJks5reK7tgaJpZM4MFb7q).

Thanks again. I did work that out earlier, then got stuck on some problems
with previous migrations and existing tables etc. All working now though.
Cheers.

On Mon, Feb 20, 2017 at 7:46 PM, Mark Topper notifications@github.com
wrote:

Use \AppVoyagerCategory.

On 19. feb. 2017 22.06 +0100, Bulmer notifications@github.com, wrote:
>

Ok, I tried the facade. I was unsure which method in AppServiceProvider
to use it in but with boot() I get "Class App\ProvidersVoyagerCategory
does not exist" and using register() I get "Class voyager does not exist".
The Model is supposed to go under App/ isn't it?

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub (https://github.com/the-
control-group/voyager/issues/777#issuecomment-280949057), or mute the
thread (https://github.com/notifications/unsubscribe-auth/ACIQ2w-
FHwZuV1o8CJoXks5xNYs2gSjJks5reK7tgaJpZM4MFb7q).

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/the-control-group/voyager/issues/777#issuecomment-281019592,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABw0RqRy5CJASqH1QoCMZXVVOgO0rHNyks5reVLqgaJpZM4MFb7q
.

Glad to hear 🎉

Have the same problem. I think it's quite common to already have a table names "categories", "translations" etc.. Voyager should not use generic tables names like that by default.

This has been closed for nearly a year. Please don't revive long-dead issues. You can open your own or post in our Slack group. But in short, https://media1.giphy.com/media/RL0xU1daTlMoE/giphy.gif This has been requested/complained about numerous times. We're looking for the best way to fix it, and just haven't found it yet.

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

raoasifraza1 picture raoasifraza1  Â·  3Comments

TXRRNT picture TXRRNT  Â·  3Comments

TPRAsh picture TPRAsh  Â·  3Comments

abacram picture abacram  Â·  3Comments

Nagendra1421 picture Nagendra1421  Â·  3Comments