Skip to content

Instantly share code, notes, and snippets.

View jxlwqq's full-sized avatar
🎯
Focusing

jxlwqq jxlwqq

🎯
Focusing
View GitHub Profile
@jxlwqq
jxlwqq / apiRoute.php
Last active March 4, 2019 11:07
Best practice for API route
<?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 / side.php
Last active June 26, 2020 13:17
Place Input Fields Side-by-Side
<?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 / Dockerfile
Last active October 27, 2021 07:51
多架构平台镜像构建
# syntax=docker/dockerfile:1
FROM --platform=$TARGETPLATFORM php:8.0-fpm
WORKDIR /app
COPY index.php /app
@jxlwqq
jxlwqq / Makefile
Created October 12, 2021 02:40
make proto
.PHONY: proto
proto:
@ if ! which protoc > /dev/null; then \
echo "error: protoc not installed" >&2; \
exit 1; \
fi
@ if ! which protoc-gen-go > /dev/null; then \
echo "error: protoc-gen-go not installed" >&2; \
exit 1; \
fi
@jxlwqq
jxlwqq / verification.php
Last active November 3, 2022 04:11
Input verification on front and back ends
<?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;
}
@jxlwqq
jxlwqq / admin.php
Last active June 3, 2023 19:05
Create upload path based on current year and month
<?php
return [
/*
|--------------------------------------------------------------------------
| Laravel-admin upload setting
|--------------------------------------------------------------------------
|
| File system configuration for form upload files and images, including
| disk and upload path.
|