Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

jxlwqq jxlwqq

🎯
Focusing
View GitHub Profile
@jxlwqq
jxlwqq / admin.php
Last active Feb 29, 2020
Create upload path based on current year and month
View admin.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Laravel-admin upload setting
|--------------------------------------------------------------------------
|
| File system configuration for form upload files and images, including
| disk and upload path.
|
@jxlwqq
jxlwqq / side.php
Last active Jun 26, 2020
Place Input Fields Side-by-Side
View side.php
<?php
protected function form()
{
$form = new Form(new ModelName);
$form->row(function ($row) {
$row->width(4)->text('email');
$row->width(4)->text('password');
$row->width(4)->text('password_confirmation');
});
@jxlwqq
jxlwqq / apiRoute.php
Last active Mar 4, 2019
Best practice for API route
View apiRoute.php
<?php
$form->select('user_id')->options(function ($id) {
$user = User::find($id);
if ($user) {
return [$user->id => $user->name];
}
})->ajax(admin_url('api/users')); # Best practice
# })->ajax('/admin/api/users'); # Strongly not recommended
@jxlwqq
jxlwqq / verification.php
Last active Feb 29, 2020
Input verification on front and back ends
View verification.php
<?php
protected function form()
{
$form = new Form(new ModelName);
$form->text('title')->rules('required')->required()->help('This field must be required');
$form->text('number')->rules('required|regex:/\d{3}/')->pattern('\d{3}')->help('This field must be three digits');
return $form;
}
You can’t perform that action at this time.