All checks were successful
Deploy preview (main_go) / deploy (push) Successful in 14s
- SHJ-9: 日次売上集計処理 - SHJ-10: 年次月次売上集計処理 - SHJ-6: サーバ死活監視処理 - 各種モデルサービスコマンド追加 - earnings_summary, device, hardware_check_log, print_job_log テーブル用SQL追加
58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
||
|
||
namespace App\Services;
|
||
|
||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||
|
||
/**
|
||
* 利用者取得サービス
|
||
* - 旧テーブル互換のまま、画面用の取得口を一本化する
|
||
*/
|
||
class UserService
|
||
{
|
||
/**
|
||
* ユーザーSEQで1件取得(旧互換)
|
||
*/
|
||
public function findBySeq(int $userSeq): ?object
|
||
{
|
||
return \App\Legacy\User::find($userSeq);
|
||
}
|
||
|
||
/**
|
||
* 画面検索条件でページング(旧User::searchの最小互換)
|
||
*/
|
||
public function paginate(array $inputs): LengthAwarePaginator
|
||
{
|
||
$query = \App\Legacy\User::query();
|
||
|
||
if (!empty($inputs['user_id'])) {
|
||
$query->where('user_id', 'like', '%'.$inputs['user_id'].'%');
|
||
}
|
||
if (!empty($inputs['member_id'])) {
|
||
$query->where('member_id', 'like', '%'.$inputs['member_id'].'%');
|
||
}
|
||
if (!empty($inputs['user_tag_serial'])) {
|
||
$query->where('user_tag_serial', 'like', '%'.$inputs['user_tag_serial'].'%');
|
||
}
|
||
if (!empty($inputs['user_phonetic'])) {
|
||
$query->where('user_phonetic', 'like', '%'.$inputs['user_phonetic'].'%');
|
||
}
|
||
if (!empty($inputs['phone'])) {
|
||
$phone = $inputs['phone'];
|
||
$query->where(function ($q) use ($phone) {
|
||
$q->where('user_mobile', 'like', '%'.$phone.'%')
|
||
->orWhere('user_homephone', 'like', '%'.$phone.'%');
|
||
});
|
||
}
|
||
|
||
$sort = $inputs['sort'] ?? 'user_seq';
|
||
$dir = $inputs['sort_type'] ?? 'desc';
|
||
|
||
return $query->orderBy($sort, $dir)->paginate(\App\Utils::item_per_page);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|