Exemplo n.º 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');
});
Exemplo n.º 2
0
Admin::model(\App\Models\Addon::class)->title('Addons')->denyEditingAndDeleting(function ($instance) {
    return false;
})->columns(function () {
    Column::string('id', 'Id');
    Column::string('name', 'Name')->inlineEdit(true);
    Column::string('type.name', 'Type');
    Column::string('price_type', 'Price Type');
    Column::string('price', 'Price');
})->inlineEdit(function ($field) {
    switch ($field) {
        case 'name':
            return function () {
                InlineEditItem::text('name', NULL)->validationRule('required');
            };
            break;
        default:
            return function () {
            };
            break;
    }
})->form(function () {
    FormItem::text('name', 'Name')->validationRule('required');
    FormItem::select('addons_type_id', 'Type')->list(Models\AddonsType::class)->required();
    FormItem::text('image', 'Image')->validationRule('required');
    FormItem::select('price_type', 'Price Type')->list(['price' => 'price', 'percent' => 'percent'])->required();
    FormItem::text('price', 'Price')->validationRule('required');
})->viewFilters(function () {
    ViewFilter::text('name', 'Name');
    ViewFilter::text('type.name', 'Type');
    ViewFilter::text('price_type', 'Price Type');
});
Exemplo n.º 3
0
            };
            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 () {
    ViewFilter::text('customer.login', 'Customer');
    ViewFilter::dropdown('orders_status_id', 'Status')->options(function () {
        $options = [['id' => '', 'name' => '- Status -']];
        return array_merge($options, App\Models\Repositories\OrdersStatusRepository::getOptionsList());
    });
});
Exemplo n.º 4
0
            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');
    FormItem::text('name', 'Name')->validationRule('required');
})->viewFilters(function () {
    ViewFilter::text('customer.name', 'Customer');
    ViewFilter::text('country', 'Country');
    ViewFilter::text('city', 'City');
    ViewFilter::text('zip_code', 'Zip Code');
});
Exemplo n.º 5
0
            };
            break;
        case 'last_name':
            return function () {
                InlineEditItem::text('last_name', NULL)->validationRule('required|regex:/^[a-zA-Z0-9_@]{3,100}$/');
            };
            break;
        default:
            return function () {
            };
            break;
    }
})->form(function () {
    FormItem::text('name', 'Name')->validationRule('required')->group('general');
    FormItem::text('second_name', 'Second Name')->validationRule('required')->group('general');
    FormItem::text('last_name', 'Last Name')->validationRule('required')->group('general');
    FormItem::email('email', 'Email')->validationRule('required|email')->group('general');
    FormItem::text('phone', 'Phone')->validationRule('required')->group('general');
    if (!preg_match('/edit$/', Request::url()) && !preg_match('/update$/', Request::url())) {
        FormItem::text('login', 'Login')->validationRule('required')->group('general');
        FormItem::text('password', 'Password')->validationRule('required')->group('general');
    }
    FormItem::images()->type('model')->modelMethod('photos')->group('photos');
    FormGroup::create('general', 'General')->setDisplayType(FormGroup::DISPLAY_TYPE_FULL);
    FormGroup::create('photos', 'Photos')->setDisplayType(FormGroup::DISPLAY_TYPE_FULL);
})->viewFilters(function () {
    ViewFilter::text('name', 'Name');
    ViewFilter::text('second_name', 'Second Name');
    ViewFilter::text('last_name', 'Last Name');
    ViewFilter::text('email', 'Email');
});