首次提交 Laravel 專案
This commit is contained in:
Executable
+1
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tg_group_users', function (Blueprint $table) {
|
||||
$table->increments('id'); // 主键 + AUTO_INCREMENT
|
||||
$table->string('chat_id')->comment('隶属群ID');
|
||||
$table->string('user_id')->comment('tg的ID');
|
||||
$table->string('first_name')->nullable();
|
||||
$table->string('last_name')->nullable();;
|
||||
$table->string('username')->nullable()->comment('tg的username');
|
||||
$table->string('status')->comment('用户在群的角色'); // creator, administrator, member, left, kicked
|
||||
$table->boolean('is_bot')->default(false)->comment('0:真人 1:机器人');
|
||||
$table->string('language_code')->nullable();
|
||||
$table->integer('operator')->default(0)->comment('操作员 0不是1是');
|
||||
$table->integer('competence')->default(0)->comment('0普通权限,1管理员');
|
||||
$table->string('inviter')->nullable()->comment('邀请人');
|
||||
$table->json('raw_data')->nullable();
|
||||
$table->unique(['chat_id', 'user_id']); // 防止重复记录
|
||||
$table->dateTime('created_at')->useCurrent()->nullable();
|
||||
$table->dateTime('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_0900_ai_ci';
|
||||
$table->comment('群用户人员');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('group_users');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tg_msg', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->bigInteger('update_id');
|
||||
$table->string('token')->nullable();
|
||||
// message 資料
|
||||
$table->bigInteger('message_message_id')->nullable();
|
||||
$table->bigInteger('message_from_id')->nullable();
|
||||
$table->boolean('message_from_is_bot')->nullable();
|
||||
$table->string('message_from_first_name')->nullable();
|
||||
$table->string('message_from_last_name')->nullable();
|
||||
$table->string('message_from_username')->nullable();
|
||||
$table->string('message_from_language_code')->nullable();
|
||||
$table->bigInteger('message_chat_id')->nullable();
|
||||
$table->string('message_chat_title')->nullable();
|
||||
$table->string('message_chat_type')->nullable();
|
||||
$table->boolean('message_chat_all_members_are_administrators')->nullable();
|
||||
$table->dateTime('message_date')->nullable(); // 👈 已改為 datetime
|
||||
$table->longText('message_text')->nullable();
|
||||
// entities 陣列中的第一個 mention 項目
|
||||
$table->integer('message_entities_0_offset')->nullable();
|
||||
$table->integer('message_entities_0_length')->nullable();
|
||||
$table->string('message_entities_0_type')->nullable();
|
||||
// 原始資料
|
||||
$table->json('raw')->nullable();
|
||||
// Laravel timestamps
|
||||
$table->dateTime('created_at')->useCurrent()->nullable();
|
||||
$table->dateTime('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
// 设置字符集与排序规则
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_0900_ai_ci';
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('telegram_messages');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tg_groups', function (Blueprint $table) {
|
||||
$table->id(); // Laravel 主鍵
|
||||
$table->bigInteger('chat_id')->unique(); // Telegram 群組/頻道 ID(可能為負數)
|
||||
$table->string('type')->nullable()->comment('群类型'); // group、supergroup、channel、private
|
||||
$table->string('title')->nullable()->comment('群名稱');
|
||||
$table->string('creator')->nullable()->comment('群主ID');
|
||||
$table->longText('description')->nullable()->comment('群組描述'); // 群組描述(如有)
|
||||
$table->string('invite_link')->nullable()->comment('群組邀請連結'); // 群組邀請連結(如有)
|
||||
// 可選擴充
|
||||
$table->string('photo_small_file_id')->nullable()->comment('群头像160x160');
|
||||
$table->string('photo_big_file_id')->nullable()->comment('群头像640x640');
|
||||
$table->dateTime('created_at')->useCurrent()->nullable();
|
||||
$table->dateTime('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
$table->comment('飞机群');
|
||||
// 设置字符集与排序规则
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_0900_ai_ci';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tg_group');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('ledger', function (Blueprint $table) {
|
||||
$table->increments('id'); // 主键 + AUTO_INCREMENT
|
||||
$table->string('chat_id', 50)->comment('隶属群ID');
|
||||
$table->string('user_id', 15)->comment('tg的ID');
|
||||
$table->integer('type')->default(0)->comment('0收入1支出');
|
||||
$table->dateTime('date')->nullable()->comment('记账时间');
|
||||
$table->decimal('amount', 12, 2)->default(0)->comment('金额');
|
||||
$table->dateTime('created_at')->useCurrent()->nullable();
|
||||
$table->dateTime('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_0900_ai_ci';
|
||||
$table->comment('收支记录');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ledger');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tg_comm', function (Blueprint $table) {
|
||||
$table->increments('id'); // PRIMARY KEY + AUTO_INCREMENT
|
||||
$table->string('command')->nullable()->comment('指令名称');
|
||||
$table->string('Instructions')->nullable()->comment('说明');
|
||||
$table->string('action', )->nullable()->comment('对应动作指令');
|
||||
$table->longText('memo')->nullable()->comment('使用说明');
|
||||
$table->integer('dis_play')->default(1)->comment('指令列表 0不显示 1显示');
|
||||
$table->integer('manager')->default(0)->comment('管理权限0需要1不需要');
|
||||
$table->integer('valid')->default(1)->comment('0停用1启用');
|
||||
$table->dateTime('created_at')->useCurrent()->nullable();
|
||||
$table->dateTime('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
// 可选:你也可以在这里设置表的注释
|
||||
$table->comment('机器人指令');
|
||||
// 指定表的 charset 与 collation
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_0900_ai_ci';
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tg_comm');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('user_account', function (Blueprint $table) {
|
||||
$table->increments('id'); // 主键 + AUTO_INCREMENT
|
||||
$table->string('chat_id')->comment('隶属群ID');
|
||||
$table->string('user_id')->comment('tg的ID');
|
||||
$table->string('username')->nullable()->comment('用户名称');
|
||||
$table->dateTime('stime')->nullable()->comment('启用时间');
|
||||
$table->integer('bill_unit')->default(1)->comment('计费单位'); //0分1天2月
|
||||
$table->integer('bill_cycle')->default(1)->comment('计费周期'); //依照bill_unit赋值
|
||||
$table->decimal('amount', 12, 2)->default(0)->comment('费用'); //计费单位要收的费用
|
||||
$table->decimal('balance', 12, 2)->default(0)->comment('当前余额');
|
||||
$table->integer('tg_msg')->default('1')->comment('0不通知1通知'); //Tg消息通知
|
||||
$table->integer('auto_stop')->default('0')->comment('0不停1停止'); //欠费是否自动停止
|
||||
$table->string('subjection')->nullable()->comment('隶属管理机器人');
|
||||
$table->longText('memo')->nullable()->comment('备注说明');
|
||||
$table->dateTime('created_at')->useCurrent()->nullable();
|
||||
$table->dateTime('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_0900_ai_ci';
|
||||
$table->comment('账户资料');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_account');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tgBot', function (Blueprint $table) {
|
||||
$table->increments('id'); // 主键 + AUTO_INCREMENT
|
||||
$table->string('bot_id')->nullable()->comment('bot_id');
|
||||
$table->string('bot_token')->nullable()->comment('bot_oken');
|
||||
$table->string('bot_username')->nullable()->comment('bot名称');
|
||||
$table->string('subjection_username')->nullable()->comment('隶属飞机用户');
|
||||
$table->string('subjection_mobile')->nullable()->comment('隶属飞机用户手机号');
|
||||
$table->longText('webhook')->nullable()->comment('webhook_url');
|
||||
$table->longText('memo')->nullable()->comment('备注说明');
|
||||
$table->dateTime('created_at')->useCurrent()->nullable();
|
||||
$table->dateTime('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
$table->charset = 'utf8mb4';
|
||||
$table->collation = 'utf8mb4_0900_ai_ci';
|
||||
$table->comment('机器人资料');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tgBot');
|
||||
}
|
||||
};
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user