新增 UsdtC2C Resource 与页面
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
|
||||
class Dashboard extends Page
|
||||
{
|
||||
protected static ?string $navigationLabel = '一路发收支记账后台'; // 左侧菜单显示
|
||||
protected static ?string $title = '控制台'; // 页面标题显示
|
||||
protected static ?string $slug = 'dashboard'; // URL 路径
|
||||
|
||||
protected static string $view = 'filament.pages.dashboard'; // 对应 Blade 文件
|
||||
|
||||
public static function getNavigationIcon(): string
|
||||
{
|
||||
return 'heroicon-o-home'; // 你可以换成你想要的图标
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
|
||||
class OtherFunctions extends Page
|
||||
{
|
||||
protected static ?int $navigationSort = 20;
|
||||
protected static ?string $title = '系统设置';
|
||||
protected static ?string $navigationLabel = '系统设置';
|
||||
protected static string $view = 'filament.pages.other-functions';
|
||||
|
||||
public static function getNavigationIcon(): string
|
||||
{
|
||||
return 'heroicon-o-cog'; // ✅ 自订你喜欢的图标,例如齿轮
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\LedgerResource\Pages;
|
||||
use App\Filament\Resources\LedgerResource\RelationManagers;
|
||||
use App\Models\Ledger;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class LedgerResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Ledger::class;
|
||||
protected static ?string $navigationLabel = '财务账本';
|
||||
protected static ?string $pluralLabel = '财务账本';
|
||||
protected static ?string $label = '账本';
|
||||
protected static ?string $navigationGroup = '财务管理';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->label('ID')->sortable(),
|
||||
Tables\Columns\TextColumn::make('chat_id')->label('群ID')->searchable(),
|
||||
Tables\Columns\TextColumn::make('user_id')->label('用户ID')->searchable(),
|
||||
Tables\Columns\TextColumn::make('type')->label('类型')->formatStateUsing(fn ($state) => $state === 0 ? '收入' : '支出')->sortable(),
|
||||
Tables\Columns\TextColumn::make('date')->label('记账时间')->dateTime()->sortable(),
|
||||
Tables\Columns\TextColumn::make('amount')->label('金额')->money('LAK')->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')->label('创建时间')->dateTime()->since(),
|
||||
Tables\Columns\TextColumn::make('updated_at')->label('更新时间')->dateTime()->since(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListLedgers::route('/'),
|
||||
'create' => Pages\CreateLedger::route('/create'),
|
||||
'edit' => Pages\EditLedger::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\LedgerResource\Pages;
|
||||
|
||||
use App\Filament\Resources\LedgerResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateLedger extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LedgerResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\LedgerResource\Pages;
|
||||
|
||||
use App\Filament\Resources\LedgerResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditLedger extends EditRecord
|
||||
{
|
||||
protected static string $resource = LedgerResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\LedgerResource\Pages;
|
||||
|
||||
use App\Filament\Resources\LedgerResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListLedgers extends ListRecords
|
||||
{
|
||||
protected static string $resource = LedgerResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\TgCommResource\Pages;
|
||||
use App\Filament\Resources\TgCommResource\RelationManagers;
|
||||
use App\Models\TgComm;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
// use Filament\Forms\Components\TextInput;
|
||||
// use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\{TextInput, Toggle, Section, Grid};
|
||||
|
||||
class TgCommResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TgComm::class;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static ?string $navigationLabel = '指令列表'; // 左侧菜单文字
|
||||
protected static ?int $navigationSort = 10;
|
||||
protected static ?string $pluralModelLabel = '指令列表'; // 页面标题
|
||||
protected static ?string $modelLabel = '指令';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form->schema([
|
||||
|
||||
Section::make('基本信息')->schema([
|
||||
Grid::make(2)->schema([
|
||||
TextInput::make('command')
|
||||
->label('指令内容')
|
||||
->required(),
|
||||
|
||||
TextInput::make('description')
|
||||
->label('指令用途'),
|
||||
]),
|
||||
|
||||
TextInput::make('action')
|
||||
->label('使用说明')
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
|
||||
Section::make('设置')->schema([
|
||||
Grid::make(3)->schema([
|
||||
Toggle::make('display')->label('显示在指令列表'),
|
||||
Toggle::make('manager')->label('管理员权限'),
|
||||
Toggle::make('valid')->label('启用'),
|
||||
]),
|
||||
]),
|
||||
|
||||
]);
|
||||
}
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')->label('ID'),
|
||||
TextColumn::make('command')->label('指令内容'),
|
||||
TextColumn::make('instructions')->label('指令说明'),
|
||||
TextColumn::make('memo')->label('使用说明'),
|
||||
TextColumn::make('dis_play')->label('列表显示'),
|
||||
TextColumn::make('manager')->label('管理权限'),
|
||||
TextColumn::make('valid')->label('停/启用'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTgComms::route('/'),
|
||||
'create' => Pages\CreateTgComm::route('/create'),
|
||||
'edit' => Pages\EditTgComm::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TgCommResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TgCommResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTgComm extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TgCommResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TgCommResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TgCommResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTgComm extends EditRecord
|
||||
{
|
||||
protected static string $resource = TgCommResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TgCommResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TgCommResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTgComms extends ListRecords
|
||||
{
|
||||
protected static string $resource = TgCommResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\UsdtC2cResource\Pages;
|
||||
use App\Filament\Resources\UsdtC2cResource\RelationManagers;
|
||||
use App\Models\UsdtC2c;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
|
||||
class UsdtC2cResource extends Resource
|
||||
{
|
||||
protected static ?string $model = UsdtC2c::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return '财务管理'; // ⚠️ 注意这要与其他项的 group 完全一致
|
||||
}
|
||||
|
||||
public static function getNavigationIcon(): string
|
||||
{
|
||||
return 'heroicon-o-currency-bangladeshi'; // 或自定义你喜欢的图示
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'USDT-LAK 记录';
|
||||
}
|
||||
|
||||
public static function getPluralLabel(): string
|
||||
{
|
||||
return 'USDT-LAK 记录';
|
||||
}
|
||||
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('Highest')->label('最高价'),
|
||||
TextColumn::make('Million')->label('200万成交价'),
|
||||
TextColumn::make('created_at')->label('时间')->dateTime(),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('created_at')
|
||||
->form([
|
||||
DatePicker::make('from'),
|
||||
DatePicker::make('until'),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
return $query
|
||||
->when($data['from'], fn ($q) => $q->where('created_at', '>=', $data['from']))
|
||||
->when($data['until'], fn ($q) => $q->where('created_at', '<=', $data['until']));
|
||||
}),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->defaultSort('Highest', 'desc'); // ✅ 放在这里才对
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListUsdtC2cs::route('/'),
|
||||
'create' => Pages\CreateUsdtC2c::route('/create'),
|
||||
'edit' => Pages\EditUsdtC2c::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\UsdtC2cResource\Pages;
|
||||
|
||||
use App\Filament\Resources\UsdtC2cResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUsdtC2c extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UsdtC2cResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\UsdtC2cResource\Pages;
|
||||
|
||||
use App\Filament\Resources\UsdtC2cResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUsdtC2c extends EditRecord
|
||||
{
|
||||
protected static string $resource = UsdtC2cResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\UsdtC2cResource\Pages;
|
||||
|
||||
use App\Filament\Resources\UsdtC2cResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUsdtC2cs extends ListRecords
|
||||
{
|
||||
protected static string $resource = UsdtC2cResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\UsdtC2c;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class BinanceController extends Controller
|
||||
{
|
||||
public function getMaxUsdtLak()
|
||||
{
|
||||
$url = 'https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search';
|
||||
|
||||
$response = Http::post($url, [
|
||||
'asset' => 'USDT',
|
||||
'fiat' => 'LAK',
|
||||
'tradeType' => 'SELL',
|
||||
'page' => 1,
|
||||
'rows' => 20,
|
||||
'merchantCheck' => true
|
||||
]);
|
||||
|
||||
if (!$response->ok()) {
|
||||
return response()->json(['error' => '请求失败'], 500);
|
||||
}
|
||||
|
||||
$ads = $response->json('data');
|
||||
$maxPrice = collect($ads)->max(fn ($item) => (float) $item['adv']['price']);
|
||||
|
||||
return response()->json([
|
||||
'max_price' => $maxPrice
|
||||
]);
|
||||
}
|
||||
|
||||
public function getUsdtLakForAmount()
|
||||
{
|
||||
$url = 'https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search';
|
||||
|
||||
$amount = 20000000; // 查询200万LAK的卖价
|
||||
|
||||
$response = Http::post($url, [
|
||||
'asset' => 'USDT',
|
||||
'fiat' => 'LAK',
|
||||
'tradeType' => 'SELL',
|
||||
'page' => 1,
|
||||
'rows' => 20,
|
||||
'merchantCheck' => true,
|
||||
'transAmount' => $amount
|
||||
]);
|
||||
|
||||
if (!$response->ok()) {
|
||||
return response()->json(['error' => '请求失败'], 500);
|
||||
}
|
||||
|
||||
$ads = $response->json('data');
|
||||
|
||||
if (empty($ads)) {
|
||||
return response()->json(['message' => '找不到符合条件的卖单']);
|
||||
}
|
||||
|
||||
// 按照价格升序排列,取最便宜的那个
|
||||
// $sorted = collect($ads)->sortBy(fn ($item) => (float) $item['adv']['price']);
|
||||
$sorted = collect($ads)->sortByDesc(fn ($item) => (float) $item['adv']['price']);
|
||||
$best = $sorted->first();
|
||||
|
||||
// dd($best);
|
||||
|
||||
return response()->json([
|
||||
'price' => $best['adv']['price'],
|
||||
'availableQuantity' => $best['adv']['surplusAmount'],
|
||||
'minAmount' => $best['adv']['minSingleTransAmount'],
|
||||
'maxAmount' => $best['adv']['maxSingleTransAmount'],
|
||||
'nickName' => $best['advertiser']['nickName']
|
||||
]);
|
||||
}
|
||||
|
||||
public function savePrice()
|
||||
{
|
||||
$url = 'https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search';
|
||||
|
||||
// 1. 获取最高价(不限制金额)
|
||||
$respAll = Http::post($url, [
|
||||
'asset' => 'USDT',
|
||||
'fiat' => 'LAK',
|
||||
'tradeType' => 'SELL',
|
||||
'page' => 1,
|
||||
'rows' => 20,
|
||||
'merchantCheck' => true
|
||||
]);
|
||||
|
||||
// 2. 获取 200 万成交价
|
||||
$resp200 = Http::post($url, [
|
||||
'asset' => 'USDT',
|
||||
'fiat' => 'LAK',
|
||||
'tradeType' => 'SELL',
|
||||
'page' => 1,
|
||||
'rows' => 20,
|
||||
'merchantCheck' => true,
|
||||
'transAmount' => 2000000
|
||||
]);
|
||||
|
||||
if (!$respAll->ok() || !$resp200->ok()) {
|
||||
return response()->json(['error' => 'Binance 请求失败'], 500);
|
||||
}
|
||||
|
||||
$adsAll = $respAll->json('data');
|
||||
$ads200 = $resp200->json('data');
|
||||
|
||||
$highestPrice = collect($adsAll)->max(fn($item) => (float) $item['adv']['price']);
|
||||
$priceFor200M = collect($ads200)->sortByDesc(fn($item) => (float) $item['adv']['price'])->first()['adv']['price'] ?? null;
|
||||
|
||||
// 写入一行资料
|
||||
UsdtC2c::create([
|
||||
'Highest' => $highestPrice,
|
||||
'Million' => $priceFor200M,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => '写入成功',
|
||||
'Highest' => $highestPrice,
|
||||
'Million' => $priceFor200M
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,4 +40,5 @@ public function Msg($token,Request $request)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UsdtC2c extends Model
|
||||
{
|
||||
protected $table = 'UsdtC2c';
|
||||
public $timestamps = true; // 我们只用 created_at 字段
|
||||
protected $fillable = ['Highest', 'Million', 'created_at'];
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
@@ -19,7 +21,14 @@ public function register(): void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Schema::defaultStringLength(191); // 防止旧 MySQL 出现索引超长报错
|
||||
Schema::defaultStringLength(191); // 防止旧 MySQL 出现索引超长报错
|
||||
|
||||
Filament::serving(function () {
|
||||
Filament::registerRenderHook(
|
||||
'panels::head.end',
|
||||
fn () => '<style>.filament-tables-text-column { user-select: text !important; }</style>'
|
||||
);
|
||||
});
|
||||
|
||||
// 强制所有表使用 utf8mb4_0900_ai_ci
|
||||
// Schema::defaultCharset('utf8mb4');
|
||||
|
||||
@@ -17,29 +17,39 @@
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
use Filament\Navigation\NavigationGroup;
|
||||
use Filament\Navigation\NavigationItem;
|
||||
use Filament\Navigation\NavigationBuilder;
|
||||
use App\Filament\Pages\Dashboard;
|
||||
use App\Filament\Widgets\AccountWidget;
|
||||
use App\Filament\Widgets\FilamentInfoWidget;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
public function hasDashboard(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
->default()
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
->login()
|
||||
->colors([
|
||||
'primary' => Color::Amber,
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->pages([
|
||||
Pages\Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
->widgets([
|
||||
Widgets\AccountWidget::class,
|
||||
Widgets\FilamentInfoWidget::class,
|
||||
])
|
||||
return Panel::make()
|
||||
->default()
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
->login()
|
||||
->colors([
|
||||
'primary' => Color::Amber,
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->pages([
|
||||
Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
// ->widgets([
|
||||
// AccountWidget::class,
|
||||
// FilamentInfoWidget::class,
|
||||
// ])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
@@ -55,4 +65,24 @@ public function panel(Panel $panel): Panel
|
||||
Authenticate::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function navigation(NavigationBuilder $builder): NavigationBuilder
|
||||
{
|
||||
return $builder
|
||||
->groups([
|
||||
NavigationGroup::make('Telegram 管理') // 父级群组
|
||||
->items([
|
||||
NavigationItem::make('指令列表') // 子菜单项
|
||||
->icon('heroicon-o-command-line')
|
||||
->url(route('filament.admin.resources.tg-comm.index'))
|
||||
->isActiveWhen(fn (): bool => request()->routeIs('filament.admin.resources.tg-comm.*')),
|
||||
|
||||
NavigationItem::make('其它功能')
|
||||
->icon('heroicon-o-cog')
|
||||
->url(route('filament.admin.pages.other-functions'))
|
||||
->isActiveWhen(fn (): bool => request()->routeIs('filament.admin.pages.other-functions')),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user