随笔分类 -  laravel

1 2 3 下一页
group by和union,Laravel分页
摘要:$res3 = DB::table('users') ->join('user_folow_boutiques', 'user_folow_boutiques.user_id', '=', 'users.id') ->join('boutique', 'boutique.id', '=', 'use 阅读全文
posted @ 2023-01-30 12:09 jzfan
laravel groupBy 分页
摘要:$model=DB::table('tablebname') ->where(function($query) use ($res){ $query->where('xx','xx'); }) ->selectRaw("area,from_unixtime(created_time,'%Y-%m-% 阅读全文
posted @ 2023-01-30 00:03 jzfan
laravel whereHas sum & addSelect sum
摘要:$users = User::select('id', 'username', 'coins', 'cut') ->when(request()->has('agent_tip_sum'), function ($q) { $q->whereHas('agentBoughts', function 阅读全文
posted @ 2022-01-24 17:17 jzfan
LaravelORM 中的 withSum , withAvg, withMax,withMin 的实现
摘要:Orm::withCount(['relation as relation_sum' =>function($query){ $query->select(DB::raw("sum(amount) as relationsum")); }]) 阅读全文
posted @ 2021-11-03 10:25 jzfan
无限极分类
摘要:class CategoryController extends Controller { public function index() { $rootCats = Category::where('parent_id', null)->get(); return $this->tree($rootCats); } priv... 阅读全文
posted @ 2019-10-04 21:55 jzfan
laravel order by
摘要:orderBy(\DB::Raw('case when avatar_id = 0 then 0 else 1 end')) Doctor::join('users', 'doctors.user_id', '=', 'users.id') ->with('user') ->withCount('services', 'notebooks') ->orderByDesc('notebooks_co 阅读全文
posted @ 2019-09-30 18:49 jzfan
laravel 编辑后跳转回分页
摘要:进入edit页面时将分页地址保存在session中,更新后跳转该地址 阅读全文
posted @ 2019-05-23 12:22 jzfan
前端token刷新并发处理
摘要:添加中间件,处理多个前端来的请求时,如果token需要刷新,先查看缓存,如果没有就在redis中做个标志位进行短期缓存,其他的请求发现缓存中的token,就不再刷新token了。这样就避免了重复刷新token的问题。 中间件代码 阅读全文
posted @ 2019-04-07 19:08 jzfan
api token
摘要:1. implement the registered() method in our RegisterController 2. User Generate Token 3. Just like the registration endpoint, we can edit the LoginCon 阅读全文
posted @ 2018-03-14 11:59 jzfan
How to fix Error: laravel.log could not be opened?
摘要:Never set a directory to 777. you should change directory ownership. so set your current user that you are logged in with as owner and the webserver u 阅读全文
posted @ 2018-02-17 22:53 jzfan
laravel 中文环境 配置
摘要:appservice boot 阅读全文
posted @ 2017-04-20 15:28 jzfan
Cors 跨域访问API
摘要:server()['HTTP_ORIGIN'] ?? false; if ($origin && in_array($origin, $domains)) { header('Access-control-Allow-Origin: ' . $origin); header('Access-control-Allow-Headers... 阅读全文
posted @ 2017-03-11 16:18 jzfan
多文件上传
摘要:$files = $request->allFiles(); foreach ($files as $file) { $fileName = uniqid() . ‘.’ . $file->getClientOriginalExtension(); $file->move(‘temp_test’, $fileName); } 阅读全文
posted @ 2017-03-10 16:24 jzfan
mockery
摘要:mockery 阅读全文
posted @ 2017-02-18 11:05 jzfan
Update Request
摘要:public function update(UpdateAppointmentRequest $request) { try { $data = array_filter($request->only(['user_id','status','note'])); $appointment = $this->appointment->findOrFai... 阅读全文
posted @ 2017-01-07 12:30 jzfan
mock the facade
摘要:mock the facade: 阅读全文
posted @ 2017-01-05 15:43 jzfan
protected $appends in Laravel
摘要:protected $appends = ['icon']; public function getIconAttribute(){ return Gravatar::src($this->email, 100).'&r=g&d=mm'; } 阅读全文
posted @ 2016-12-31 14:26 jzfan
手机号码验证规则
摘要:手机号码验证规则 扩展 阅读全文
posted @ 2016-12-29 16:43 jzfan
throw exception
摘要:Throw new CustomerException('Customer message'); // App\Exceptions\Handler.php public function render($request, Exception $e) { // 没有权限访问 if ($e instanceof ForbiddenExcep... 阅读全文
posted @ 2016-12-14 13:34 jzfan
laravel DB事物
摘要:public function store(Request $request, $id) { $externalAccount = ExternalAccounts::find($id); DB::beginTransaction(); try { $externalAccount->fund_nu 阅读全文
posted @ 2016-11-16 11:41 jzfan

1 2 3 下一页