add usercompany
This commit is contained in:
@@ -28,6 +28,7 @@ return new class extends Migration
|
||||
->nullable();
|
||||
|
||||
$table->foreignId('bank_id')->nullable()->constrained('banks')->nullOnDelete();
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -2,6 +2,30 @@
|
||||
|
||||
namespace App\Modules\UserCompany\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Bank\Models\Bank;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class UserCompany extends Model {}
|
||||
class UserCompany extends Model
|
||||
{
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bank
|
||||
*
|
||||
* @return BelongsTo<Bank, $this>
|
||||
*/
|
||||
public function bank(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Bank::class);
|
||||
}
|
||||
}
|
||||
|
||||
63
app/Modules/UserCompany/Types/CompanyType.php
Normal file
63
app/Modules/UserCompany/Types/CompanyType.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\UserCompany\Types;
|
||||
|
||||
use App\Modules\AppHelpers\Enums\HasEnumHelpers;
|
||||
|
||||
enum CompanyType: string
|
||||
{
|
||||
use HasEnumHelpers;
|
||||
|
||||
/** Telekeçi */
|
||||
case TELEKECI = 'tel';
|
||||
|
||||
/** Hususy kärhana */
|
||||
case HK = 'hk';
|
||||
|
||||
/** Hojalyk jemgyýeti */
|
||||
case HJ = 'hj';
|
||||
|
||||
/**
|
||||
* Options
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function options(): array
|
||||
{
|
||||
return [
|
||||
self::TELEKECI->value => __('Telekeçi'),
|
||||
self::HK->value => __('Hususy kärhana'),
|
||||
self::HJ->value => __('Hojalyk jemgyýeti'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Default option
|
||||
*/
|
||||
public static function default(): string
|
||||
{
|
||||
return self::TELEKECI->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Status classes
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function statusClasses(): array
|
||||
{
|
||||
return [
|
||||
self::TELEKECI->value => 'success',
|
||||
self::HK->value => 'danger',
|
||||
self::HJ->value => 'warning',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status
|
||||
*/
|
||||
public static function statusClass(?string $key): string
|
||||
{
|
||||
return self::statusClasses()[$key] ?? 'danger';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user