Example #1
0
Admin::model(\App\Models\AddonsType::class)->title('Addons Types')->denyEditingAndDeleting(function ($instance) {
    return false;
})->columns(function () {
    Column::string('id', 'Id');
    Column::string('code', 'Code')->inlineEdit(true);
    Column::string('name', 'Name')->inlineEdit(true);
})->inlineEdit(function ($field) {
    switch ($field) {
        case 'code':
            return function () {
                InlineEditItem::text('code', NULL)->validationRule('required');
            };
            break;
        case 'name':
            return function () {
                InlineEditItem::text('name', NULL)->validationRule('required');
            };
            break;
        default:
            return function () {
            };
            break;
    }
})->form(function () {
    FormItem::text('code', 'Code')->validationRule('required');
    FormItem::text('name', 'Name')->validationRule('required');
})->viewFilters(function () {
    ViewFilter::text('code', 'Code');
    ViewFilter::text('name', 'Name');
});
Example #2
0
    Column::string('zip_code', 'Zip Code')->inlineEdit(true);
})->inlineEdit(function ($field) {
    switch ($field) {
        case 'country':
            return function () {
                InlineEditItem::text('country', NULL)->validationRule('required|alpha');
            };
            break;
        case 'city':
            return function () {
                InlineEditItem::text('city', NULL)->validationRule('required|alpha');
            };
            break;
        case 'zip_code':
            return function () {
                InlineEditItem::text('zip_code', NULL);
                //                        ->validationRule('required|regex:^\d{5}(?:[-\s]\d{4})?$');
            };
            break;
        default:
            return function () {
            };
            break;
    }
})->form(function () {
    FormItem::select('customer_id', 'Customer')->list(Models\Customer::class)->validationRule('required|numeric|exists:customers,id');
    FormItem::text('country', 'Country')->validationRule('required|alpha');
    FormItem::text('city', 'City')->validationRule('required|alpha');
    FormItem::text('phone', 'Phone')->validationRule('required');
    FormItem::text('zip_code', 'Zip Code')->validationRule('required');
    FormItem::text('street', 'Street')->validationRule('required');
Example #3
0
<?php

Admin::model(\App\Models\Administrator::class)->title('Administrators')->denyDeleting(function ($instance) {
    return true;
})->columns(function () {
    Column::string('id', 'Id');
    Column::string('username', 'Login');
    Column::string('name', 'Name')->inlineEdit(true);
})->inlineEdit(function ($field) {
    switch ($field) {
        case 'name':
            return function () {
                InlineEditItem::text('name', NULL)->validationRule('required|regex:/^[a-zA-Z0-9_@]{3,20}$/');
            };
            break;
        default:
            return function () {
            };
            break;
    }
})->form(function () {
    // Describing elements in create and editing forms
    FormItem::text('username', 'Login')->validationRule('required|regex:/^[a-zA-Z0-9_@]{3,20}$/');
    FormItem::text('name', 'Name')->validationRule('required|regex:/^[a-zA-Z0-9_\\s@]{3,20}$/');
    $data = Input::all();
    if (preg_match('/edit$/', Request::url()) || isset($data['_method']) && $data['_method'] == 'PUT') {
        // ok this is update statement, so let's rock
        FormItem::checkbox('changePassword', 'Change Password');
        if (isset($data['changePassword']) && $data['changePassword'] == 1) {
            FormItem::text('passwd', 'Password')->validationRule('required|regex:/^[a-zA-Z0-9_@]{6,20}$/');
            FormItem::text('passwdConfirm', 'Password Confirmation')->validationRule('required|same:passwd');
Example #4
0
    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;
        default:
            return function () {
            };
            break;
    }
})->form(function () {
    FormItem::select('customer_id', 'Customer')->list(Models\Customer::class)->validationRule('required|numeric|exists:customers,id')->group('general');
    FormItem::select('orders_status_id', 'Status')->list(Models\OrdersStatus::class)->validationRule('required|numeric|exists:orders_statuses,id')->group('general');
    FormItem::text('total', 'Total')->validationRule('required|numeric|min:1')->group('general');
    FormItem::items('items', 'Items')->group('items');
    FormGroup::create('general', 'General')->setDisplayType(FormGroup::DISPLAY_TYPE_FULL);
    FormGroup::create('items', 'Items')->setDisplayType(FormGroup::DISPLAY_TYPE_FULL);
})->viewFilters(function () {
Example #5
0
    Column::string('id', 'Id');
    Column::string('code', 'Code')->inlineEdit(true);
    Column::callback('name', 'Name')->contentCallback(function ($instance) {
        return $instance->getName();
    })->inlineEdit(true);
    Column::boolean('default', 'Default');
})->inlineEdit(function ($field) {
    switch ($field) {
        case 'code':
            return function () {
                InlineEditItem::text('code', NULL)->validationRule('required');
            };
            break;
        case 'name':
            return function () {
                InlineEditItem::callback('name', '')->callback(function ($instance) {
                    $content = '';
                    foreach (Models\Language::get() as $language) {
                        $value = '';
                        $descriptions = $instance->descriptions->where('language_id', $language->id)->first();
                        if (!is_null($descriptions)) {
                            $value = $descriptions->name;
                        }
                        $content .= HtmlBuilder::text('name_' . $language->id, 'Name [' . $language->code . ']', $value, ['data-parsley-required' => true]);
                    }
                    return $content;
                });
            };
            break;
        default:
            return function () {
Example #6
0
    Column::string('id', 'Id');
    Column::string('width', 'Width')->inlineEdit(true);
    Column::string('height', 'Height')->inlineEdit(true);
    Column::string('price', 'Price')->inlineEdit(true);
})->inlineEdit(function ($field) {
    switch ($field) {
        case 'width':
            return function () {
                InlineEditItem::text('width', NULL)->validationRule('required|regex:\\d');
            };
            break;
        case 'height':
            return function () {
                InlineEditItem::text('height', NULL)->validationRule('required|regex:\\d');
            };
            break;
        case 'price':
            return function () {
                InlineEditItem::text('price', NULL)->validationRule('required|regex:\\d');
            };
            break;
        default:
            return function () {
            };
            break;
    }
})->form(function () {
    FormItem::text('width', 'Width')->validationRule('required|numeric');
    FormItem::text('height', 'Height')->validationRule('required|numeric');
    FormItem::text('price', 'Price')->validationRule('required|numeric');
});