User company addded

This commit is contained in:
2024-11-09 18:49:54 +05:00
parent 95c6d5746b
commit a566b7ac61
8 changed files with 175 additions and 10 deletions

View File

@@ -20,6 +20,9 @@ return new class extends Migration
->nullable()
->comment('types: tel, hk, hj');
$table->string('name')
->index();
$table->string('ssb')
->nullable()
->comment('Şahsy salgyt belgisi');
@@ -30,6 +33,8 @@ return new class extends Migration
$table->foreignId('bank_id')->nullable()->constrained('banks')->nullOnDelete();
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
$table->boolean('default')->default(false);
$table->timestamps();
});
}

View File

@@ -7,8 +7,32 @@ use App\Modules\Bank\Models\Bank;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $id [primary,unique]
* @property \App\Modules\UserCompany\Types\CompanyType $company_type
* @property string $name
* @property string $ssb [unique]
* @property string $hb [unique]
* @property bool $default [default: false]
* @property int $user_id
* @property int $bank_id
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
*/
class UserCompany extends Model
{
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'default' => 'boolean',
];
}
/**
* User
*

View File

@@ -31,6 +31,11 @@ enum CompanyType: string
];
}
public static function option(?string $key = ''): string
{
return self::options()[$key] ?? '-';
}
/**
* Default option
*/
@@ -56,7 +61,7 @@ enum CompanyType: string
/**
* Get status
*/
public static function statusClass(?string $key): string
public static function statusClass(?string $key = ''): string
{
return self::statusClasses()[$key] ?? 'danger';
}