reupload
This commit is contained in:
28
app/Models/System/Settings/Currency.php
Normal file
28
app/Models/System/Settings/Currency.php
Normal 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',
|
||||
];
|
||||
}
|
||||
40
app/Models/System/Settings/Location/Province.php
Normal file
40
app/Models/System/Settings/Location/Province.php
Normal 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);
|
||||
}
|
||||
}
|
||||
73
app/Models/System/Settings/Location/Region.php
Normal file
73
app/Models/System/Settings/Location/Region.php
Normal 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] ?? '';
|
||||
}
|
||||
}
|
||||
73
app/Models/System/Settings/Location/UserAddress.php
Normal file
73
app/Models/System/Settings/Location/UserAddress.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
85
app/Models/System/Settings/OS.php
Normal file
85
app/Models/System/Settings/OS.php
Normal 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;
|
||||
}
|
||||
}
|
||||
83
app/Models/System/Settings/Payments/PaymentType.php
Normal file
83
app/Models/System/Settings/Payments/PaymentType.php
Normal 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));
|
||||
}
|
||||
}
|
||||
40
app/Models/System/Settings/Settings.php
Normal file
40
app/Models/System/Settings/Settings.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user