Laravel Voyager installation issue - laravel

I just finished my first laravel project> Now I only need to install an admin panel. I tried to install Laravel Voyager but I got an issue because I had a role table already created, So it stopped the installation. Is there a way to fix this issue or should I use admin panel, what do you advice me ?
I already had a role table with helpers methods and data that I am currently using. I completely unistall it and I delete all files that I got during the installation.

In the past, I run into the same issue with Voyager, with my previous users and a roles table. Since I had logic already in place for the user's/role table design, what I did was fuse both tables migrations into one. In detail these are the steps I went through to accomplish that:
Create new database for Voyager's installation.
Update.env to access new DB (would be advisable to clear cache after).
Install Voyager php artisan voyager:install (after Voyager vendor was installed using composer).
Copy Voyagers migrations to database/migrations, make your changes, turn off the config option database.autoload_migrations (full guidance for this step can be found in https://voyager-docs.devdojo.com/getting-started/installation#advanced).
Merge conflicting migrations files (in this case the roles table, or any other that can conflict with Voyager's migrations), meaning bringing columns needed from the previous migration into Voyager's migration file.
Delete all tables from the database again (since migrations tables were modified) and run php artisan migrate.
Now you should end-up having the previous roles table (with previous and new Voyagers columns, and definitions), without affecting the Voyager's tables functionality :)

Related

My Laravel 5.3 Migrations seem to be messed up - how to fix?

I have a Laravel 5.3 site and I suspect I made some manual database changes without using the Laravel migrate functionality and now it is biting me...
Now I am trying to get to a stable database situation.
Here was my migrations folder yesterday:
create_sometable1_table
create_sometable2_table
create_sometable3_table
And so on.
Then I added via
php artisan make:migration create_newtable_table
But later renamed the migration file and the model file to create_newtabledifferentname_table
Then I tried to add another table using
php artisan make:migration create_anothertable_table
But I get
[InvalidArgumentException]
A CreateAnothertableTable migration already exists.
I ran the usual commands to try and get things into normal state, like cache:clear, and the recommended composer commands (like autoload).
But nothing works.
In my DB these tables don't exist and the migration file create_anothertable_table doesn't exist.
So I ran
php artisan migrate:rollback
And this resulted in all but 3 of my tables disappearing, with 3 now remaining in the database. The 3 remaining ones are not the ones of interest.
Anyway, I have all my tables and data on my live site and am just trying to get things locally looking the same, so no big deal that my DB on localhost is currently messed up.
Just need to know, how to get things into a stable state from this point onward?
Thanks!
Brian

How to generate completely new migration in laravel 5.2

I am new to Laravel and was working on one project, which was 90% completed, and now project is 100% completed.
The project has old Migration files. I have made so many modifications in the tables (added/deleted columns) and/or added new tables in the database, now how do I update/create the Migration for that modifications? Because I don't remember where did I made the changes in the tables.
Do I have to use artisan command to create new migration for users table and all other tables same like this? php artisan make:migration create_users_table --create=users or there is any another way?
I have read the documentation but don't get how to do it.
Please correct me if I have made any mistake, because I don't know how to ask this question.
We user migration and tinker to Not use phpmyadmin , so if you have altered your tables in any way in phpmyadmin , you are all set , no need to do anything.
If you dont want to use phpmyadmin you can use migration and then start writing the sql code in there ( altering tables , etc)
And as we know the migration php files are located in your laravelfolder/database/migration . you can edit them there and then run php artisan migration and it will go throw all of them and make the changes in phpmyadmin.
Hope im clear enough :D

Can Laravel generate all mvc skeleton out of an existing table like that of cakephp's command cake bake all

I found laravel very interesting. But I'm wondering if there's any artisan command to generate all MVC skeleton files provided a database table all at ones. And how about separate generation of especially the model, given the table structure? or is there any alternative way to do the code generating?
You can create a migration file from the table via the package below.
https://github.com/Xethron/migrations-generator
Install it via : composer require --dev "xethron/migrations-generator"
Follow the package instructions, After connecting you application with the database simply run php artisan migrate:generate.
You will see number of migrations created via console message, You can also check your database/migrations folder for confirmation.
I didn't find how to do that, so I created my own code in order to create the models:
https://github.com/Triun/laravel-model-base
It is not super documented, but you can actually write your own addons in order to add custom business behaviors or include your own interfaces or traits to your models, with your own code.
And of course, reports and contributions are more than welcome.
I hope this helps.

Laravel Package Migration add column to existing App Migration in Database

I'm creating a Laravel Package that will migrate / add a column to an already existing App Migration that was migrated prior to package being installed.
Is there any best methods for setting something like this up? And if so, how do you manage reset/refresh migrations from App and Package.
OR
Is it better to keep them both separate in that the Package Migration overrides all migrations that the App Migration would have done.
Thanks.
Its always better to keep the column modifications in a separate migration unless and until0l you are so sure that your package is not used anywhere as of now. For existing installations it may cause problem with migration/rollback if you modify the existing migration. So i would recommend going with a new migration for column changes

create first user in Laravel 5

This is my first time using Laravel 5. Never experienced with any of other framework like CakePHP, CodeIgniter, Yii, etc. I just know how to use make api REST with slim framework.
I already create a table users as I can't access <<URL>>/home. I create fields and load it some data. Whenever I want to try reset the password, it show error because I dont have table password_resets. What are the steps to be taken after install the Laravel actually.
Thanks
You don't need to create any table manually (and you shouldn't). In Laravel you have migrations that help you quickly create tables in your database and seeds (where you can put initial data to those tables).
In fresh Laravel installation you have 2 ready migrations (for creating users and password_resets tables). All you need to do is running your console, go to directory where you have your Laravel project and run:
php artisan migrate
to run those migrations. After running this command Laravel will create those 2 tables for you. Before, you need to have configured your database connection (look at config/database.php file)

Resources