bale/core

Core for bale

Installs: 11

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Language:Blade

pkg:composer/bale/core

dev-master 2026-01-07 02:15 UTC

This package is auto-updated.

Last update: 2026-01-07 02:15:48 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require bale/core

You can publish and run the migrations with:

php artisan vendor:publish --tag="core-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="core-config"

This is the contents of the published config file:

return [
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="core-views"

Usage

$core = new Bale\Core();
echo $core->echoPhrase('Hello, Bale!');

Table Improvements (Filtering & Sorting)

Komponen tabel di bale-core telah dilengkapi dengan fitur filtering dan sorting yang terintegrasi dengan Livewire.

1. Sorting dengan x-core::table-th

Gunakan x-core::table-th di dalam slot thead untuk membuat header yang bisa diklik.

<x-slot name="thead">
    <tr>
        <x-core::table-th
            label="Nama"
            sortBy="name"
            :sortField="$sortField"
            :sortDirection="$sortDirection"
        />
    </tr>
</x-slot>

Di Livewire Component:

public $sortField = 'name';
public $sortDirection = 'asc';

public function sort($field) {
    if ($this->sortField === $field) {
        $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
    } else {
        $this->sortField = $field;
        $this->sortDirection = 'asc';
    }
}

2. Filtering dengan x-core::table

Gunakan slot filters dan prop activeFilters untuk menambahkan UI filter.

<x-core::table
    :links="$data"
    header
    :activeFilters="array_filter(['Status' => $filterStatus])"
>
    <x-slot name="filters">
        <x-core::select-dropdown label="Status" wire:model.live="filterStatus">
            <option value="">Semua</option>
            <option value="active">Aktif</option>
        </x-core::select-dropdown>
    </x-slot>
    ...
</x-core::table>

Di Livewire Component (Untuk Reset):

public function resetFilter($field) {
    if ($field === 'Status') $this->reset('filterStatus');
}

public function resetAllFilters() {
    $this->reset(['filterStatus', 'query']);
}

3. Item Actions (core.shared-components.item-actions)

Komponen untuk tombol Edit, Delete (dengan konfirmasi dropdown), dan aksi tambahan (slot).

<livewire:core.shared-components.item-actions
    :editUrl="route('items.edit', $item->id)"
    :deleteId="$item->id"
    confirmMessage="Yakin ingin menghapus data ini?"
>
    <!-- Slot Aksi Tambahan -->
</livewire:core.shared-components.item-actions>

Integrasi dengan Deletion Trait: Komponen item-actions didesain untuk bekerja secara otomatis dengan trait penghapusan pada setiap package.

  1. Core Package: Gunakan Bale\Core\Traits\HasDeleteOption.
  2. CMS Package: Gunakan Bale\Cms\Traits\HasSafeDelete (untuk support tenant connection).

Cara Penggunaan (Contoh di CMS):

use Bale\Cms\Traits\HasSafeDelete;

class YourComponent extends Component {
    use HasSafeDelete;
    protected string $modelClass = Post::class;
}

Komponen akan otomatis memicu method performDelete() pada trait tersebut saat konfirmasi ditekan.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.