Using QuickAdmin for Existing Laravel Project
Founder of QuickAdminPanel
We’ve been asked quite a lot about using QuickAdmin for already existing project. It’s not straightforward but possible: time to write a mini-tutorial about it.
Let’s imagine you already have a Laravel project, with proper front-end and database. And you want to build an adminpanel for it.
Real example: our FAQ section page which looks like this:
It’s a small Laravel 5.3 project with two database tables: sections and questions:
Here’s how the migrations look like:
Schema::create('sections', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->timestamps(); $table->softDeletes(); });
Schema::create('questions', function (Blueprint $table) { $table->increments('id'); $table->integer('section_id')->unsigned(); $table->foreign('section_id')->references('id')->on('sections'); $table->text('question'); $table->text('answer'); $table->timestamps(); $table->softDeletes(); });
Now, let’s get back to the topic – how to create an adminpanel for this mini-project? Of course, with our QuickAdmin.
Step 1. Create a new project (and register if you haven’t already)
Step 2. Create CRUDs – Sections and Questions, adding all the same fields as in our current project
Step 3. Download the project, unarchive it and prepare for use
You can put it into a separate folder, or into the same project under /admin or something like that. But it is treated as a separate Laravel project – with its dependancies, migrations etc.
In my case, I’ve put it in the same folder and within Homestead.yaml file configured a subdomain to point to that folder, for me locally it became admin.faq.dev URL.
Of course, you need to set up .env file – choose the same database as in your existing project. Don’t be afraid, QuickAdmin won’t erase anything.
Also, run things like:
composer install php artisan key:generate
Step 4. Run the migrations and seeds
Now, this one is the most tricky part. The old project has migrations for questions and sections, so for adminpanel we don’t need to run it.
But on the other hand, we need to run migrations and seeds for roles and users for our adminpanel, right?
Now, let’s create a separate migrations table for the adminpanel! Yes, it is possible – in your adminpanel project go to config/database.php and change ‘migrations’ value into something else, like ‘migrations_admin’.
Then you can run migrations separately for your admin project:
php artisan migrate --seed
By the way, our generated migrations will check if that table already exists, so won’t throw any errors on existing sections/questions:
if(! Schema::hasTable('sections')) { Schema::create('sections', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->timestamps(); $table->softDeletes(); }); }
And that’s it – go to your adminpanel URL and login with admin@admin.com – password.
There you go – you can now manage your sections and questions!
That’s it!
Of course, this example is quite simplified and uses only two database tables, on bigger projects you would face more complicated database merges, but we’re happy to consult you on it – just shoot an email to info@laraveldaily.com or use live-chat help which is always available on QuickAdminPanel.com.