コード例 #1
0
ファイル: Administrator.php プロジェクト: avilaj/ocsport
<?php

Admin::model('SleepingOwl\\AdminAuth\\Entities\\Administrator')->title('Administrators')->display(function () {
    $display = AdminDisplay::datatables();
    $display->order([[0, 'desc']]);
    $display->columns([Column::string('id')->label('ID'), Column::string('name')->label('Name'), Column::string('username')->label('Username')]);
    return $display;
})->createAndEdit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('username', 'Username'), FormItem::text('name', 'Name'), FormItem::custom()->display(function ($instance) {
        return view('form.password_field', ['instance' => $instance]);
    })->callback(function ($instance) {
        $instance->password = Input::get('password');
    })]);
    return $form;
});
コード例 #2
0
ファイル: BlogPost.php プロジェクト: AngryGantz/cms-cookbook
<?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;
});
コード例 #3
0
ファイル: User.php プロジェクト: larabox/larabox
            \Request::merge(['theme_sidebar_mini' => false]);
        } else {
            \Request::merge(['theme_sidebar_mini' => true]);
        }
        \SoaUserSetting::set('theme.sidebar_mini', \Request::input('theme_sidebar_mini'), $instance->id);
        \SoaUserSetting::save();
    }), FormItem::custom()->display(function ($instance) {
        $field_params = ['name' => 'theme.toggle_sidebar', 'lang' => null, 'label_size' => null, 'field_size' => null, 'label' => 'Toggle Sidebar', 'required_field' => false, 'value' => \SoaUserSetting::get('theme.toggle_sidebar', config('admintheme.toggle_sidebar'), $instance->id), 'help_text' => 'Toggle the left sidebar\'s state (open or collapse)'];
        return view(AdminTemplate::view('formitem.checkbox'), $field_params)->render();
    })->callback(function ($instance) {
        if (!\Request::has('theme_toggle_sidebar')) {
            \Request::merge(['theme_toggle_sidebar' => false]);
        } else {
            \Request::merge(['theme_toggle_sidebar' => true]);
        }
        \SoaUserSetting::set('theme.toggle_sidebar', \Request::input('theme_toggle_sidebar'), $instance->id);
        \SoaUserSetting::save();
    }), FormItem::custom()->display(function ($instance) {
        $field_params = ['name' => 'theme.sidebar_on_hover', 'lang' => null, 'label_size' => null, 'field_size' => null, 'label' => 'Sidebar on Hover', 'required_field' => false, 'value' => \SoaUserSetting::get('theme.sidebar_on_hover', config('admintheme.sidebar_on_hover'), $instance->id), 'help_text' => 'Let the sidebar mini expand on hover'];
        return view(AdminTemplate::view('formitem.checkbox'), $field_params)->render();
    })->callback(function ($instance) {
        if (!\Request::has('theme_sidebar_on_hover')) {
            \Request::merge(['theme_sidebar_on_hover' => false]);
        } else {
            \Request::merge(['theme_sidebar_on_hover' => true]);
        }
        \Setting::set('theme.sidebar_on_hover', \Request::input('theme_sidebar_on_hover'), $instance->id);
        \SoaUserSetting::save();
    })]]);
    return $form;
});
コード例 #4
0
<?php

/*
 * This is a simple example of the main features.
 * For full list see documentation.
 */
Admin::model('App\\Models\\License')->title('Licenses')->alias('license')->display(function () {
    $display = AdminDisplay::datatablesAsync();
    $display->order([[0, 'asc']]);
    $display->columns([Column::string('name')->label('Name'), Column::string('duration')->label('Duration'), Column::custom()->label('Enabled')->callback(function ($instance) {
        return $instance->is_enabled ? '&check;' : '-';
    }), Column::custom()->label('Payed version')->callback(function ($instance) {
        return $instance->needs_validation ? '&check;' : '-';
    }), 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([ColumnFilter::text()->placeholder('Name'), 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')), ColumnFilter::range()->from(ColumnFilter::date()->format('d.m.Y')->placeholder('From Date'))->to(ColumnFilter::date()->format('d.m.Y')->placeholder('To Date'))]);
    return $display;
})->edit(function () {
    $form = AdminForm::form();
    $form->items([FormItem::custom()->display(function ($instance) {
        return '<div class="form-group ">
                                <label for="key">Key</label><br/>
                                ' . $instance->key . '
                            </div>';
    }), FormItem::text('name', 'Name')->required(), FormItem::text('duration', 'Duration')->required(), FormItem::checkbox('is_enabled', 'Enabled'), FormItem::checkbox('needs_validation', 'Payed version'), FormItem::ckeditor('description', 'Description')]);
    return $form;
})->create(function () {
    $form = AdminForm::form();
    $form->items([FormItem::text('name', 'Name')->required(), FormItem::text('duration', 'Duration')->required(), FormItem::checkbox('is_enabled', 'Enabled'), FormItem::checkbox('needs_validation', 'Payed version'), FormItem::ckeditor('description', 'Description')]);
    return $form;
});
コード例 #5
0
ファイル: Form.php プロジェクト: ntamvl/admin-3-demo
<?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;
});
コード例 #6
0
ファイル: JetCmsModels.php プロジェクト: jetcms/models
    $form->ajax_validation(true);
    $form->items(array('Main' => array(FormItem::columns()->columns([[FormItem::text('title', 'Title')->validationRules('unique:pages,title,' . $id), FormItem::text('alias', 'Alias')->validationRules('unique:pages,alias,' . $id . ',id,context,' . Request::get('context', '')), FormItem::textarea('description', 'Description'), FormItem::chosen('tag', 'Tag')->model('App\\Tag')->display('lable')->multi(true)->nullable(), FormItem::icheckbox('active')->label('Active')->skin('flat')], [FormItem::bsselect('menu_id', 'Menu id')->options(App\Menu::getNestedList('level_lable'))->disableSort()->nullable(), FormItem::select('context', 'Context')->enum(config('jetcms.models.context')), FormItem::select('template', 'Template')->enum(config('jetcms.models.template.' . $model->context, []))->nullable()->disableSort(), FormItem::select('policies', 'Policies')->enum(config('jetcms.models.policies.' . $model->context, []))->nullable()->disableSort(), FormItem::bsselect('user_id', 'User')->model('App\\User')->display('email|id')->defaultValue(Sentinel::check()->id)->nullable(), FormItem::image('image', 'Image')]]), FormItem::images('gallery', 'Gallery')), 'Content' => [FormItem::ckeditor('content', 'Text')], 'Fields' => value(function () use($id, $model) {
        //if (!$model) {return array();}
        return [FormItem::custom()->display(function ($instance) use($model) {
            $str = null;
            foreach (config('jetcms.models.fields.' . $instance->context, array()) as $val) {
                $type = $val['type'];
                $input = FormItem::$type('field_array.' . $val['name'] . '', $val['lable']);
                $input->defaultValue($instance->field($val['name']));
                $str .= $input;
            }
            return $str;
        })->callback(function ($instance) {
            $instance->fieldArray = Request::input('field_array');
        })];
    }), 'Action' => [FormItem::custom()->display(function ($instance) {
        $str = null;
        foreach (config('jetcms.models.action.' . $instance->context, []) as $val) {
            $s = '<a class="btn btn-default btn-small" href="/' . config('admin.prefix') . '/' . $val['href'] . '">' . $val['lable'] . '</a> ';
            $s = str_replace(':id', $instance->id, $s);
            $str .= str_replace(':url', $instance->url, $s);
        }
        return $str;
    })]));
    return $form;
});
/**
 * Tags
 */
Admin::model('App\\Tag')->title('Tag')->alias('tags')->display(function () {
    $display = AdminDisplay::table();