PHP code example of incraigulous / adminzone

1. Go to this page and download the library: Download incraigulous/adminzone 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/ */

    

incraigulous / adminzone example snippets


    
    namespace App\Resources;
    
    use Incraigulous\AdminZone\Resources\Resource;
    
    class User extends Resource
    {
        public function columns(): array
        {
            return [
                'ID' => 'id',
                'Name' => 'name',
                'email' => function ($user) {
                    return "<a href='mailto:$user->email' title='Email $user->name'>$user->email</a>";
                },
                'Created' => function($model) {
                    return $model->created_at->format('M d Y');
                },
            ];
        }
    
        public function fields(): array
        {
            return [
                'ID' => 'id',
                'Name' => 'name',
                'email' => function ($user) {
                    return "<a href='mailto:$user->email' title='Email $user->name'>$user->email</a>";
                }
            ];
        }
        
        public function model() {
            return new \App\User();
        }
    }

    protected function main(SectionInterface $main): SectionInterface
    {
        $main->field(TextField::create('Email'))
        ->$main->field(BelongsToField::create('User')->relatedTo(User::class));

        return $main;
    }

    protected function main(SectionInterface $main): SectionInterface
    {
        $main->field(TextField::create('Post Title'))
        $main->field(RichTextField::create('Content'))
        ->$main->field(BelongsToManyField::create('Author')->relatedTo(Author::class));

        return $main;
    }

    php artisan vendor:publish --provider="Incraigulous\AdminZone\AdminZoneServiceProvider" --tag=config