wip billing

This commit is contained in:
Masroor Ehsan 2025-01-01 16:31:03 +06:00
parent 5d56d24ea6
commit 4833cf9225
6 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class BillingGroupRequest extends FormRequest
{
public function rules(): array
{
return [
'name' => ['required'],
'description' => ['nullable'],
'is_active' => ['boolean'],
];
}
public function authorize(): bool
{
return true;
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class BillingRadiologistRequest extends FormRequest
{
public function rules(): array
{
return [
'billing_group_id' => ['required', 'exists:billing_groups'],
'radiologist_id' => ['required', 'exists:users'],
];
}
public function authorize(): bool
{
return true;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BillingGroup extends Model
{
protected function casts(): array
{
return [
'is_active' => 'boolean',
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class BillingRadiologist extends Model
{
public function billingGroup(): BelongsTo
{
return $this->belongsTo(BillingGroup::class);
}
public function radiologist(): BelongsTo
{
return $this->belongsTo(User::class, 'radiologist_id');
}
}

View File

@ -0,0 +1,24 @@
<?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('billing_groups', function (Blueprint $table) {
$table->id();
$table->boolean('is_active')->index();
$table->string('name')->unique();
$table->text('description')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('billing_groups');
}
};

View File

@ -0,0 +1,25 @@
<?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('billing_radiologists', function (Blueprint $table) {
$table->id();
$table->foreignId('billing_group_id')->constrained('billing_groups')->nullOnDelete();
$table->foreignId('radiologist_id')->constrained('users')->nullOnDelete();
$table->timestamps();
$table->unique(['billing_group_id', 'radiologist_id']);
});
}
public function down(): void
{
Schema::dropIfExists('billing_radiologists');
}
};