mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
ptgen api point support parameter & default user
This commit is contained in:
@@ -57,6 +57,7 @@ class AttendanceRepository extends BaseRepository
|
||||
$attendance->update($update);
|
||||
}
|
||||
}
|
||||
$attendance->added_time = $now->toTimeString();
|
||||
$attendance->is_updated = $isUpdated;
|
||||
do_log("[FINAL_ATTENDANCE]: " . $attendance->toJson());
|
||||
return $attendance;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace App\Repositories;
|
||||
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\UnauthorizedException;
|
||||
|
||||
@@ -22,7 +23,7 @@ class AuthenticateRepository extends BaseRepository
|
||||
$user->checkIsNormal();
|
||||
$tokenName = __METHOD__ . __LINE__;
|
||||
$token = DB::transaction(function () use ($user, $tokenName) {
|
||||
$user->tokens()->delete();
|
||||
$user->update(['last_login' => Carbon::now()]);
|
||||
$tokenResult = $user->createToken($tokenName);
|
||||
return $tokenResult->plainTextToken;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\News;
|
||||
|
||||
class NewsRepository extends BaseRepository
|
||||
{
|
||||
public function getList(array $params)
|
||||
{
|
||||
$query = News::query()->with(['user']);
|
||||
if (!empty($params['userid'])) {
|
||||
$query->where('userid', $params['userid']);
|
||||
}
|
||||
list($sortField, $sortType) = $this->getSortFieldAndType($params);
|
||||
$query->orderBy($sortField, $sortType);
|
||||
return $query->paginate();
|
||||
}
|
||||
|
||||
public function store(array $params)
|
||||
{
|
||||
$model = News::query()->create($params);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function update(array $params, $id)
|
||||
{
|
||||
$model = News::query()->findOrFail($id);
|
||||
$model->update($params);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function getDetail($id)
|
||||
{
|
||||
$model = News::query()->findOrFail($id);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$model = News::query()->findOrFail($id);
|
||||
$result = $model->delete();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -80,17 +80,23 @@ class TorrentRepository extends BaseRepository
|
||||
});
|
||||
}
|
||||
|
||||
list($sortField, $sortType) = $this->getSortFieldAndType($params);
|
||||
$query->orderBy($sortField, $sortType);
|
||||
$query = $this->handleGetListSort($query, $params);
|
||||
|
||||
$with = ['user'];
|
||||
$torrents = $query->with($with)
|
||||
->orderBy('pos_state', 'desc')
|
||||
->orderBy('id', 'desc')
|
||||
->paginate();
|
||||
$torrents = $query->with($with)->paginate();
|
||||
return $torrents;
|
||||
}
|
||||
|
||||
private function handleGetListSort(Builder $query, array $params)
|
||||
{
|
||||
if (empty($params['sort_field']) && empty($params['sort_type'])) {
|
||||
//the default torrent list sort
|
||||
return $query->orderBy('pos_state', 'desc')->orderBy('id', 'desc');
|
||||
}
|
||||
list($sortField, $sortType) = $this->getSortFieldAndType($params);
|
||||
return $query->orderBy($sortField, $sortType);
|
||||
}
|
||||
|
||||
public function getSearchBox($id = null)
|
||||
{
|
||||
if (is_null($id)) {
|
||||
|
||||
Reference in New Issue
Block a user