Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

jxlwqq jxlwqq

🎯
Focusing
Block or report user

Report or block jxlwqq

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jxlwqq
jxlwqq / admin.php
Last active Dec 25, 2018
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 Apr 5, 2019
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 Jul 28, 2019
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.