first commit
This commit is contained in:
73
app/Models/BookkeepingDocument.php
Normal file
73
app/Models/BookkeepingDocument.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Storage;
|
||||
|
||||
class BookkeepingDocument extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const PATH_PREFIX = 'public/bookkeeping';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
'user_id',
|
||||
'batch_name',
|
||||
'remark',
|
||||
'file_name',
|
||||
'bookkeeping_document_category_id',
|
||||
'status',
|
||||
'data_molino_status',
|
||||
'data_molino_return_status',
|
||||
'xero_status',
|
||||
'xero_amount',
|
||||
'url',
|
||||
'name',
|
||||
'description',
|
||||
'file_size',
|
||||
];
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(BookkeepingDocumentCategory::class, 'bookkeeping_document_category_id', 'id');
|
||||
}
|
||||
|
||||
public function getFolderPathAttribute()
|
||||
{
|
||||
return self::PATH_PREFIX . '/' . $this->id;
|
||||
}
|
||||
|
||||
public function getFilePathAttribute()
|
||||
{
|
||||
return ! $this->file_name ? null : $this->getFolderPathAttribute() . "/{$this->file_name}";
|
||||
}
|
||||
|
||||
public function getFileUrlAttribute()
|
||||
{
|
||||
$path = $this->getFilePathAttribute();
|
||||
|
||||
if ($path && Storage::exists($path)) {
|
||||
return env('AWS_ENDPOINT') . env('AWS_BUCKET') . '/' . $path;
|
||||
}
|
||||
|
||||
return '#';
|
||||
}
|
||||
}
|
||||
21
app/Models/BookkeepingDocumentCategory.php
Normal file
21
app/Models/BookkeepingDocumentCategory.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BookkeepingDocumentCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
];
|
||||
}
|
||||
47
app/Models/Company.php
Normal file
47
app/Models/Company.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Company extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'email',
|
||||
'name_english',
|
||||
'name_chinese',
|
||||
'registered_office_address_english',
|
||||
'registered_office_address_chinese',
|
||||
'br_number',
|
||||
'xero_api_key',
|
||||
];
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
if (strtolower(app()->getLocale()) == 'zh_hk') {
|
||||
return $this->name_chinese;
|
||||
}
|
||||
return $this->name_english;
|
||||
}
|
||||
|
||||
public function getRegisteredOfficeAddressAttribute()
|
||||
{
|
||||
if (strtolower(app()->getLocale()) == 'zh_hk') {
|
||||
return $this->registered_office_address_chinese;
|
||||
}
|
||||
return $this->registered_office_address_english;
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
}
|
||||
23
app/Models/CompanyDocument.php
Normal file
23
app/Models/CompanyDocument.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CompanyDocument extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
'member_id',
|
||||
'filename',
|
||||
'url',
|
||||
];
|
||||
}
|
||||
39
app/Models/CompanyMember.php
Normal file
39
app/Models/CompanyMember.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CompanyMember extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
'position',
|
||||
'title',
|
||||
'name_english',
|
||||
'name_chinese',
|
||||
'phone',
|
||||
'email',
|
||||
'document_type',
|
||||
'document_number',
|
||||
'country',
|
||||
'address_english',
|
||||
'address_chinese',
|
||||
'year_date',
|
||||
'month_date',
|
||||
'day_date',
|
||||
];
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->hasMany(CompanyDocument::class, 'member_id', 'id');
|
||||
}
|
||||
}
|
||||
34
app/Models/CompanySubscription.php
Normal file
34
app/Models/CompanySubscription.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CompanySubscription extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
'subscription_id',
|
||||
'stripe_subscription_id',
|
||||
'status',
|
||||
'expiration_at',
|
||||
];
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->hasOne(Company::class, 'id', 'company_id');
|
||||
}
|
||||
|
||||
public function subscription()
|
||||
{
|
||||
return $this->hasOne(Subscription::class, 'id', 'subscription_id');
|
||||
}
|
||||
}
|
||||
29
app/Models/DocumentActionLogs.php
Normal file
29
app/Models/DocumentActionLogs.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DocumentActionLogs extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'event',
|
||||
'description',
|
||||
'status',
|
||||
'type',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
24
app/Models/InviteUser.php
Normal file
24
app/Models/InviteUser.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class InviteUser extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'email',
|
||||
'token',
|
||||
'user_id',
|
||||
'company_id',
|
||||
'is_used',
|
||||
];
|
||||
}
|
||||
49
app/Models/OnlineHelp.php
Normal file
49
app/Models/OnlineHelp.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OnlineHelp extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title_english',
|
||||
'title_chinese',
|
||||
'details_english',
|
||||
'details_chinese',
|
||||
'category',
|
||||
'sort',
|
||||
];
|
||||
|
||||
public function getTitleAttribute()
|
||||
{
|
||||
if (strtolower(app()->getLocale()) == 'zh_hk') {
|
||||
return $this->title_chinese;
|
||||
}
|
||||
return $this->title_english;
|
||||
}
|
||||
|
||||
public function getDetailsAttribute()
|
||||
{
|
||||
if (strtolower(app()->getLocale()) == 'zh_hk') {
|
||||
return $this->detailss_chinese;
|
||||
}
|
||||
return $this->detailss_english;
|
||||
}
|
||||
|
||||
public function getCategoryNameDisplayAttribute()
|
||||
{
|
||||
if ($this->category == 'faq') {
|
||||
return __("FAQ");
|
||||
}
|
||||
return __("Online Documents");
|
||||
}
|
||||
}
|
||||
16
app/Models/Permission.php
Normal file
16
app/Models/Permission.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Permission extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function permissionGroup()
|
||||
{
|
||||
return $this->hasOne(PermissionGroup::class, 'id', 'permission_group_id');
|
||||
}
|
||||
}
|
||||
16
app/Models/PermissionGroup.php
Normal file
16
app/Models/PermissionGroup.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PermissionGroup extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function permissions()
|
||||
{
|
||||
return $this->hasMany(Permission::class);
|
||||
}
|
||||
}
|
||||
34
app/Models/PermissionRole.php
Normal file
34
app/Models/PermissionRole.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PermissionRole extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'permission_id',
|
||||
'role_id',
|
||||
'company_id',
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function permission()
|
||||
{
|
||||
return $this->hasOne(Permission::class, 'id', 'permission_id');
|
||||
}
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->hasOne(Role::class, 'id', 'role_id');
|
||||
}
|
||||
}
|
||||
50
app/Models/Role.php
Normal file
50
app/Models/Role.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
// Built In Roles
|
||||
public const ADMIN_ROLE = 1;
|
||||
public const TRIAL_ROLE = 2;
|
||||
public const BASIC_ROLE = 3;
|
||||
public const PRO_ROLE = 4;
|
||||
public const PREMIUM_ROLE = 5;
|
||||
public const CANCELLED_ROLE = 6;
|
||||
|
||||
// Custom Roles
|
||||
// User
|
||||
public const OWNER_ROLE = 7;
|
||||
public const ADMINISTRATOR_ROLE = 8;
|
||||
public const BOOKKEEPER_ROLE = 9;
|
||||
public const COMPANY_SECRETARY_ROLE = 10;
|
||||
// Admin
|
||||
public const IT_PERSONNEL_ROLE = 11;
|
||||
public const NUMSTATION_MANAGER_ROLE = 12;
|
||||
public const NUMSTATION_STAFF_ROLE = 13;
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function rolePermissions()
|
||||
{
|
||||
return $this->hasMany(PermissionRole::class);
|
||||
}
|
||||
|
||||
public function hasAccess($permissionKey)
|
||||
{
|
||||
$permission = Permission::where('key', $permissionKey)->first();
|
||||
if ($permission) {
|
||||
return $this->rolePermissions()->where('permission_id', $permission->id)->exists();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
44
app/Models/ServiceChat.php
Normal file
44
app/Models/ServiceChat.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServiceChat extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const PATH_PREFIX = 'public/chats';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
'user_id',
|
||||
'service_type',
|
||||
];
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return $this->hasMany(ServiceChatMessage::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function getFolderPathAttribute()
|
||||
{
|
||||
return self::PATH_PREFIX . '/' . $this->id;
|
||||
}
|
||||
}
|
||||
78
app/Models/ServiceChatMessage.php
Normal file
78
app/Models/ServiceChatMessage.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Storage;
|
||||
|
||||
class ServiceChatMessage extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const PATH_PREFIX = 'public/chats';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'service_chat_id',
|
||||
'message',
|
||||
'from_user_id',
|
||||
'to_user_id',
|
||||
'to_admin',
|
||||
'is_file',
|
||||
'file_name',
|
||||
'is_read',
|
||||
];
|
||||
|
||||
public function getElapsedTimeAttribute()
|
||||
{
|
||||
$time = time() - $this->created_at->timestamp;
|
||||
$time = $time < 1 ? 1 : $time;
|
||||
$tokens = [
|
||||
31536000 => 'year',
|
||||
2592000 => 'month',
|
||||
604800 => 'week',
|
||||
86400 => 'day',
|
||||
3600 => 'hour',
|
||||
60 => 'min',
|
||||
1 => 'second',
|
||||
];
|
||||
|
||||
foreach ($tokens as $unit => $text) {
|
||||
if ($time < $unit) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$numberOfUnits = floor($time / $unit);
|
||||
|
||||
return $numberOfUnits . ' ' . $text . ($numberOfUnits > 1 ? 's' : '') . ' ago';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getFolderPathAttribute()
|
||||
{
|
||||
return self::PATH_PREFIX . '/' . $this->service_chat_id;
|
||||
}
|
||||
|
||||
public function getFilePathAttribute()
|
||||
{
|
||||
return ! $this->file_name ? null : $this->getFolderPathAttribute() . "/{$this->file_name}";
|
||||
}
|
||||
|
||||
public function getFileUrlAttribute()
|
||||
{
|
||||
$path = $this->getFilePathAttribute();
|
||||
|
||||
if ($path && Storage::exists($path)) {
|
||||
return env('AWS_ENDPOINT') . env('AWS_BUCKET') . '/' . $path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
63
app/Models/SiteSetting.php
Normal file
63
app/Models/SiteSetting.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SiteSetting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'terms_and_conditions_english',
|
||||
'terms_and_conditions_chinese',
|
||||
'privacy_policy_english',
|
||||
'privacy_policy_chinese',
|
||||
'phone',
|
||||
'whatsapp',
|
||||
'email',
|
||||
'office_hour_english',
|
||||
'office_hour_chinese',
|
||||
'address_english',
|
||||
'address_chinese',
|
||||
'google_drive_api_key',
|
||||
];
|
||||
|
||||
public function getTermsAndConditionsAttribute()
|
||||
{
|
||||
if (strtolower(app()->getLocale()) == 'zh_hk') {
|
||||
return $this->terms_and_conditions_chinese;
|
||||
}
|
||||
return $this->terms_and_conditions_english;
|
||||
}
|
||||
|
||||
public function getPrivacyPolicyAttribute()
|
||||
{
|
||||
if (strtolower(app()->getLocale()) == 'zh_hk') {
|
||||
return $this->privacy_policy_chinese;
|
||||
}
|
||||
return $this->privacy_policy_english;
|
||||
}
|
||||
|
||||
public function getOfficeHourAttribute()
|
||||
{
|
||||
if (strtolower(app()->getLocale()) == 'zh_hk') {
|
||||
return $this->office_hour_chinese;
|
||||
}
|
||||
return $this->office_hour_english;
|
||||
}
|
||||
|
||||
public function getAddressAttribute()
|
||||
{
|
||||
if (strtolower(app()->getLocale()) == 'zh_hk') {
|
||||
return $this->address_chinese;
|
||||
}
|
||||
return $this->address_english;
|
||||
}
|
||||
}
|
||||
38
app/Models/Subscription.php
Normal file
38
app/Models/Subscription.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Subscription extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'service_type',
|
||||
'name_english',
|
||||
'name_chinese',
|
||||
'period_english',
|
||||
'period_chinese',
|
||||
'description_english',
|
||||
'description_chinese',
|
||||
'price',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function basicServices()
|
||||
{
|
||||
return $this->hasMany(SubscriptionBasicService::class);
|
||||
}
|
||||
|
||||
public function optionalServices()
|
||||
{
|
||||
return $this->hasMany(SubscriptionOptionalService::class);
|
||||
}
|
||||
}
|
||||
27
app/Models/SubscriptionBasicService.php
Normal file
27
app/Models/SubscriptionBasicService.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SubscriptionBasicService extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'subscription_id',
|
||||
'title_english',
|
||||
'title_chinese',
|
||||
];
|
||||
|
||||
public function lists()
|
||||
{
|
||||
return $this->hasMany(SubscriptionBasicServiceList::class);
|
||||
}
|
||||
}
|
||||
22
app/Models/SubscriptionBasicServiceList.php
Normal file
22
app/Models/SubscriptionBasicServiceList.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SubscriptionBasicServiceList extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'subscription_basic_service_id',
|
||||
'title_english',
|
||||
'title_chinese',
|
||||
];
|
||||
}
|
||||
26
app/Models/SubscriptionOptionalService.php
Normal file
26
app/Models/SubscriptionOptionalService.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SubscriptionOptionalService extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'subscription_id',
|
||||
'title_english',
|
||||
'title_chinese',
|
||||
'price',
|
||||
'period',
|
||||
'is_custom',
|
||||
'custom_description',
|
||||
];
|
||||
}
|
||||
126
app/Models/User.php
Normal file
126
app/Models/User.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Wave\User as Authenticatable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable, SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'username',
|
||||
'password',
|
||||
'verification_code',
|
||||
'verified',
|
||||
'trial_ends_at',
|
||||
'company_id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'alias_name',
|
||||
'phone',
|
||||
'forgot_password_otp',
|
||||
'status',
|
||||
'role_id',
|
||||
'api_token',
|
||||
'admin_active_company_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'trial_ends_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function getRedirectRoute()
|
||||
{
|
||||
switch ($this->role_id) {
|
||||
case Role::OWNER_ROLE:
|
||||
return RouteServiceProvider::USER_HOME;
|
||||
case Role::ADMINISTRATOR_ROLE:
|
||||
return RouteServiceProvider::USER_HOME;
|
||||
case Role::BOOKKEEPER_ROLE:
|
||||
return RouteServiceProvider::USER_HOME;
|
||||
case Role::COMPANY_SECRETARY_ROLE:
|
||||
return RouteServiceProvider::USER_HOME;
|
||||
case Role::IT_PERSONNEL_ROLE:
|
||||
return RouteServiceProvider::ADMIN_HOME;
|
||||
case Role::NUMSTATION_MANAGER_ROLE:
|
||||
return RouteServiceProvider::ADMIN_HOME;
|
||||
case Role::NUMSTATION_STAFF_ROLE:
|
||||
return RouteServiceProvider::ADMIN_HOME;
|
||||
default:
|
||||
return RouteServiceProvider::USER_HOME;
|
||||
}
|
||||
}
|
||||
|
||||
public function getRedirectRouteIfNotAuthenticated()
|
||||
{
|
||||
switch ($this->role_id) {
|
||||
case Role::OWNER_ROLE:
|
||||
return RouteServiceProvider::USER_LOGIN;
|
||||
case Role::ADMINISTRATOR_ROLE:
|
||||
return RouteServiceProvider::USER_LOGIN;
|
||||
case Role::BOOKKEEPER_ROLE:
|
||||
return RouteServiceProvider::USER_LOGIN;
|
||||
case Role::COMPANY_SECRETARY_ROLE:
|
||||
return RouteServiceProvider::USER_LOGIN;
|
||||
case Role::IT_PERSONNEL_ROLE:
|
||||
return RouteServiceProvider::ADMIN_LOGIN;
|
||||
case Role::NUMSTATION_MANAGER_ROLE:
|
||||
return RouteServiceProvider::ADMIN_LOGIN;
|
||||
case Role::NUMSTATION_STAFF_ROLE:
|
||||
return RouteServiceProvider::ADMIN_LOGIN;
|
||||
default:
|
||||
return RouteServiceProvider::USER_LOGIN;
|
||||
}
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function notificationSettings()
|
||||
{
|
||||
return $this->hasMany(UserNotificationSetting::class);
|
||||
}
|
||||
|
||||
public function userRole()
|
||||
{
|
||||
return $this->hasOne(Role::class, 'id', 'role_id');
|
||||
}
|
||||
|
||||
public function notifications()
|
||||
{
|
||||
return $this->hasMany(UserNotification::class);
|
||||
}
|
||||
|
||||
public function adminActiveCompany()
|
||||
{
|
||||
return $this->hasOne(Company::class, 'id', 'admin_active_company_id');
|
||||
}
|
||||
}
|
||||
23
app/Models/UserAccessLog.php
Normal file
23
app/Models/UserAccessLog.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserAccessLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'event',
|
||||
'description',
|
||||
'status'
|
||||
];
|
||||
}
|
||||
11
app/Models/UserCompany.php
Normal file
11
app/Models/UserCompany.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserCompany extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
33
app/Models/UserEnquiry.php
Normal file
33
app/Models/UserEnquiry.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserEnquiry extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name',
|
||||
'phone',
|
||||
'email',
|
||||
'title',
|
||||
'message',
|
||||
'category',
|
||||
'status',
|
||||
'reply',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
72
app/Models/UserNotification.php
Normal file
72
app/Models/UserNotification.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserNotification extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'title',
|
||||
'description',
|
||||
'category',
|
||||
'target_id',
|
||||
'target_type',
|
||||
'is_read',
|
||||
'is_admin',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
$url = '';
|
||||
if (strtolower($this->category) == 'service chat') {
|
||||
$url = route('cms.chat');
|
||||
$chat = ServiceChat::find($this->target_id);
|
||||
if ($chat) {
|
||||
$url = $url . '?user_id=' . $chat->user_id . '&company_id=' . $chat->company_id . '&chat_id=' . $this->target_id;
|
||||
}
|
||||
}
|
||||
else if (strtolower($this->category) == 'bookkeeping queue') {
|
||||
$url = route('cms.bookkeepings');
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function getCategoryUrlAttribute()
|
||||
{
|
||||
$url = '';
|
||||
if (strtolower($this->category) == 'service chat') {
|
||||
$url = route('cms.chat');
|
||||
}
|
||||
else if (strtolower($this->category) == 'bookkeeping queue') {
|
||||
$url = route('cms.bookkeepings');
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function getImageUrlAttribute()
|
||||
{
|
||||
$url = '';
|
||||
if (strtolower($this->category) == 'service chat') {
|
||||
$url = asset('themes/tailwind/images/building.svg');
|
||||
}
|
||||
else if (strtolower($this->category) == 'bookkeeping queue') {
|
||||
$ext = pathinfo($this->description, PATHINFO_EXTENSION);
|
||||
$url = $ext == 'pdf' ? asset('themes/tailwind/images/pdf.svg') : asset('themes/tailwind/images/jpg.svg');
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
28
app/Models/UserNotificationSetting.php
Normal file
28
app/Models/UserNotificationSetting.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserNotificationSetting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
//
|
||||
public const USER_PUSH_NOTIFICATION = 'user_push_notification';
|
||||
public const USER_BOOKKEEPING_QUEUE = 'user_bookkeeping_queue';
|
||||
public const USER_COMPANY_SECURTY_QUEUE = 'user_company_securty_queue';
|
||||
public const USER_CHAT_ROOM = 'user_chat_room';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'notification',
|
||||
'is_active',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user