mirror of
https://github.com/henry4682/finance_app.git
synced 2026-07-16 00:10:00 +00:00
feat: 前端分離+功能api化
1. 新增資產管理CRUD、googleOAuth登入 2. 更改原記帳controller
This commit is contained in:
188
database/seeders/AccountSeeder.php
Normal file
188
database/seeders/AccountSeeder.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AccountSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::table('accounts')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'user_id' => 1,
|
||||
'name' => '凱基銀行',
|
||||
'type' => 'bank',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 123028.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'user_id' => 1,
|
||||
'name' => '國泰證券',
|
||||
'type' => 'stock',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 0.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'user_id' => 1,
|
||||
'name' => '國泰銀行',
|
||||
'type' => 'bank',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 19067.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'user_id' => 1,
|
||||
'name' => '永豐銀行',
|
||||
'type' => 'cash',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 14138.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'user_id' => 1,
|
||||
'name' => '永豐證券',
|
||||
'type' => 'stock',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 0.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 11,
|
||||
'user_id' => 1,
|
||||
'name' => '國泰信用卡',
|
||||
'type' => 'credit_card',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 0.00,
|
||||
'note' => null,
|
||||
'billing_day' => 17,
|
||||
'payment_day' => 2,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 12,
|
||||
'user_id' => 1,
|
||||
'name' => '麥當勞點點卡',
|
||||
'type' => 'wallet',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 299.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 13,
|
||||
'user_id' => 1,
|
||||
'name' => '國泰基金',
|
||||
'type' => 'fund',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 0.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 14,
|
||||
'user_id' => 1,
|
||||
'name' => '手機悠遊卡',
|
||||
'type' => 'wallet',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 1.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 15,
|
||||
'user_id' => 1,
|
||||
'name' => '玉山金融卡(悠遊卡)',
|
||||
'type' => 'wallet',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 222.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 16,
|
||||
'user_id' => 1,
|
||||
'name' => '凱基信用卡(悠遊卡)',
|
||||
'type' => 'wallet',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 154.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 17,
|
||||
'user_id' => 1,
|
||||
'name' => '東華學生證(悠遊卡)',
|
||||
'type' => 'wallet',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 85.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 18,
|
||||
'user_id' => 1,
|
||||
'name' => '安聯基金',
|
||||
'type' => 'fund',
|
||||
'currency' => 'TWD',
|
||||
'balance' => 0.00,
|
||||
'note' => null,
|
||||
'billing_day' => null,
|
||||
'payment_day' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,19 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
\App\Models\User::updateOrCreate(
|
||||
['email' => 'henry194557@gmail.com'], // 換成你的 Google 登入 email
|
||||
[
|
||||
'name' => 'Henry',
|
||||
'google_id' => '', // 可以先隨便填
|
||||
'password' => bcrypt('password'),
|
||||
]
|
||||
);
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
$this->call([
|
||||
AccountSeeder::class,
|
||||
InvestmentHoldingSeeder::class,
|
||||
InvestmentTransactionSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
52
database/seeders/InvestmentHoldingSeeder.php
Normal file
52
database/seeders/InvestmentHoldingSeeder.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InvestmentHoldingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::table('investment_holdings')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'account_id' => 2,
|
||||
'type' => 'stock',
|
||||
'symbol' => '0050',
|
||||
'name' => '元大台灣50',
|
||||
'shares' => 304.00,
|
||||
'avg_cost' => 76.27,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'account_id' => 13,
|
||||
'type' => 'fund',
|
||||
'symbol' => '10350113',
|
||||
'name' => '國泰台灣高股息台幣月配',
|
||||
'shares' => 229.70,
|
||||
'avg_cost' => 43.53,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'account_id' => 18,
|
||||
'type' => 'fund',
|
||||
'symbol' => 'A36004',
|
||||
'name' => '安聯台灣科技基金',
|
||||
'shares' => 51.11,
|
||||
'avg_cost' => 782.69,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
301
database/seeders/InvestmentTransactionSeeder.php
Normal file
301
database/seeders/InvestmentTransactionSeeder.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InvestmentTransactionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::table('investment_transactions')->insert([
|
||||
// 國泰基金 holding_id=2
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 35.70,
|
||||
'price' => 56.11,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-06-05',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 20.10,
|
||||
'price' => 49.74,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-05-20',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 29.00,
|
||||
'price' => 34.48,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-02-05',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 27.30,
|
||||
'price' => 36.59,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-02-23',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 27.10,
|
||||
'price' => 36.89,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-03-05',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 25.10,
|
||||
'price' => 39.79,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-03-20',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 25.40,
|
||||
'price' => 39.39,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-04-07',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 21.10,
|
||||
'price' => 47.36,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-04-20',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 2,
|
||||
'action' => 'buy',
|
||||
'shares' => 18.90,
|
||||
'price' => 52.89,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 0,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-05-05',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
// 0050 holding_id=1
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 1.00,
|
||||
'price' => 70.05,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-01-09',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 50.00,
|
||||
'price' => 70.05,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-01-09',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 14.00,
|
||||
'price' => 104.49,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-06-05',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 14.00,
|
||||
'price' => 100.54,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-05-25',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 15.00,
|
||||
'price' => 94.39,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-05-05',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 17.00,
|
||||
'price' => 86.59,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-04-23',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 33.00,
|
||||
'price' => 75.14,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-04-07',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 20.00,
|
||||
'price' => 74.02,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-03-23',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 45.00,
|
||||
'price' => 77.53,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-03-05',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 48.00,
|
||||
'price' => 72.02,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2026-02-05',
|
||||
'note' => '定期定額',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'holding_id' => 1,
|
||||
'action' => 'buy',
|
||||
'shares' => 47.00,
|
||||
'price' => 62.54,
|
||||
'amount' => null,
|
||||
'nav' => null,
|
||||
'fee' => 1,
|
||||
'tax' => 0,
|
||||
'traded_at' => '2025-12-05',
|
||||
'note' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user