chore: code style
This commit is contained in:
@@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
*/
|
||||
class TransactionFactory extends Factory
|
||||
{
|
||||
protected static ?string $transaction_type;
|
||||
protected static ?string $transaction_type;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
@@ -24,15 +24,15 @@ class TransactionFactory extends Factory
|
||||
return [
|
||||
'symbol' => $this->faker->randomElement(['AAPL', 'GOOG', 'AMZN']),
|
||||
'transaction_type' => $transaction_type,
|
||||
'portfolio_id' => Portfolio::factory()->create()->id,
|
||||
'portfolio_id' => Portfolio::factory()->create()->id,
|
||||
'date' => $this->faker->date('Y-m-d'),
|
||||
'quantity' => 1,
|
||||
'cost_basis' => $transaction_type == 'BUY'
|
||||
'cost_basis' => $transaction_type == 'BUY'
|
||||
? $this->faker->randomFloat(2, 10, 500)
|
||||
: null,
|
||||
'sale_price' => $transaction_type == 'SELL'
|
||||
: null,
|
||||
'sale_price' => $transaction_type == 'SELL'
|
||||
? $this->faker->randomFloat(2, 10, 500)
|
||||
: null,
|
||||
: null,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class TransactionFactory extends Factory
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'transaction_type' => 'BUY',
|
||||
'cost_basis' => $this->faker->randomFloat(2, 10, 500),
|
||||
'sale_price' => null
|
||||
'sale_price' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class UserFactory extends Factory
|
||||
'two_factor_secret' => null,
|
||||
'two_factor_recovery_codes' => null,
|
||||
'remember_token' => Str::random(10),
|
||||
'profile_photo_path' => null
|
||||
'profile_photo_path' => null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
|
||||
@@ -14,7 +14,7 @@ return new class extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('portfolios', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('title');
|
||||
$table->text('notes')->nullable();
|
||||
$table->boolean('wishlist')->default(false);
|
||||
@@ -31,4 +31,4 @@ return new class extends Migration
|
||||
{
|
||||
Schema::dropIfExists('portfolios');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Portfolio;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
@@ -34,4 +34,4 @@ return new class extends Migration
|
||||
{
|
||||
Schema::dropIfExists('portfolio_user');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use Database\Seeders\MarketDataSeeder;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMarketDataTable extends Migration
|
||||
{
|
||||
@@ -34,7 +34,7 @@ class CreateMarketDataTable extends Migration
|
||||
|
||||
Artisan::call('db:seed', [
|
||||
'--class' => MarketDataSeeder::class,
|
||||
'--force' => true
|
||||
'--force' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateDailyChangeTable extends Migration
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreateDividendsTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('dividends', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->uuid('id')->primary();
|
||||
$table->date('date');
|
||||
$table->foreignIdFor(MarketData::class, 'symbol');
|
||||
$table->float('dividend_amount', 12, 4);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\MarketData;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSplitsTable extends Migration
|
||||
{
|
||||
@@ -15,7 +15,7 @@ class CreateSplitsTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('splits', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->uuid('id')->primary();
|
||||
$table->date('date');
|
||||
$table->foreignIdFor(MarketData::class, 'symbol');
|
||||
$table->float('split_amount', 12, 4);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use App\Models\MarketData;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use App\Models\Portfolio;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTransactionsTable extends Migration
|
||||
{
|
||||
@@ -16,7 +16,7 @@ class CreateTransactionsTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->uuid('id')->primary();
|
||||
$table->foreignIdFor(MarketData::class, 'symbol');
|
||||
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
|
||||
$table->string('transaction_type', 15);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use App\Models\MarketData;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use App\Models\Portfolio;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateHoldingsTable extends Migration
|
||||
{
|
||||
@@ -16,7 +16,7 @@ class CreateHoldingsTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('holdings', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->uuid('id')->primary();
|
||||
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignIdFor(MarketData::class, 'symbol');
|
||||
$table->float('quantity', 12, 4);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
@@ -41,4 +41,4 @@ return new class extends Migration
|
||||
|
||||
Schema::dropIfExists('connected_accounts');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
@@ -31,4 +31,4 @@ return new class extends Migration
|
||||
{
|
||||
Schema::dropIfExists('backup_import_jobs');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAiChatsTable extends Migration
|
||||
{
|
||||
@@ -18,7 +18,7 @@ class CreateAiChatsTable extends Migration
|
||||
Builder::morphUsingUuids();
|
||||
|
||||
Schema::create('ai_chats', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->uuid('id')->primary();
|
||||
$table->foreignIdFor(User::class, 'user_id')->constrained()->onDelete('cascade');
|
||||
$table->morphs('chatable');
|
||||
$table->string('role');
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
|
||||
class MarketDataSeeder extends Seeder
|
||||
{
|
||||
@@ -14,7 +14,7 @@ class MarketDataSeeder extends Seeder
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
{
|
||||
$chunkSize = 500;
|
||||
|
||||
// Path to the CSV file
|
||||
@@ -29,7 +29,7 @@ class MarketDataSeeder extends Seeder
|
||||
|
||||
while (($row = fgetcsv($handle, 0, ',')) !== false) {
|
||||
|
||||
if (!$header) {
|
||||
if (! $header) {
|
||||
|
||||
// header must be the first row
|
||||
$header = $row;
|
||||
@@ -40,31 +40,31 @@ class MarketDataSeeder extends Seeder
|
||||
$data = array_combine($header, $row);
|
||||
|
||||
$rows[] = [
|
||||
'symbol' => $data['symbol'],
|
||||
'name' => $data['name'],
|
||||
'symbol' => $data['symbol'],
|
||||
'name' => $data['name'],
|
||||
'meta_data' => json_encode([
|
||||
'country' => $data['country'],
|
||||
'first_trade_year' => $data['first_trade_year'],
|
||||
'sector' => $data['sector'],
|
||||
'industry' => $data['industry'],
|
||||
]),
|
||||
]),
|
||||
];
|
||||
|
||||
$rowCount++;
|
||||
|
||||
if ($rowCount % $chunkSize == 0) {
|
||||
DB::table('market_data')->insertOrIgnore($rows);
|
||||
$rows = [];
|
||||
$rows = [];
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
throw new \Exception('Error: '. $e->getMessage());
|
||||
|
||||
throw new \Exception('Error: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// final clean up
|
||||
if (!empty($rows)) {
|
||||
if (! empty($rows)) {
|
||||
DB::table('market_data')->insertOrIgnore($rows);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user