This commit is contained in:
2025-09-25 03:03:31 +05:00
commit ae480cf2f6
2768 changed files with 1485826 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<?php
namespace App\Models\System\Roles;
use Spatie\Permission\Models\Permission as SpatiePermission;
class Permission extends SpatiePermission {}

View File

@@ -0,0 +1,7 @@
<?php
namespace App\Models\System\Roles;
use Spatie\Permission\Models\Role as SpatieRole;
class Role extends SpatieRole {}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Models\System\Settings;
use Illuminate\Database\Eloquent\Model;
class Currency extends Model
{
/**
* Default currency
*
* @var string
*/
public const DEFAULT = 'TMT';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'code',
'symbol',
'format',
'exchange_rate',
];
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Models\System\Settings\Location;
use App\Models\Post\PostBranch;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Translatable\HasTranslations;
class Province extends Model
{
use HasFactory;
use HasTranslations;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'region',
'name',
];
/**
* Translatable fields
*
* @var array<string>
*/
public $translatable = ['name'];
/**
* Post branches
*/
public function postBranches(): HasMany
{
return $this->hasMany(PostBranch::class);
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Models\System\Settings\Location;
class Region
{
/**
* Mary
*/
public const MR = 'mr';
/**
* Aşgabat
*/
public const AG = 'ag';
/**
* Arkadag
*/
public const AK = 'ak';
/**
* Ahal
*/
public const AH = 'ah';
/**
* Lebap
*/
public const LB = 'lb';
/**
* Balkan
*/
public const BN = 'bn';
/**
* Daşoguz
*/
public const DZ = 'dz';
/**
* Regions
*/
public static function values(): array
{
return [
self::AG => __('Ashgabat'),
self::AK => __('Arkadag'),
self::MR => __('Mary'),
self::AH => __('Ahal'),
self::LB => __('Lebap'),
self::BN => __('Balkan'),
self::DZ => __('Dashoguz'),
];
}
/**
* Default value
*/
public static function default(): string
{
return self::AG;
}
/**
* Label for given region
*/
public static function labelFor(string $region): string
{
return static::values()[$region] ?? '';
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Models\System\Settings\Location;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class UserAddress extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'last_name',
'first_name',
'company_name',
'street_address',
'street_address_plus',
'zipcode',
'city',
'phone_number',
'is_default',
'type',
'user_id',
];
/**
* The dynamic attributes from mutators that should be returned with the user object.
*
* @var array
*/
protected $appends = [
'full_name',
];
/**
* Define if an address is default or not.
*/
public function isDefault(): bool
{
return $this->is_default === true;
}
/**
* User
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
/**
* Bootstrap the model and its traits.
*/
protected static function boot()
{
parent::boot();
static::creating(function ($address) {
if ($address->is_default) {
$address->user->addresses()->where('type', $address->type)->update([
'is_default' => false,
]);
}
});
}
}

View File

@@ -0,0 +1,85 @@
<?php
namespace App\Models\System\Settings;
class OS
{
/**
* MacOS
*/
public const MACOS = 'macos';
/**
* Linux
*/
public const LINUX = 'linux';
/**
* Windows
*/
public const WINDOWS = 'windows';
/**
* IOS
*/
public const IOS = 'ios';
/**
* Android
*/
public const ANDROID = 'android';
/**
* Operationg systems
*/
public static function types(): array
{
return [
self::IOS => 'IOS',
self::ANDROID => 'Android',
];
}
/**
* Website - shop.post.tm
*/
public const WEBSITE = 'site';
/**
* Admin panel - admin shop.post.tm
*/
public const ADMIN = 'admin';
/**
* Ecommerce app - postshop
*/
public const MOBILE_APP = 'mobile_app';
/**
* Seller app - postshop satyjy
*/
public const MOBILE_ADMIN = 'mobile_admin';
/**
* Our Apps
*/
public static function apps(): array
{
return [
self::WEBSITE => __('Website'),
self::ADMIN => __('Admin Panel'),
self::MOBILE_APP => __('Mobile app'),
self::MOBILE_ADMIN => __('Mobile admin'),
self::ANDROID => __('Android'),
self::IOS => __('IOS'),
];
}
/**
* Default value
*/
public static function default(): string
{
return self::WEBSITE;
}
}

View File

@@ -0,0 +1,83 @@
<?php
namespace App\Models\System\Settings\Payments;
use Illuminate\Database\Eloquent\Model;
use Spatie\Sluggable\HasSlug;
use Spatie\Sluggable\SlugOptions;
use Spatie\Translatable\HasTranslations;
class PaymentType extends Model
{
use HasSlug;
use HasTranslations;
/**
* Table
*
* @var string
*/
protected $table = 'payment_types';
/**
* Translatable fields
*
* @var array<int, string>
*/
public $translatable = [
'name',
];
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'code',
'name',
'tax',
'is_enabled',
'options',
];
/**
* Get the options for generating the slug.
*/
public function getSlugOptions(): SlugOptions
{
return SlugOptions::create()
->generateSlugsFrom('name')
->saveSlugsTo('code');
}
/**
* Create base payments
*/
public static function createBaseRecords(): void
{
collect([
[
'code' => 'cash',
'name' => ['en' => 'Cash', 'tk' => 'Nagt', 'ru' => 'Näliçni'],
'tax' => 0,
'is_enabled' => true,
'options' => null,
],
[
'code' => 'atm',
'name' => ['en' => 'ATM', 'tk' => 'Terminal', 'ru' => 'ATM'],
'tax' => 0,
'is_enabled' => true,
'options' => null,
],
[
'code' => 'online_halkbank',
'name' => ['en' => 'Online (halkbank)', 'tk' => 'Onlaýn (halkbank)', 'ru' => 'Onlaýn (halkbank)'],
'tax' => 0,
'is_enabled' => true,
'options' => null,
],
])->each(fn ($data) => static::create($data));
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Models\System\Settings;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
class Settings extends Model
{
use HasFactory;
use HasTranslations;
/**
* The attributes that are mass assignable.
*
* @var array<string>
*/
protected $fillable = [
'key',
'value',
'display_name',
'locked',
];
/**
* Translatable fields
*
* @var array<string>
*/
public $translatable = ['display_name'];
/**
* Sms token
*/
public static function smsToken(): string
{
return config('sms.api.token');
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Models\System\VersionManagement;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AppVersion extends Model
{
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'app_versions';
/**
* The attributes that are mass assignable.
*
* version - string
* os - string | in: ios, android
* important - bool
* notes - ?string
*
* @var array<string>
*/
protected $fillable = [
'version',
'os',
'important',
'notes',
];
}