1. Go to this page and download the library: Download atk4/ui 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/ */
class User extends Model
{
protected function init(): void
{
parent::init();
$this->addField('name');
$this->addField('gender', ['enum' => 'female', 'male', 'other']);
$this->hasMany('Purchases', ['model' => [Purchase::class]]);
}
}
use \Atk4\Mastercrud\MasterCrud;
// set up $app here
$masterCrud = MasterCrud::addTo($app)
->setModel(new User($app->db), [
'Purchases' => [],
]);
$this->addUserAction('archive', function (Model $entity) {
$this->set('is_archived', true);
$this->saveAndUnload();
});
$tabs = \Atk4\Ui\Tabs::addTo($app);
\Atk4\Ui\Message::addTo($tabs->addTab('Intro'), ['Other tabs are loaded dynamically!']);
$tabs->addTab('Users', function (\Atk4\Ui\VirtualPage $p) use ($app) {
// this tab is loaded dynamically, but also contains dynamic component
\Atk4\Ui\Crud::addTo($p)
->setModel(new User($app->db));
});
$tabs->addTab('Settings', function (\Atk4\Ui\VirtualPage $p) use ($app) {
// second tab contains an AJAX form that stores itself back to DB
$m = new Settings($app->db);
$m = $m->load(2);
\Atk4\Ui\Form::addTo($p)
->setModel($m);
});
$app = new \Atk4\Ui\App('My App');
$app->initLayout([\Atk4\Ui\Layout\Admin::class]);
$app->db = \Atk4\Data\Persistence::connect('mysql://user:pass@localhost/yourdb');
class User extends \Atk4\Data\Model
{
public $table = 'user';
protected function init(): void
{
parent::init();
$this->addField('name');
$this->addField('email', ['
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.