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


PHP Column::count方法代码示例

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


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

示例1:

<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
Admin::model('App\\User')->title('Users')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with('link');
    $display->order([[0, 'desc']]);
    $display->columns([Column::string('name')->label('Name'), Column::string('lastname')->label('Last Name'), Column::string('email')->label('Email'), Column::count('link')->label('Links count')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('name', 'Name')->required(), FormItem::text('email', 'Email')->required()->unique()]);
    return $form;
});
开发者ID:karakhanyans,项目名称:linker,代码行数:17,代码来源:User.php

示例2:

<?php

Admin::model('\\Country')->title('Countries')->with('contacts')->columns(function () {
    Column::string('title', 'Title');
    Column::count('contacts', 'Contacts')->append(Column::filter('country_id')->model('\\Contact'));
})->form(function () {
    FormItem::text('title', 'Title')->required()->unique();
});
开发者ID:tldmic,项目名称:admin_demo,代码行数:8,代码来源:Country.php

示例3:

<?php

Admin::model(\App\Model\Category::class)->title('Категории Блога')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with('pages');
    $display->filters([]);
    $display->columns([Column::string('title')->label('Название'), Column::count('pages.id')->label('Количество статей'), Column::action('show')->label('Label')->callback(function ($query) {
        return $query->active ? '&check;' : '-';
    })]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::tabbed();
    $form->items(['Main' => [FormItem::hidden('user_id')->defaultValue(AdminAuth::user()->id), FormItem::text('title', 'Заголовок'), FormItem::text('slug', 'Slug - Заполняется автоматически'), FormItem::ckeditor('content', 'Content'), FormItem::textarea('descriptor', 'Краткое описание')]]);
    return $form;
});
开发者ID:peyoter,项目名称:pblog,代码行数:15,代码来源:Category.php

示例4: str_limit

$model->display(function () {
    $display = AdminDisplay::tabbed();
    $display->tabs(function () {
        $mainDisplay = AdminDisplay::datatables();
        $mainDisplay->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::count('attachments')->label('Вложений'), Column::datetime('date')->label('Создан')->format('d.m.Y в H:i'), Column::datetime('created_at')->label('Импортирован')->format('d.m.Y в H:i')]);
        $mainDisplay->actions([Column::action('post_import')->value('Импортировать последние 10 записей')->icon('fa-share')->callback(function ($collection) {
            \App\Imports\Post::import(0, 10);
        }), Column::action('post_trashed')->value('Удалить записи')->icon('fa-times')->callback(function (\Illuminate\Database\Eloquent\Collection $collections) {
            if ($collections) {
                /** @var \App\Post $collection */
                foreach ($collections as $collection) {
                    $collection->delete();
                }
            }
        })]);
        $mainDisplay->order([3, 'desc']);
        $secondaryDisplay = AdminDisplay::datatables();
        $secondaryDisplay->apply(function ($query) {
            $query->onlyTrashed();
        });
开发者ID:stcoder,项目名称:uf-vova,代码行数:31,代码来源:Post.php

示例5: switch

<?php

use App\Models;
use SleepingOwl\Admin\Models\Form\FormGroup;
Admin::model(\App\Models\Order::class)->title('Orders')->denyCreating(function () {
    return true;
})->columns(function () {
    Column::string('id', 'Id');
    Column::string('customer.login', 'Customer')->inlineEdit(true);
    Column::callback('orders_status_id', 'Status')->contentCallback(function ($instance) {
        return $instance->status()->first()->getName();
    })->inlineEdit(true);
    Column::string('total', 'Total')->inlineEdit(true);
    Column::count('items', 'Items');
})->inlineEdit(function ($field) {
    switch ($field) {
        case 'customer.login':
            return function () {
                InlineEditItem::select('customer_id', NULL)->list(Models\Customer::class);
            };
            break;
        case 'orders_status_id':
            return function () {
                InlineEditItem::select('orders_status_id', NULL)->list(Models\OrdersStatus::class);
            };
            break;
        case 'total':
            return function () {
                InlineEditItem::text('total', NULL)->validationRule('required|regexp:\\d');
            };
            break;
开发者ID:procoders,项目名称:printrock,代码行数:31,代码来源:Order.php

示例6: use

<?php

/** @var \SleepingOwl\Admin\Model\ModelConfiguration $model */
$model = Admin::model(\App\HistoryDate::class);
$model->title('История – даты');
$model->display(function () {
    $display = AdminDisplay::datatables();
    $display->columns([Column::checkbox(), Column::string('title')->label('Заголовок')->orderable(false), Column::string('description')->label('Описание')->orderable(false), Column::count('events')->label('Событий')->orderable(false), Column::datetime('created_at')->label('Создан')->format('d.m.Y в H:i')->orderable(false), Column::order()->orderable(false)]);
    $display->order([[5, 'asc']]);
    $display->apply(function (\Illuminate\Database\Eloquent\Builder $query) {
        $query->withTrashed();
    });
    return $display;
})->createAndEdit(function ($id) use($model) {
    $model->title($id ? 'Редактировать дату' : 'Создать дату');
    $form = AdminForm::form();
    $form->items([FormItem::text('title', 'Заголовок')->required(), FormItem::text('description', 'Описание')]);
    return $form;
});
开发者ID:stcoder,项目名称:uf-vova,代码行数:19,代码来源:HistoryDates.php

示例7: switch

<?php

use SleepingOwl\Admin\Models\Form\FormGroup;
Admin::model(\App\Models\Customer::class)->title('Customers')->denyEditingAndDeleting(function ($instance) {
    return false;
})->columns(function () {
    Column::string('id', 'Id');
    Column::string('name', 'Name')->inlineEdit(true);
    Column::string('second_name', 'Second Name')->inlineEdit(true);
    Column::string('last_name', 'Last Name')->inlineEdit(true);
    Column::string('email', 'Email');
    Column::string('login', 'Login');
    Column::count('photos', 'Photos');
    Column::count('addresses', 'Addresses');
})->inlineEdit(function ($field) {
    switch ($field) {
        case 'name':
            return function () {
                InlineEditItem::text('name', NULL)->validationRule('required|regex:/^[a-zA-Z0-9_@]{3,100}$/');
            };
            break;
        case 'second_name':
            return function () {
                InlineEditItem::text('second_name', NULL)->validationRule('required|regex:/^[a-zA-Z0-9_@]{3,100}$/');
            };
            break;
        case 'last_name':
            return function () {
                InlineEditItem::text('last_name', NULL)->validationRule('required|regex:/^[a-zA-Z0-9_@]{3,100}$/');
            };
            break;
开发者ID:procoders,项目名称:printrock,代码行数:31,代码来源:Customer.php

示例8:

<?php

Admin::model('App\\Country')->title('Countries (orderable)')->display(function () {
    $display = AdminDisplay::table();
    $display->apply(function ($query) {
        $query->orderBy('order', 'asc');
    });
    $display->columns([Column::string('title')->label('Title'), Column::count('contacts')->label('Contacts')->append(Column::filter('country_id')->model('App\\Contact')), Column::order()]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('title', 'Title')->required()->unique()]);
    return $form;
});
开发者ID:ntamvl,项目名称:admin-3-demo,代码行数:14,代码来源:Country.php

示例9:

<?php

Admin::model('App\\Category')->title('Categories')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with('link');
    $display->filters([]);
    $display->columns([Column::string('name')->label('Name'), Column::count('link')->label('Links count')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('name', 'Name')]);
    return $form;
});
开发者ID:karakhanyans,项目名称:linker,代码行数:13,代码来源:Category.php

示例10: config

<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Input;
use App\Product;
use App\UserProduct;
Admin::model('App\\User')->title('Пользователи')->display(function () {
    $display = AdminDisplay::datatables();
    $display->columns([Column::checkbox(), Column::string('id')->label('ID'), Column::string('name')->label('Имя'), Column::custom()->label('Актив.')->callback(function ($instance) {
        return $instance->is_active ? '&check;' : '-';
    }), Column::string('email')->label('Email'), Column::count('products')->label('Товаров')->orderable(true), Column::count('list_active_products')->label('Акт. товаров')->orderable(true), Column::string('balance')->label('Баланс')]);
    $display->columnFilters([null, ColumnFilter::select()->model('App\\User')->display('name'), null, null, null, null]);
    $display->actions([Column::action('export')->value('Раздать товары')->icon('fa-share')->callback(function ($collection) {
        $max_products_per_user = config('main.max_products_per_user', 3);
        foreach ($collection as $key => $user) {
            $active_products = $user->list_active_products;
            $count_active_products = count($active_products);
            if ($count_active_products >= 0 && $count_active_products < $max_products_per_user) {
                $random_product = Product::orderByRaw("RAND()")->first();
                try {
                    $user_product = UserProduct::create(['user_id' => $user->id, 'product_id' => $random_product->id]);
                } catch (QueryException $e) {
                    //Nothing
                }
            }
        }
开发者ID:Eduard90,项目名称:Laravel-5-Example,代码行数:31,代码来源:User.php

示例11: dd

<?php

Admin::model('App\\Contact')->title('Contacts')->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<br/><small>(image)</small>'), Column::string('fullName')->label('Name<br/><small>(string with accessor)</small>'), Column::datetime('birthday')->label('Birthday<br/><small>(datetime)</small>')->format('d.m.Y'), Column::string('country.title')->label('Country<br/><small>(string from related model)</small>')->append(Column::filter('country_id')), Column::count('companies')->label('Companies<br/><small>(count)</small>'), Column::lists('companies.title')->label('Companies<br/><small>(lists)</small>'), Column::custom()->label('Has Photo?<br/><small>(custom)</small>')->callback(function ($instance) {
        return $instance->photo ? '&check;' : '-';
    }), Column::action('my_action')->label('<small>(action)</small>')->value('Custom action')->target('_blank')->callback(function ($instance) {
        dd('Custom action called with instance:', $instance->toArray());
    })]);
    return $display;
})->createAndEdit(null)->delete(null);
开发者ID:ntamvl,项目名称:admin-3-demo,代码行数:13,代码来源:Contact.php

示例12:

<?php

Admin::model('App\\Category')->title('Categorias')->display(function () {
    $display = AdminDisplay::table();
    $display->apply(function ($query) {
        $query->orderBy('order', 'asc');
    });
    $display->columns([Column::string('name')->label('Nombre'), Column::count('products')->label('Productos'), Column::order()]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('name', 'Nombre'), FormItem::image('banner', 'Banner'), FormItem::ckeditor('description', 'Descripcion')]);
    return $form;
});
开发者ID:avilaj,项目名称:ocsport,代码行数:14,代码来源:Category.php

示例13:

<?php

Admin::model('App\\Models\\Server')->title(trans('admin::pages.servers.title'))->display(function () {
    $display = AdminDisplay::datatables();
    $display->with();
    $display->filters([]);
    $display->columns([Column::string('name')->label('Name'), Column::string('ip')->label('Ip'), Column::string('port')->label('Port'), Column::string('engine')->label('Engine'), Column::count('products')->label('Товаров')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('name', 'Name')->required(), FormItem::text('ip', 'Ip')->required(), FormItem::text('port', 'Port')->required(), FormItem::text('rcon_password', 'RCON password'), FormItem::select('engine', 'Engine')->options([0 => 'CS 1.6', 1 => 'Counter-Strike: Source', 2 => 'Counter-Strike: Global Offensive'])->required(), FormItem::checkbox('active', 'Active')]);
    return $form;
});
开发者ID:proudly,项目名称:RefEng,代码行数:13,代码来源:Server.php


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