首次提交 Laravel 專案
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BladeInjectionConfiguration" default="false">
|
||||
<directives>
|
||||
<data directive="@append" />
|
||||
<data directive="@auth" injection="true" prefix="<?php if(auth()->guard(" suffix=")->check()): ?>" />
|
||||
<data directive="@aware" injection="true" prefix="<?php $attributes = $attributes->exceptProps(" suffix="); ?>" />
|
||||
<data directive="@break" injection="true" prefix="<?php if(" suffix=") break; ?>" />
|
||||
<data directive="@can" injection="true" prefix="<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check(" suffix=")): ?>" />
|
||||
<data directive="@canany" injection="true" prefix="<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->any(" suffix=")): ?>" />
|
||||
<data directive="@cannot" injection="true" prefix="<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->denies(" suffix=")): ?>" />
|
||||
<data directive="@case" injection="true" prefix="<?php case (" suffix="): ?>" />
|
||||
<data directive="@checked" injection="true" prefix="<?php if(" suffix=") {echo 'checked';}?>" />
|
||||
<data directive="@choice" injection="true" prefix="<?php echo app('translator')->choice(" suffix="); ?>" />
|
||||
<data directive="@class" injection="true" prefix="class="<?php echo \Illuminate\Support\Arr::toCssClasses(" suffix=")?>"" />
|
||||
<data directive="@component" injection="true" prefix="<?php $__env->startComponent(" suffix="); ?>" />
|
||||
<data directive="@componentfirst" injection="true" prefix="<?php $__env->startComponentFirst(" suffix="); ?>" />
|
||||
<data directive="@continue" injection="true" prefix="<?php if(" suffix=") continue; ?>" />
|
||||
<data directive="@csrf" />
|
||||
<data directive="@dd" injection="true" prefix="<?php dd(" suffix="); ?>" />
|
||||
<data directive="@default" />
|
||||
<data directive="@disabled" injection="true" prefix="<?php if(" suffix=") {echo 'disabled';}?>" />
|
||||
<data directive="@dump" injection="true" prefix="<?php dump(" suffix="); ?>" />
|
||||
<data directive="@each" injection="true" prefix="<?php echo $__env->renderEach(" suffix="); ?>" />
|
||||
<data directive="@else" />
|
||||
<data directive="@elseauth" injection="true" prefix="<?php elseif(auth()->guard(" suffix=")->check()): ?>" />
|
||||
<data directive="@elsecan" injection="true" prefix="<?php elseif (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check(" suffix=")): ?>" />
|
||||
<data directive="@elsecanany" injection="true" prefix="<?php elseif (app(\Illuminate\Contracts\Auth\Access\Gate::class)->any(" suffix=")): ?>" />
|
||||
<data directive="@elsecannot" injection="true" prefix="<?php elseif (app(\Illuminate\Contracts\Auth\Access\Gate::class)->denies(" suffix=")): ?>" />
|
||||
<data directive="@elseguest" injection="true" prefix="<?php elseif(auth()->guard(" suffix=")->guest()): ?>" />
|
||||
<data directive="@elseif" injection="true" prefix="<?php elseif(" suffix="): ?>" />
|
||||
<data directive="@empty" injection="true" prefix="<?php if(empty(" suffix=")): ?>" />
|
||||
<data directive="@endauth" />
|
||||
<data directive="@endcan" />
|
||||
<data directive="@endcanany" />
|
||||
<data directive="@endcannot" />
|
||||
<data directive="@endcomponent" />
|
||||
<data directive="@endcomponentClass" />
|
||||
<data directive="@endcomponentfirst" />
|
||||
<data directive="@endempty" />
|
||||
<data directive="@endenv" />
|
||||
<data directive="@enderror" />
|
||||
<data directive="@endfor" />
|
||||
<data directive="@endforeach" />
|
||||
<data directive="@endforelse" />
|
||||
<data directive="@endfragment" />
|
||||
<data directive="@endguest" />
|
||||
<data directive="@endif" />
|
||||
<data directive="@endisset" />
|
||||
<data directive="@endlang" />
|
||||
<data directive="@endonce" />
|
||||
<data directive="@endphp" />
|
||||
<data directive="@endprepend" />
|
||||
<data directive="@endprependonce" />
|
||||
<data directive="@endproduction" />
|
||||
<data directive="@endpush" />
|
||||
<data directive="@endpushif" />
|
||||
<data directive="@endpushonce" />
|
||||
<data directive="@endsection" />
|
||||
<data directive="@endsession" />
|
||||
<data directive="@endslot" />
|
||||
<data directive="@endswitch" />
|
||||
<data directive="@endunless" />
|
||||
<data directive="@endverbatim" />
|
||||
<data directive="@endwhile" />
|
||||
<data directive="@env" injection="true" prefix="<?php if(app()->environment(" suffix=")): ?>" />
|
||||
<data directive="@error" injection="true" prefix="<?php $__errorArgs = [" suffix="]; $__bag = $errors->getBag($__errorArgs[1] ?? 'default'); if ($__bag->has($__errorArgs[0])) : if (isset($message)) { $__messageOriginal = $message; } $message = $__bag->first($__errorArgs[0]); ?>" />
|
||||
<data directive="@extends" injection="true" prefix="<?php echo $__env->make(" suffix=", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>" />
|
||||
<data directive="@extendsfirst" injection="true" prefix="<?php echo $__env->first(" suffix=", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>" />
|
||||
<data directive="@for" injection="true" prefix="<?php for(" suffix="): ?>" />
|
||||
<data directive="@foreach" injection="true" prefix="<?php foreach(" suffix="): ?>" />
|
||||
<data directive="@forelse" injection="true" prefix="<?php foreach(" suffix="): ?>" />
|
||||
<data directive="@fragment" injection="true" prefix="<?php $__env->startFragment(" suffix="); ?>" />
|
||||
<data directive="@guest" injection="true" prefix="<?php if(auth()->guard(" suffix=")->guest()): ?>" />
|
||||
<data directive="@hasSection" injection="true" prefix="<?php if (! empty(trim($__env->yieldContent(" suffix=")))): ?>" />
|
||||
<data directive="@if" injection="true" prefix="<?php if(" suffix="): ?>" />
|
||||
<data directive="@include" injection="true" prefix="<?php echo $__env->make(" suffix=", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>" />
|
||||
<data directive="@includeFirst" injection="true" prefix="<?php echo $__env->first(" suffix=", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>" />
|
||||
<data directive="@includeUnless" injection="true" prefix="<?php echo $__env->renderUnless(" suffix=", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path'])); ?>" />
|
||||
<data directive="@includeWhen" injection="true" prefix="<?php echo $__env->renderWhen(" suffix=", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path'])); ?>" />
|
||||
<data directive="@isset" injection="true" prefix="<?php if(isset(" suffix=")): ?>" />
|
||||
<data directive="@js" injection="true" prefix="<?php _bladeDirective(" suffix="); ?>" />
|
||||
<data directive="@json" injection="true" prefix="<?php echo json_encode(" suffix=") ?>" />
|
||||
<data directive="@lang" injection="true" prefix="<?php echo app('translator')->get(" suffix="); ?>" />
|
||||
<data directive="@method" injection="true" prefix="<?php echo method_field(" suffix="); ?>" />
|
||||
<data directive="@once" />
|
||||
<data directive="@overwrite" />
|
||||
<data directive="@parent" />
|
||||
<data directive="@php" injection="true" prefix="<?php (" suffix="); ?>" />
|
||||
<data directive="@prepend" injection="true" prefix="<?php $__env->startPrepend(" suffix="); ?>" />
|
||||
<data directive="@prependonce" injection="true" prefix="<?php $___phpstorm_prepend_once_params = [" suffix="]; if (! $__env->hasRenderedOnce($___phpstorm_prepend_once_params[1])): $__env->markAsRenderedOnce($___phpstorm_prepend_once_params); $__env->startPrepend($___phpstorm_prepend_once_params[0]); ?>" />
|
||||
<data directive="@production" />
|
||||
<data directive="@props" injection="true" prefix="<?php $attributes = $attributes->exceptProps(" suffix="); ?>" />
|
||||
<data directive="@push" injection="true" prefix="<?php $__env->startPush(" suffix="); ?>" />
|
||||
<data directive="@pushif" injection="true" prefix="<?php $__pushif_args = explode(','," suffix=", 2); if({$__pushif_args[0]}): $__env->startPush({$__pushif_args[1]}); ?>" />
|
||||
<data directive="@pushonce" injection="true" prefix="<?php $__php_storm_push_once_params = [" suffix="]; if (!$__env->hasRenderedOnce($__php_storm_push_once_params[1])): $__env->markAsRenderedOnce($__php_storm_push_once_params[1]); $__env->startPush($__php_storm_push_once_params[0]); ?>" />
|
||||
<data directive="@readonly" injection="true" prefix="<?php if(" suffix="): echo 'readonly'; endif; ?>" />
|
||||
<data directive="@required" injection="true" prefix="<?php if(" suffix="): echo 'required'; endif; ?>" />
|
||||
<data directive="@section" injection="true" prefix="<?php $__env->startSection(" suffix="); ?>" />
|
||||
<data directive="@sectionMissing" injection="true" prefix="<?php if (empty(trim($__env->yieldContent(" suffix=")))): ?>" />
|
||||
<data directive="@selected" injection="true" prefix="<?php if(" suffix=") {echo 'selected';}?>" />
|
||||
<data directive="@session" injection="true" prefix="<?php $value = session()->get(" suffix=")?>"" />
|
||||
<data directive="@show" />
|
||||
<data directive="@slot" injection="true" prefix="<?php $__env->slot(" suffix="); ?>" />
|
||||
<data directive="@stack" injection="true" prefix="<?php echo $__env->yieldPushContent(" suffix="); ?>" />
|
||||
<data directive="@stop" />
|
||||
<data directive="@style" injection="true" prefix="class="<?php echo \Illuminate\Support\Arr::toCssStyles(" suffix=")?>"" />
|
||||
<data directive="@switch" injection="true" prefix="<?php switch(" suffix="): ?>" />
|
||||
<data directive="@unless" injection="true" prefix="<?php if (! (" suffix=")): ?>" />
|
||||
<data directive="@unset" injection="true" prefix="<?php unset(" suffix="); ?>" />
|
||||
<data directive="@verbatim" />
|
||||
<data directive="@vite" injection="true" prefix="<?php echo vite_func(" suffix="); ?>" />
|
||||
<data directive="@viteReactRefresh" />
|
||||
<data directive="@vitereactrefresh" />
|
||||
<data directive="@while" injection="true" prefix="<?php while(" suffix="): ?>" />
|
||||
<data directive="@yield" injection="true" prefix="<?php echo $__env->yieldContent(" suffix="); ?>" />
|
||||
</directives>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
class tg_group_users extends Model
|
||||
{
|
||||
protected $table = 'tg_group_users';
|
||||
|
||||
// 可批量赋值字段
|
||||
protected $fillable = [
|
||||
'chat_id',
|
||||
'user_id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'username',
|
||||
'status',
|
||||
'is_bot',
|
||||
'language_code',
|
||||
'raw_data',
|
||||
];
|
||||
|
||||
// Telegram status 常量定义
|
||||
public const STATUS_CREATOR = 'creator'; // 群主
|
||||
public const STATUS_ADMINISTRATOR = 'administrator'; // 管理员
|
||||
public const STATUS_MEMBER = 'member'; // 普通成员
|
||||
public const STATUS_RESTRICTED = 'restricted'; // 被限制的成员
|
||||
public const STATUS_LEFT = 'left'; // 已离开
|
||||
public const STATUS_KICKED = 'kicked'; // 被踢出
|
||||
|
||||
// 可选:提供一个状态中文对照表(静态方法)
|
||||
public static function statusLabel(string $status): string
|
||||
{
|
||||
return match ($status) {
|
||||
self::STATUS_CREATOR => '群主',
|
||||
self::STATUS_ADMINISTRATOR => '管理员',
|
||||
self::STATUS_MEMBER => '成员',
|
||||
self::STATUS_RESTRICTED => '受限成员',
|
||||
self::STATUS_LEFT => '已离开',
|
||||
self::STATUS_KICKED => '被踢出',
|
||||
default => '未知',
|
||||
};
|
||||
}
|
||||
|
||||
public static function updateOrCreateFromTelegram(array $chatMemberData, int|string $chatId): self
|
||||
{
|
||||
$user = $chatMemberData['user'] ?? null;
|
||||
|
||||
if (!$user || !isset($chatMemberData['status'])) {
|
||||
throw new \InvalidArgumentException('无效的 Telegram ChatMember 数据结构');
|
||||
}
|
||||
|
||||
return self::updateOrCreate(
|
||||
[
|
||||
'chat_id' => $chatId,
|
||||
'user_id' => $user['id'],
|
||||
],
|
||||
[
|
||||
'first_name' => $user['first_name'] ?? null,
|
||||
'last_name' => $user['last_name'] ?? null,
|
||||
'username' => $user['username'] ?? null,
|
||||
'status' => $chatMemberData['status'],
|
||||
'is_bot' => $user['is_bot'] ?? false,
|
||||
'language_code' => $user['language_code'] ?? null,
|
||||
'raw_data' => json_encode($chatMemberData, JSON_UNESCAPED_UNICODE),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user