first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Account>
|
||||
*/
|
||||
class AccountFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Contract>
|
||||
*/
|
||||
class ContractFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Debt>
|
||||
*/
|
||||
class DebtFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Payment>
|
||||
*/
|
||||
class PaymentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Person;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Person\AddressType>
|
||||
*/
|
||||
class AddressTypeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Person;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Person\PersonAddress>
|
||||
*/
|
||||
class PersonAddressFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Person;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Person\Person>
|
||||
*/
|
||||
class PersonFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Person;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Person\PersonGroup>
|
||||
*/
|
||||
class PersonGroupFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Person;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Person\PersonPhone>
|
||||
*/
|
||||
class PersonPhoneFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Person;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Person\PersonType>
|
||||
*/
|
||||
class PersonTypeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Person;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Person\PhoneType>
|
||||
*/
|
||||
class PhoneTypeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Segment>
|
||||
*/
|
||||
class SegmentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Jetstream\Features;
|
||||
|
||||
/**
|
||||
* @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'),
|
||||
'two_factor_secret' => null,
|
||||
'two_factor_recovery_codes' => null,
|
||||
'remember_token' => Str::random(10),
|
||||
'profile_photo_path' => null,
|
||||
'current_team_id' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the user should have a personal team.
|
||||
*/
|
||||
public function withPersonalTeam(?callable $callback = null): static
|
||||
{
|
||||
if (! Features::hasTeamFeatures()) {
|
||||
return $this->state([]);
|
||||
}
|
||||
|
||||
return $this->has(
|
||||
Team::factory()
|
||||
->state(fn (array $attributes, User $user) => [
|
||||
'name' => $user->name.'\'s Team',
|
||||
'user_id' => $user->id,
|
||||
'personal_team' => true,
|
||||
])
|
||||
->when(is_callable($callback), $callback),
|
||||
'ownedTeams'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->foreignId('current_team_id')->nullable();
|
||||
$table->string('profile_photo_path', 2048)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
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('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->text('two_factor_secret')
|
||||
->after('password')
|
||||
->nullable();
|
||||
|
||||
$table->text('two_factor_recovery_codes')
|
||||
->after('two_factor_secret')
|
||||
->nullable();
|
||||
|
||||
if (Fortify::confirmsTwoFactorAuthentication()) {
|
||||
$table->timestamp('two_factor_confirmed_at')
|
||||
->after('two_factor_recovery_codes')
|
||||
->nullable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(array_merge([
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
], Fortify::confirmsTwoFactorAuthentication() ? [
|
||||
'two_factor_confirmed_at',
|
||||
] : []));
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,112 @@
|
||||
<?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('person_types', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('person_groups', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('phone_types', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('address_types', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('person', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->unsignedBigInteger('nu')->default(0);
|
||||
$table->string('first_name', 255)->nullable();
|
||||
$table->string('last_name', 255)->nullable();
|
||||
$table->string('full_name', 255)->nullable();
|
||||
$table->enum('gender', ['m','w'])->nullable();
|
||||
$table->date('birthday')->nullable();
|
||||
$table->string('tax_number', 99)->nullable();
|
||||
$table->string('social_security_number',99)->nullable();
|
||||
$table->string('description',500)->nullable();
|
||||
$table->foreignId('group_id')->references('id')->on('person_groups');
|
||||
$table->foreignId('type_id')->references('id')->on('person_types');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->foreignIdFor(\App\Models\User::class);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('person_phones', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('nu',50);
|
||||
$table->unsignedInteger('country_code')->nullable();
|
||||
$table->foreignId('type_id')->references('id')->on('phone_types');
|
||||
$table->string('description',125)->nullable();
|
||||
$table->foreignIdFor(\App\Models\Person\Person::class);
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->foreignIdFor(\App\Models\User::class);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('person_addresses', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('address',150);
|
||||
$table->string('country')->nullable();
|
||||
$table->foreignId('type_id')->references('id')->on('address_types');
|
||||
$table->string('description',125)->nullable();
|
||||
$table->foreignIdFor(\App\Models\Person\Person::class);
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->foreignIdFor(\App\Models\User::class);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('person_types');
|
||||
Schema::dropIfExists('person_groups');
|
||||
Schema::dropIfExists('phone_types');
|
||||
Schema::dropIfExists('address_types');
|
||||
Schema::dropIfExists('person');
|
||||
Schema::dropIfExists('person_phones');
|
||||
Schema::dropIfExists('person_addresses');
|
||||
}
|
||||
};
|
||||
@@ -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('account_types', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('accounts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('reference', 125)->nullable();
|
||||
$table->string('description', 255)->nullable();
|
||||
$table->foreignIdFor(\App\Models\Contract::class);
|
||||
$table->foreignId('type_id')->references('id')->on('account_types');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('account_type');
|
||||
Schema::dropIfExists('accounts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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('debt_types', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('name',50)->unique();
|
||||
$table->string('description',125)->nullable();
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
|
||||
Schema::create('debts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('reference',125)->nullable();
|
||||
$table->string('invoice_nu',125)->nullable();
|
||||
$table->date('issue_date')->nullable();
|
||||
$table->date('due_date')->nullable();
|
||||
$table->decimal('amount', 11, 4)->nullable();
|
||||
$table->decimal('interest', 11, 8)->nullable();
|
||||
$table->date('interest_start_date')->nullable();
|
||||
$table->string('description',125)->nullable();
|
||||
$table->foreignId('account_id')->references('id')->on('accounts');
|
||||
$table->foreignId('type_id')->references('id')->on('debt_types');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('debt_types');
|
||||
Schema::dropIfExists('debts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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('payment_types', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('reference', 125)->nullable();
|
||||
$table->string('payment_nu', 125)->nullable();
|
||||
$table->date('payment_date')->nullable();
|
||||
$table->decimal('amount',11,4)->nullable();
|
||||
$table->foreignId('debt_id')->references('id')->on('debts');
|
||||
$table->foreignId('type_id')->references('id')->on('payment_types');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->foreignIdFor(\App\Models\User::class);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('payment_types');
|
||||
Schema::dropIfExists('payments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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('contract_types', function(Blueprint $table){
|
||||
$table->id();
|
||||
$table->string('name',50);
|
||||
$table->string('description',125)->nullable();
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
});
|
||||
|
||||
Schema::create('contracts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('reference', 125)->nullable();
|
||||
$table->date('start_date');
|
||||
$table->date('end_date')->nullable();
|
||||
$table->string('description', 255)->nullable();
|
||||
$table->foreignIdFor(\App\Models\Person\Person::class, 'client_id');
|
||||
$table->foreignIdFor(\App\Models\Person\Person::class, 'debtor_id');
|
||||
$table->foreignId('type_id')->references('id')->on('contract_types');
|
||||
$table->unsignedTinyInteger('active')->default(1);
|
||||
$table->unsignedTinyInteger('deleted')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contract_types');
|
||||
Schema::dropIfExists('contracts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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('segments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 50);
|
||||
$table->string('description', 255);
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('segments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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('contract_segment', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('contract_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('segment_id')->constrained()->onDelete('cascade');
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contract_segment');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AccountSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Contract;
|
||||
use App\Models\ContractType;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ContractSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$contractType = [
|
||||
[ 'name' => 'delivery', 'description' => ''],
|
||||
[ 'name' => 'leasing', 'description' => '']
|
||||
];
|
||||
|
||||
foreach($contractType as $ct){
|
||||
ContractType::create($ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Person\PersonType;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
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',
|
||||
'password' => Hash::make("password")
|
||||
]);
|
||||
|
||||
$this->call([
|
||||
PersonSeeder::class,
|
||||
SegmentSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DebtSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class PaymentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Contract;
|
||||
use App\Models\ContractType;
|
||||
use App\Models\Person\AddressType;
|
||||
use App\Models\Person\Person;
|
||||
use App\Models\Person\PersonGroup;
|
||||
use App\Models\Person\PersonType;
|
||||
use App\Models\Person\PhoneType;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class PersonSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
$personTypes = [
|
||||
[ 'name' => 'legal', 'description' => ''],
|
||||
[ 'name' => 'natural', 'description' => '']
|
||||
];
|
||||
|
||||
$personGroups = [
|
||||
[ 'name' => 'client', 'description' => ''],
|
||||
[ 'name' => 'debtor', 'description' => '']
|
||||
];
|
||||
|
||||
$phoneTypes = [
|
||||
[ 'name' => 'mobile', 'description' => ''],
|
||||
[ 'name' => 'telephone', 'description' => '']
|
||||
];
|
||||
|
||||
$addressTypes = [
|
||||
[ 'name' => 'permanent', 'description' => ''],
|
||||
[ 'name' => 'temporary', 'description' => '']
|
||||
];
|
||||
|
||||
$contractTypes = [
|
||||
['name' => 'early', 'description' => ''],
|
||||
['name' => 'hard', 'description' => '']
|
||||
];
|
||||
|
||||
|
||||
foreach($personTypes as $pt){
|
||||
PersonType::create($pt);
|
||||
}
|
||||
|
||||
foreach($personGroups as $pg){
|
||||
PersonGroup::create($pg);
|
||||
}
|
||||
|
||||
foreach($phoneTypes as $pt){
|
||||
PhoneType::create($pt);
|
||||
}
|
||||
|
||||
foreach($addressTypes as $at){
|
||||
AddressType::create($at);
|
||||
}
|
||||
|
||||
foreach($contractTypes as $ct){
|
||||
ContractType::create($ct);
|
||||
}
|
||||
|
||||
//client
|
||||
Person::create([
|
||||
'nu' => rand(100000,200000),
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'full_name' => 'test d.o.o.',
|
||||
'gender' => 'm',
|
||||
'birthday' => '2000-01-01',
|
||||
'tax_number' => '22424345',
|
||||
'social_security_number' => '22525252233656',
|
||||
'description' => 'sdwwf',
|
||||
'group_id' => 1,
|
||||
'type_id' => 1,
|
||||
'user_id' => 1
|
||||
]);
|
||||
|
||||
//debtors
|
||||
Person::create([
|
||||
'nu' => rand(100000,200000),
|
||||
'first_name' => 'test',
|
||||
'last_name' => 'test',
|
||||
'full_name' => 'test test',
|
||||
'gender' => 'm',
|
||||
'birthday' => '2000-01-01',
|
||||
'tax_number' => '22424345',
|
||||
'social_security_number' => '22525252233656',
|
||||
'description' => 'sdwwf',
|
||||
'group_id' => 2,
|
||||
'type_id' => 2,
|
||||
'user_id' => 1
|
||||
]);
|
||||
|
||||
Person::create([
|
||||
'nu' => rand(100000,200000),
|
||||
'first_name' => 'test2',
|
||||
'last_name' => 'test2',
|
||||
'full_name' => 'test2 test2',
|
||||
'gender' => 'm',
|
||||
'birthday' => '1992-01-01',
|
||||
'tax_number' => '2425233',
|
||||
'social_security_number' => '22522312314',
|
||||
'description' => 'dw323',
|
||||
'group_id' => 2,
|
||||
'type_id' => 2,
|
||||
'user_id' => 1
|
||||
]);
|
||||
|
||||
//client
|
||||
Person::create([
|
||||
'nu' => rand(100000,200000),
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'full_name' => 'test d.o.o.',
|
||||
'gender' => 'm',
|
||||
'birthday' => '2000-01-01',
|
||||
'tax_number' => '22424345',
|
||||
'social_security_number' => '22525252233656',
|
||||
'description' => 'sdwwf',
|
||||
'group_id' => 1,
|
||||
'type_id' => 1,
|
||||
'user_id' => 1
|
||||
]);
|
||||
|
||||
//debtors
|
||||
Person::create([
|
||||
'nu' => rand(100000,200000),
|
||||
'first_name' => 'test3',
|
||||
'last_name' => 'test3',
|
||||
'full_name' => 'test3 test3',
|
||||
'gender' => 'm',
|
||||
'birthday' => '2000-01-01',
|
||||
'tax_number' => '22424345',
|
||||
'social_security_number' => '22525252233656',
|
||||
'description' => 'sdwwf',
|
||||
'group_id' => 2,
|
||||
'type_id' => 2,
|
||||
'user_id' => 1
|
||||
]);
|
||||
|
||||
Person::create([
|
||||
'nu' => rand(100000,200000),
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'full_name' => 'test4 d.o.o.',
|
||||
'gender' => 'm',
|
||||
'birthday' => '1992-01-01',
|
||||
'tax_number' => '2425233',
|
||||
'social_security_number' => '22522312314',
|
||||
'description' => 'dw323',
|
||||
'group_id' => 2,
|
||||
'type_id' => 1,
|
||||
'user_id' => 1
|
||||
]);
|
||||
|
||||
|
||||
//contract
|
||||
Contract::create([
|
||||
'reference' => '111111222',
|
||||
'start_date' => date('Y-m-d'),
|
||||
'client_id' => 1,
|
||||
'debtor_id' => 2,
|
||||
'type_id' => 1
|
||||
]);
|
||||
|
||||
Contract::create([
|
||||
'reference' => '111111224',
|
||||
'start_date' => date('Y-m-d'),
|
||||
'client_id' => 1,
|
||||
'debtor_id' => 3,
|
||||
'type_id' => 1
|
||||
]);
|
||||
|
||||
Contract::create([
|
||||
'reference' => '211111222',
|
||||
'start_date' => date('Y-m-d'),
|
||||
'client_id' => 4,
|
||||
'debtor_id' => 5,
|
||||
'type_id' => 1
|
||||
]);
|
||||
|
||||
Contract::create([
|
||||
'reference' => '211111224',
|
||||
'start_date' => date('Y-m-d'),
|
||||
'client_id' => 4,
|
||||
'debtor_id' => 6,
|
||||
'type_id' => 1
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SegmentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$sements = [
|
||||
[ 'name' => 'global', 'description' => ''],
|
||||
[ 'name' => 'terrain', 'description' => '']
|
||||
];
|
||||
|
||||
foreach($sements as $st){
|
||||
Segment::create($st);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user