1. Go to this page and download the library: Download jiannius/atom library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jiannius / atom example snippets
// app/Livewire/Customers/Create.php
namespace App\Livewire\Customers;
use Jiannius\Atom\Traits\AtomComponent;
use Livewire\Component;
class Create extends Component
{
use AtomComponent;
public $name;
public $email;
public $bio;
public function breadcrumbs($crumbs)
{
return $crumbs
->home('Dashboard', route('home'))
->push('Customers', route('customers.index'))
->push('New Customer');
}
public function save()
{
$this->validate([
'name' => '
public function tableQuery()
{
return Invoice::query()->filter($this->filters);
}
#[Computed]
public function items()
{
return $this->tableQuery()->toTable();
}
public function deleteSelected(): void
{
$this->tableSelection()->delete();
$this->resetTableCheckboxes();
}
#[Computed]
public function items() // your name — atom never defines or looks for it
{
return $this->tableRowsQuery()->toTable(); // the selection when the toggle is on
}
public function tableSelectionQuery()
{
return Invoice::query(); // scoped, no filters
}
public function tableQuery()
{
return $this->tableSelectionQuery()->filter($this->filters); // + the live filters
}
use Jiannius\Atom\Casts\AsEditorContent;
class Article extends Model
{
protected $casts = [
'body' => AsEditorContent::class,
];
}
// app/Actions/Customer/Search.php
namespace App\Actions\Customer;
use Jiannius\Atom\Contracts\WebAction;
class Search implements WebAction
{
public function handle($params)
{
return \App\Models\Customer::query()
->where('name', 'like', '%'.$params['q'].'%')
->take(10)
->get(['id', 'name']);
}
}
class Search implements WebAction
{
public function authorize($params) : bool
{
return auth()->check();
}
public function handle($params) { /* ... */ }
}
namespace App\Actions;
class GetOptions extends \Jiannius\Atom\Actions\GetOptions
{
/** Readable only by a signed-in caller. */
protected array $auth = ['users'];
/** Readable by anyone, guests ->map(fn ($user) => ['value' => $user->id, 'label' => $user->name])
->all();
}
}