当前位置: 首页>>代码示例>>PHP>>正文


PHP AdminDisplay::tab方法代码示例

本文整理汇总了PHP中AdminDisplay::tab方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminDisplay::tab方法的具体用法?PHP AdminDisplay::tab怎么用?PHP AdminDisplay::tab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AdminDisplay的用法示例。


在下文中一共展示了AdminDisplay::tab方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: strlen

    $display = AdminDisplay::tabbed();
    $display->tabs(function () {
        $tabs = [];
        $columns = [Column::string('title')->label('Title'), Column::datetime('date')->label('Date')->format('d.m.Y'), Column::custom()->label('Published')->callback(function ($instance) {
            return $instance->published ? '✓' : '-';
        })];
        $main = AdminDisplay::table();
        $main->columns($columns);
        $tabs[] = AdminDisplay::tab($main)->label('Main')->active(true);
        $withScope = AdminDisplay::table();
        $withScope->scope('last');
        $withScope->columns($columns);
        $tabs[] = AdminDisplay::tab($withScope)->label('With Scope');
        $otherColumns = AdminDisplay::table();
        $otherColumns->apply(function ($query) {
            $query->orderBy('title', 'asc');
        });
        $otherColumns->columns([Column::string('title')->label('Title'), Column::custom()->label('Title Length')->callback(function ($instance) {
            return strlen($instance->title);
        })]);
        $tabs[] = AdminDisplay::tab($otherColumns)->label('Other Columns and Order');
        $otherDisplay = Admin::model('App\\Page')->display();
        $tabs[] = AdminDisplay::tab($otherDisplay)->label('Display from Other Model');
        return $tabs;
    });
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('title', 'Title')->required(), FormItem::date('date', 'Date')->required()->format('d.m.Y'), FormItem::checkbox('published', 'Published'), FormItem::ckeditor('text', 'Text')]);
    return $form;
});
开发者ID:ntamvl,项目名称:admin-3-demo,代码行数:31,代码来源:News3.php

示例2: use

<?php

Admin::model('App\\Contact3')->title('Contact')->alias('contacts3')->display(function () {
    $display = AdminDisplay::table();
    $display->with('country', 'companies');
    $display->filters([Filter::related('country_id')->model('App\\Country')]);
    $display->columns([Column::image('photo')->label('Photo'), Column::string('fullName')->label('Name'), Column::datetime('birthday')->label('Birthday')->format('d.m.Y'), Column::string('country.title')->label('Country')->append(Column::filter('country_id')), Column::lists('companies.title')->label('Companies')]);
    return $display;
})->createAndEdit(function ($id) {
    $display = AdminDisplay::tabbed();
    $display->tabs(function () use($id) {
        $tabs = [];
        $form = AdminForm::form();
        $form->items([FormItem::columns()->columns([[FormItem::text('firstName', 'First Name')->required(), FormItem::text('lastName', 'Last Name')->required(), FormItem::text('phone', 'Phone'), FormItem::text('address', 'Address')], [FormItem::image('photo', 'Photo'), FormItem::date('birthday', 'Birthday')->format('d.m.Y')], [FormItem::select('country_id', 'Country')->model('App\\Country')->display('title'), FormItem::textarea('comment', 'Comment')]])]);
        $tabs[] = AdminDisplay::tab($form)->label('Main Form')->active(true);
        if (!is_null($id)) {
            $instance = App\Contact::find($id);
            if ($instance->country_id) {
                $country = Admin::model('App\\Country')->fullEdit($instance->country_id);
                $tabs[] = AdminDisplay::tab($country)->label('Form from Related Model (Country)');
            }
            $companies = Admin::model('App\\Company')->display();
            $companies->scope('withContact', $id);
            $companies->parameters(['contact_id' => $id]);
            $tabs[] = AdminDisplay::tab($companies)->label('Display from Related Model (Companies)');
        }
        return $tabs;
    });
    return $display;
})->delete(null);
开发者ID:ntamvl,项目名称:admin-3-demo,代码行数:30,代码来源:Contact3.php

示例3: str_limit

        $secondaryDisplay = AdminDisplay::datatables();
        $secondaryDisplay->apply(function ($query) {
            $query->onlyTrashed();
        });
        $secondaryDisplay->columns([Column::checkbox(), Column::string('id'), Column::custom()->label('Картинка')->callback(function ($instance) {
            $attachment = $instance->attachments()->first();
            if (!is_null($attachment)) {
                if ($attachment->type === 'album') {
                    $attachment = $attachment->childs()->first();
                }
                return "<img class='thumbnail' width='80px' src='{$attachment->srcs['image_small']}'>";
            }
            return '';
        }), Column::custom()->label('Текст')->callback(function ($instance) {
            return str_limit($instance->text, 180);
        }), Column::datetime('date')->label('Создан')->format('d.m.Y в H:i'), Column::datetime('created_at')->label('Импортирован')->format('d.m.Y в H:i'), Column::datetime('deleted_at')->label('Удален')->format('d.m.Y в H:i')]);
        $secondaryDisplay->actions([Column::action('post_restore')->value('Восстановить записи')->icon('fa-refresh')->callback(function (\Illuminate\Database\Eloquent\Collection $collections) {
            if ($collections) {
                /** @var \App\Post $collection */
                foreach ($collections as $collection) {
                    $collection->restore();
                }
            }
        })]);
        $tabs = [];
        $tabs[] = AdminDisplay::tab($mainDisplay)->label('Активные записи')->active(true);
        $tabs[] = AdminDisplay::tab($secondaryDisplay)->label('Удаленные записи');
        return $tabs;
    });
    return $display;
});
开发者ID:stcoder,项目名称:uf-vova,代码行数:31,代码来源:Post.php

示例4:

<?php

Admin::model('App\\Post')->title('Posts (soft deletes)')->display(function () {
    $display = AdminDisplay::tabbed();
    $display->tabs(function () {
        $tabs = [];
        $default = AdminDisplay::table();
        $default->columns([Column::string('title')->label('Title')]);
        $tabs[] = AdminDisplay::tab($default)->label('Default')->active(true);
        $withTrashed = AdminDisplay::table();
        $withTrashed->scope('withTrashed');
        $withTrashed->columns([Column::string('title')->label('Title')]);
        $tabs[] = AdminDisplay::tab($withTrashed)->label('With Trashed');
        $onlyTrashed = AdminDisplay::table();
        $onlyTrashed->scope('onlyTrashed');
        $onlyTrashed->columns([Column::string('title')->label('Title')]);
        $tabs[] = AdminDisplay::tab($onlyTrashed)->label('Only Trashed');
        return $tabs;
    });
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('title', 'Title')->required()->unique(), FormItem::ckeditor('text', 'Text')]);
    return $form;
});
开发者ID:ntamvl,项目名称:admin-3-demo,代码行数:25,代码来源:Post.php


注:本文中的AdminDisplay::tab方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。