Admin Panel and CRUD Generator in Laravel 8 using Craftable
First create a new laravel project,
composer create-project --prefer-dist laravel/laravel:^8.0 craftable# go inside the project folder
cd craftable
Now, add the craftable to your laravel project,
composer require brackets/craftable
composer require --dev brackets/admin-generator
Add your database credientials to .env file,
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=craftable
DB_USERNAME=root
DB_PASSWORD=password
Install the craftable,
php artisan craftable:install
After successfully running this command your password will be automatically generate, save that password to clipboard. (In the below picture the highlighted is password)
Now, install the node modules,
npm install
npm run dev
Craftable is successfully install and now you can run the project on browser.
php artisan serve
You can login by using:
Email: administrator@brackets.sk
Password: you copied a while before
Now, let’s create a crud. you just need to create a migration and leave it to the craftable to make a crud for you.
e.g. create a migration for product
php artisan make:migration create_products_table# migration path
# database/migrations/2021_05_21_115426_create_products_table.php
Add some columns to the migration,
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->nullable();
$table->boolean('status')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products');
}
}
Now, just hit the following command to make the whole crud,
php artisan admin:generate products
Now, compile the the laravel mix
npm run dev
Crud is generated, now you can run the project,
php artisan serve