示例#1
0
 public function testFactories()
 {
     // char
     $this->assertEquals(new CharColumn('foo', 'char', 0), Column::char('foo', 0));
     $this->assertEquals(new CharColumn('foo', 'varchar', 0), Column::varchar('foo', 0));
     // datetime
     $this->assertEquals(new DateTimeColumn('foo'), Column::datetime('foo'));
     // decimal
     $this->assertEquals(new DecimalColumn('foo', 10, 2), Column::decimal('foo', 10, 2));
     // float
     $this->assertEquals(new FloatColumn('foo', 10, 2), Column::float('foo', 10, 2));
     // int
     $this->assertEquals(new IntColumn('foo', 'tinyint'), Column::tinyint('foo'));
     $this->assertEquals(new IntColumn('foo', 'smallint'), Column::smallint('foo'));
     $this->assertEquals(new IntColumn('foo', 'int'), Column::int('foo'));
     $this->assertEquals(new IntColumn('foo', 'mediumint'), Column::mediumint('foo'));
     $this->assertEquals(new IntColumn('foo', 'bigint'), Column::bigint('foo'));
     $this->assertEquals((new IntColumn('foo', 'tinyint'))->setUnsigned()->setAutoIncrement(), Column::tinyserial('foo'));
     $this->assertEquals((new IntColumn('foo', 'smallint'))->setUnsigned()->setAutoIncrement(), Column::smallserial('foo'));
     $this->assertEquals((new IntColumn('foo', 'int'))->setUnsigned()->setAutoIncrement(), Column::serial('foo'));
     $this->assertEquals((new IntColumn('foo', 'mediumint'))->setUnsigned()->setAutoIncrement(), Column::mediumserial('foo'));
     $this->assertEquals((new IntColumn('foo', 'bigint'))->setUnsigned()->setAutoIncrement(), Column::bigserial('foo'));
     // text
     $this->assertEquals(new TextColumn('foo', 'tinytext'), Column::tinytext('foo'));
     $this->assertEquals(new TextColumn('foo', 'text'), Column::text('foo'));
     $this->assertEquals(new TextColumn('foo', 'mediumtext'), Column::mediumtext('foo'));
     $this->assertEquals(new TextColumn('foo', 'longtext'), Column::longtext('foo'));
     // timestamp
     $this->assertEquals(new TimestampColumn('foo'), Column::timestamp('foo'));
 }
<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
Admin::model('App\\Models\\Sector')->title('Sectors')->alias('sector')->display(function () {
    $display = AdminDisplay::datatablesAsync();
    $display->order([[0, 'asc']]);
    $display->columns([Column::string('id')->label('Id'), Column::string('name')->label('Name'), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created'), Column::datetime('updated_at')->format('d-m-Y h:i:s')->label('Updated')]);
    $display->columnFilters([null, ColumnFilter::text()->placeholder('Name'), ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date')), ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date'))]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('name', 'Name')->required()]);
    return $form;
});
示例#3
0
文件: Post.php 项目: stcoder/uf-vova
        $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;
});
示例#4
0
<?php

Admin::model('App\\Directions')->title('Направления')->display(function () {
    $display = AdminDisplay::table();
    $display->columns([Column::string('name')->label('Название'), Column::datetime('created_at')->label('Дата создания'), Column::datetime('updated_at')->label('Дата изменения')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::columns()->columns([[FormItem::text('name', 'Название'), FormItem::ckeditor('desc', 'Описание'), FormItem::ckeditor('desc_detail', 'Описание'), FormItem::text('video', 'Видео')], [FormItem::images('images', 'Картинки')]])]);
    return $form;
});
<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
Admin::model('App\\Models\\Webpage')->title('Webpages')->alias('webpage')->display(function () {
    $display = AdminDisplay::datatablesAsync();
    $display->order([[4, 'desc']]);
    $display->columns([Column::string('host')->label('Domain'), Column::string('path')->label('Path'), Column::custom()->label('Evaluations')->callback(function ($instance) {
        return $instance->evaluations()->count();
    }), Column::custom()->label('Enabled')->callback(function ($instance) {
        return $instance->is_enabled ? '&check;' : '&cross;';
    }), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created')]);
    $display->columnFilters([ColumnFilter::text()->placeholder('Domain'), ColumnFilter::text()->placeholder('Path'), null, null, ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date'))]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::checkbox('is_enabled', 'Enabled'), FormItem::text('url', 'URL')->required(), FormItem::ckeditor('description', 'Description')]);
    return $form;
})->delete(null);
示例#6
0
<?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;
});
示例#7
0
<?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);
示例#8
0
<?php

/** @var \SleepingOwl\Admin\Model\ModelConfiguration $model */
$model = Admin::model(\App\HistoryEvent::class);
$model->title('История – события');
$model->display(function () {
    $display = AdminDisplay::datatables();
    $display->with('date');
    $display->columns([Column::checkbox(), Column::string('date.title')->label('Дата'), Column::custom()->label('Заголовок')->callback(function ($instance) {
        $res = $instance->title;
        if ($instance->more) {
            $res .= '<br><div class="label label-primary">Кнопка – подробней</div>';
        }
        return $res;
    }), Column::datetime('date_event')->format('d.m.Y')->label('Точная дата события'), Column::datetime('created_at')->label('Создан')->format('d.m.Y в H:i')]);
    $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', 'Заголовок'), FormItem::image('image', 'Картинка'), FormItem::select('history_date_id', 'Дата')->model(\App\HistoryDate::class)->display('title')->required(), FormItem::ckeditor('description', 'Описание')->required(), FormItem::date('date_event', 'Точная дата события'), FormItem::checkbox('more', 'Показать кнопку – подробней')]);
    return $form;
});
示例#9
0
<?php

Admin::model('App\\Models\\BlogPost')->title('Статьи блога')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with('user', 'statusName');
    $display->filters([]);
    $display->columns([Column::string('id')->label('Id'), Column::string('title')->label('Заголовок'), Column::datetime('created_at')->label('Создан')->format('d.m.Y H:i'), Column::string('user.first_name')->label('Автор'), Column::string('statusName.name')->label('Статус')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('title', 'Заголовок'), FormItem::image('img', 'Изображение'), FormItem::text('slug', 'Slug'), FormItem::select('user_id', 'Автор')->model('App\\User')->display('first_name')->defaultValue(1), FormItem::select('status', 'Статус')->model('App\\Models\\PostStatus')->display('name')->defaultValue(1), FormItem::text('metakey', 'Metakey'), FormItem::text('metadesc', 'Metadesc'), FormItem::ckeditor('text', 'Текст статьи'), FormItem::custom('newtags', 'sssssssssss')->display(function ($instance) {
        return view('admin.formitem_tags', ['instance' => $instance]);
    })->callback(function ($instance) {
        $instance->retag($_POST['newtags']);
    })]);
    return $form;
});
示例#10
0
<?php

Admin::model('Lanz\\Commentable\\Comment')->title('Комментарии')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with();
    $display->filters([]);
    $display->columns([Column::string('body')->label('Комментарий'), Column::datetime('created_at')]);
    return $display;
})->createAndEdit(function ($id) {
    if (is_null($id)) {
        return null;
    }
    $form = AdminForm::form();
    $form->items([FormItem::select('user_id', 'Автор')->model('App\\User')->display('first_name'), FormItem::ckeditor('body', 'Комментарий')]);
    return $form;
});
示例#11
0
<?php

/** @var \SleepingOwl\Admin\Model\ModelConfiguration $mdenu */
$model = Admin::model(\App\ScheduleAndCost::class);
$model->title('Блок расписание и стоимость');
$model->display(function () {
    $display = AdminDisplay::datatables();
    $display->columns([Column::string('title')->label('Заголовок')->orderable(false), Column::datetime('created_at')->label('Создан')->orderable(false), Column::order()->orderable(false)]);
    $display->apply(function (\Illuminate\Database\Eloquent\Builder $query) {
        $query->withTrashed();
        $query->orderBy('order', 'asc');
    });
    return $display;
})->createAndEdit(function ($id) use($model) {
    $model->title($id ? 'Редактировать блок' : 'Создать блок');
    $form = AdminForm::form();
    $form->items([FormItem::text('title'), FormItem::ckeditor('text')]);
    return $form;
});
示例#12
0
<?php

Admin::model('App\\Form')->title('Form Items')->display(function () {
    $display = AdminDisplay::table();
    $display->columns([Column::string('id')->label('ID'), Column::string('title')->label('String'), Column::datetime('created_at')->label('Created At')->format('d.m.Y H:i:s')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::columns()->columns([[FormItem::text('title', 'FormItem::text')->defaultValue('default value')->required(), FormItem::textaddon('textaddon', 'FormItem::textaddon')->addon('$')->placement('after'), FormItem::checkbox('checkbox', 'FormItem::checkbox'), FormItem::date('date', 'FormItem::date')->format('d.m.Y'), FormItem::time('time', 'FormItem::time')->format('H:i:s')->seconds(true), FormItem::timestamp('timestamp', 'FormItem::timestamp')->format('d.m.Y g:i A')], [FormItem::select('select', 'FormItem::select')->options([1 => 'First', 2 => 'Second', 3 => 'Third'])->nullable(), FormItem::custom()->display(function ($instance) {
        return view('custom_form_item', compact('instance'));
    })->callback(function ($instance) {
        $instance->custom = \Carbon\Carbon::now();
    })], [FormItem::image('image', 'FormItem::image'), FormItem::images('images', 'FormItem::images')]]), FormItem::columns()->columns([[FormItem::textarea('textarea', 'FormItem::textarea')], [FormItem::ckeditor('ckeditor', 'FormItem::ckeditor')]])]);
    return $form;
});
<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
Admin::model('App\\Models\\Evaluation')->title('Evaluations')->alias('evaluation')->display(function () {
    $display = AdminDisplay::datatablesAsync();
    $display->order([[7, 'desc']]);
    $display->columns([Column::string('member.first_name')->label('User'), Column::string('webpage.url')->label('Url'), Column::string('ip')->label('IP-address'), Column::string('device_type')->label('Type'), Column::string('browser')->label('Browser'), Column::string('platform')->label('Platform'), Column::string('device')->label('Device'), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created')]);
    $display->columnFilters([null, ColumnFilter::text()->placeholder('Url'), ColumnFilter::text()->placeholder('IP-address'), null, null, null, null, ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date'))]);
    return $display;
})->create(null)->edit(null)->createAndEdit(null)->delete(null);
示例#14
0
文件: Page.php 项目: stcoder/uf-vova
<?php

/**
 * @var \SleepingOwl\Admin\Model\ModelConfiguration
 */
$model = Admin::model(\App\Page::class);
$model->title('Страницы');
$model->display(function () {
    $display = AdminDisplay::datatables();
    $display->filters([Filter::field('id')->title(function ($value) {
        return 'Выбрана страница с идентификатором: ' . $value;
    })]);
    $display->columns([Column::string('title')->label('Заголовок'), Column::published('published')->label('Опубликован')->orderable(false), Column::datetime('created_at')->label('Создан')->format('d.m.Y в H:i')]);
    $display->columnFilters([null, ColumnFilter::select()->options(['нет' => 'Нет', 'да' => 'Да'])->filter_field('published')]);
    return $display;
})->createAndEdit(function ($id) use($model) {
    $model->title($id ? 'Редактировать страницу' : 'Создать страницу');
    $form = AdminForm::tabbed();
    $form->items(['Основное' => [FormItem::text('title', 'Заголовок')->required(), FormItem::checkbox('published', 'Опубликовать'), FormItem::ckeditor('content', 'Содержимое')], 'Мета данные' => [FormItem::textarea('meta_keywords', 'Ключевые слова')->rows(2), FormItem::textarea('meta_description', 'Описание страницы')->rows(4), FormItem::textarea('meta_others', 'Другая мета информация')->rows(7)]]);
    return $form;
});
<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
Admin::model('App\\Models\\Result')->title('Results')->alias('result')->display(function () {
    $display = AdminDisplay::datatablesAsync();
    $display->order([[7, 'desc']]);
    $display->columns([Column::string('evaluation.member.first_name')->label('User'), Column::string('evaluation.webpage.url')->label('Url'), Column::string('module')->label('Module'), Column::string('type')->label('Type'), Column::string('status')->label('Status'), Column::string('value')->label('Value'), Column::string('info')->label('Info'), Column::datetime('created_at')->format('d-m-Y h:i:s')->label('Created')]);
    return $display;
})->create(null)->edit(null)->createAndEdit(null)->delete(null);
示例#16
0
<?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);
示例#17
0
<?php

Admin::model('Angrydeer\\Productso\\Models\\PrsoProduct')->title('Товары')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with();
    $display->filters([]);
    $display->columns([Column::string('name')->label('Товар'), Column::string('id')->label('Id'), Column::string('show')->label('Включен'), Column::string('views')->label('Просмотры'), Column::datetime('created_at')->label('Создан')->format('d.m.Y')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('name', 'Товар')->required(), FormItem::text('cost', 'Цена'), FormItem::text('slug', 'Ярлык (если не заполнять генерируется автоматически)'), FormItem::text('status', 'Статус'), FormItem::text('artikul', 'Артикул'), FormItem::multiselect('categories', 'Категории')->model('Angrydeer\\Productso\\Models\\PrsoCategory')->display('name'), FormItem::text('views', 'Просмотры')->readonly(), FormItem::checkbox('show', 'Включен')->defaultValue(true), FormItem::ckeditor('note', 'Аннотация'), FormItem::ckeditor('description', 'Описание'), FormItem::multiimages('photos', 'Изображения')]);
    return $form;
});
示例#18
0
文件: Post.php 项目: kesha1/blog.loc
<?php

Admin::model(\App\Models\Post::class)->title('Блог')->display(function () {
    $display = AdminDisplay::datatables();
    $display->columns([Column::string('id')->label('#'), Column::string('title')->label('Заголовок'), Column::custom()->label('Опубликован')->callback(function ($instance) {
        return $instance->published ? 'Да' : 'Нет';
    }), Column::datetime('created_at')->label('Дата создания')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::columns()->columns([[FormItem::checkbox('published', 'Опубликован')->defaultValue(1), FormItem::text('title', 'Заголовок')->required(), FormItem::ckeditor('body', 'Текст')->required()]])]);
    return $form;
});
示例#19
0
<?php

Admin::model('App\\News4')->title('News')->alias('news4')->display(function () {
    $display = AdminDisplay::table();
    $display->filters([Filter::scope('last')->title('Latest News'), Filter::field('published')->title(function ($value) {
        return $value ? 'Published' : 'Not Published';
    }), Filter::custom('limit')->title(function ($value) {
        return 'Custom Filter: ' . $value;
    })->callback(function ($query, $value) {
        $query->limit($value);
    })]);
    $display->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 ? '&check;' : '-';
    })]);
    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;
});
示例#20
0
文件: Entry.php 项目: proudly/RefEng
<?php

Admin::model('App\\Models\\Entry')->title('Entries')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with();
    $display->filters([Filter::scope('published'), Filter::scope('unpublished')]);
    $display->columns([Column::string('title')->label('Title'), Column::string('content')->label('Content'), Column::datetime('published_at')->format('H:i d.m.Y')->label('Published At'), Column::custom()->label('Published')->callback(function ($instance) {
        return $instance->published ? '&check;' : '-';
    })]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('title', 'Title')->required(), FormItem::text('slug', 'Slug')->required(), FormItem::checkbox('published', 'Published'), FormItem::timestamp('published_at', 'Published At')->format('d.m.Y H:i:s')->seconds(true), FormItem::ckeditor('content', 'Content')->required()]);
    return $form;
});