Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
none committed Jul 19, 2023
2 parents b3dc938 + 24624a2 commit 2810c11
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 33 deletions.
6 changes: 5 additions & 1 deletion app/Businesses/BusinessState.php
Expand Up @@ -115,8 +115,12 @@ public function promoCodeCanUse(int $loginUserId, array $promoCode): bool
if ($promoCode['user_id'] === $loginUserId) {
return false;
}
// 使用次数已用完
if ($promoCode['use_times'] > 0 && $promoCode['use_times'] - $promoCode['used_times'] <= 0) {
// 使用次数已用完
return false;
}
// 是否过期
if ($promoCode['expired_at'] && Carbon::now()->gt($promoCode['expired_at'])) {
return false;
}
/**
Expand Down
Expand Up @@ -9,6 +9,7 @@
namespace App\Http\Controllers\Backend\Api\V1;

use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Models\AdministratorLog;
use App\Models\AdministratorRole;
Expand Down Expand Up @@ -48,6 +49,7 @@ public function store(
AdministratorRole $role
) {
$data = $request->filldata();
$data['slug'] = Str::random(16);
$permissionIds = $request->input('permission_ids', []);

$role->fill($data)->save();
Expand Down Expand Up @@ -87,8 +89,8 @@ public function update(AdministratorRoleRequest $request, $id)
AdministratorLog::storeLogDiff(
AdministratorLog::MODULE_ADMINISTRATOR_ROLE,
AdministratorLog::OPT_UPDATE,
Arr::only(array_merge($data, ['permission_ids' => $permissionIds]), ['display_name', 'slug', 'description', 'permission_ids']),
Arr::only(array_merge($role->toArray(), ['permission_id' => $oldPermissionIds]), ['display_name', 'slug', 'description', 'permission_ids'])
Arr::only(array_merge($data, ['permission_ids' => $permissionIds]), ['display_name', 'description', 'permission_ids']),
Arr::only(array_merge($role->toArray(), ['permission_id' => $oldPermissionIds]), ['display_name', 'description', 'permission_ids'])
);

$role->fill($data)->save();
Expand Down
Expand Up @@ -136,7 +136,7 @@ public function graph(Request $request)

$startAt = Carbon::parse($startAt)->format('Y-m-d');

$endAt = Carbon::parse($endAt)->format('Y-m-d');
$endAt = Carbon::parse($endAt)->format('Y-m-d') . ' 23:59:59';
$endAtCarbon = Carbon::parse($endAt);

// 每日注册学员数量统计
Expand Down
16 changes: 14 additions & 2 deletions app/Http/Controllers/Backend/Api/V1/NavController.php
Expand Up @@ -23,17 +23,29 @@ public function index(Request $request)
$platform = $request->input('platform');

$navs = Nav::query()
->with(['children'])
->select([
'id', 'sort', 'name', 'url', 'active_routes', 'platform', 'parent_id',
'blank', 'created_at', 'updated_at',
])
->with(['children'])
->when($platform, function ($query) use ($platform) {
$query->where('platform', $platform);
})
->where('parent_id', 0)
->orderBy('sort')
->get();
->get()
->toArray();

foreach ($navs as $key => $navItem) {
$children = $navItem['children'] ?? [];
if (!$children) {
continue;
}
usort($children, function ($a, $b) {
return $a['sort'] - $b['sort'];
});
$navs[$key]['children'] = $children;
}

AdministratorLog::storeLog(
AdministratorLog::MODULE_NAV,
Expand Down
28 changes: 2 additions & 26 deletions app/Http/Requests/Backend/AdministratorRoleRequest.php
Expand Up @@ -10,56 +10,32 @@

class AdministratorRoleRequest extends BaseRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
return [
'display_name' => 'required',
'description' => 'required',
];

if ($this->isMethod('post')) {
$rules['slug'] = 'required|unique:administrator_roles';
}

return $rules;
}

public function messages()
{
return [
'display_name.required' => __('请输入后台管理角色名'),
'slug.required' => __('请输入后台管理角色slug'),
'slug.unique' => __('后台管理角色slug已存在'),
'description.required' => __('请输入后台管理角色描述'),
];
}

public function filldata()
{
$data = [
return [
'display_name' => $this->input('display_name'),
'description' => $this->input('description'),
];

if ($this->isMethod('post')) {
$data['slug'] = $this->input('slug');
}

return $data;
}
}
15 changes: 14 additions & 1 deletion app/Services/Other/Services/NavService.php
Expand Up @@ -19,7 +19,7 @@ class NavService implements NavServiceInterface
*/
public function all($platform = ''): array
{
return Nav::query()
$navs = Nav::query()
->with(['children'])
->select(['id', 'sort', 'name', 'url', 'active_routes', 'platform', 'parent_id', 'blank'])
->when($platform, function ($query) use ($platform) {
Expand All @@ -29,5 +29,18 @@ public function all($platform = ''): array
->orderBy('sort')
->get()
->toArray();

foreach ($navs as $key => $navItem) {
$children = $navItem['children'] ?? [];
if (!$children) {
continue;
}
usort($children, function ($a, $b) {
return $a['sort'] - $b['sort'];
});
$navs[$key]['children'] = $children;
}

return $navs;
}
}
12 changes: 12 additions & 0 deletions database/seeders/AdministratorPermissionSeeder.php
Expand Up @@ -20,6 +20,18 @@ class AdministratorPermissionSeeder extends Seeder
public function run()
{
$permissions = [
// 主面板
[
'group_name' => '主面板',
'children' => [
[
'display_name' => '主面板',
'slug' => 'dashboard',
'method' => 'GET',
'url' => '(^dashboard$|^dashboard\/check$|^dashboard\/system\/info$|^dashboard\/graph$)',
],
],
],
// 录播课
[
'group_name' => '录播课',
Expand Down

0 comments on commit 2810c11

Please sign in to comment.