BREAKING NEWS

Jumat, 13 Desember 2024

Belajar Membuat Aplikasi Glossarium berbasis Laravel dan Filament

Guys, di sini saya ingin sharing cara membuat backend pengelolaan data glosarium, berbasis laravel dan filament, semoga dapat bermanfaat buat rekan-rekan.

 

Dashboard

CRUD Category

 

CRUD Glossarium

CRUD Tautan

Step-stepnya sebagai berikut:

1. Create laravel project

    composer create-project laravel/laravel:^10.0 lat-filamen


2. masuk ke folder lat-filamen

    cd lat-filamen


3. install filament 3.2

    composer require filament/filament:"^3.2" -W


4. install panel filament

    php artisan filament:install --panels


5. Buat user

    php artisan make:filament-user
    Name:
    > Admin

    Email:
    > admin@example.com

    Password:
    > ********

    User Admin has been created successfully!



6. Buat model Category

    php artisan make:model Category -m


7. Tambahkan script di models/category.php

    protected $fillable = [
            'name',
        ];



8. Edit file database/migration/create_categories_table.php

    Schema::create('categories', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->timestamps();
            $table->softDeletes();
        });


9. Jalankan migrasi

    php artisan migrate



10. Buat resource category untuk membuat form CRUD Category

    php artisan make:filament-resource Category --generate


11. Buat model Glossarium

    php artisan make:model Glossarium -m


12. Tambahkan script di models/category.php

    protected $fillable = [
            'name',
            'category_id',
            'istilah_indonesia',
            'istilah_inggris',
            'description',
        ];


13. Edit file database/migration/create_glossaria_table.php
   Tambahkan script:

    Schema::create('categories', function (Blueprint $table) {
            $table->id();
            $table->string('istilah_indonesia');
            $table->string('istilah_inggris');
            $table->text('description');
            $table->foreignId('category_id')->constrained('categories')->cascadeOnDelete();
            $table->timestamps();
            $table->softDeletes();
        });


14. Jalankan migrasi

    php artisan migrate


15. Buat resource Glossarium untuk membuat form CRUD Glossariums

    php artisan make:filament-resource Glossarium --generate


16. Buat model Tautan

    php artisan make:model Tautan -m


17. Tambahkan script di models/category.php

    protected $fillable = [
            'instansi',
            'url',
    ];


18. Edit file database/migration/create_tautans_table.php
   Tambahkan script:

    Schema::create('categories', function (Blueprint $table) {
            $table->id();
            $table->string('instansi');
            $table->string('url');
            $table->timestamps();
            $table->softDeletes();
        });


19. Jalankan migrasi

    php artisan migrate


20. Buat resource Tautan untuk membuat form CRUD Tautan

    php artisan make:filament-resource Tautan --generate


21. Membuat group menu side navigasi
    Tambahkan skrip di dalam class TautanResource:

    protected static ?string $navigationGroup = 'Admin Menu';


22. Mengubah nama side navigasi
    Tambahkan skrip di dalam class TautanResource:   

    protected static ?string $navigationLabel = 'Tautan';

 

22. Jalankan aplikasi

    php artisan serve

;

 
Copyright © 2014 Persada Blog

Powered by Mafsyah