Merge remote-tracking branch 'origin/staging' into origin/production
This commit is contained in:
@@ -67,5 +67,11 @@ class Kernel extends HttpKernel
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'linksehat.old.auth' => \App\Http\Middleware\LinksehatOldAuthMiddleware::class,
|
||||
|
||||
// Role
|
||||
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ class Drug extends Model
|
||||
'remark',
|
||||
'selling_unit_id',
|
||||
'status',
|
||||
'price',
|
||||
'active',
|
||||
];
|
||||
|
||||
|
||||
19
app/Models/Navigations.php
Normal file
19
app/Models/Navigations.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Navigations extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'path',
|
||||
'icon',
|
||||
'name',
|
||||
'parent_id',
|
||||
'permission'
|
||||
];
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class NotificationToken extends Model
|
||||
'type',
|
||||
'token',
|
||||
'status',
|
||||
'device_id'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
@@ -19,6 +19,7 @@ class Prescription extends Model
|
||||
'sSource',
|
||||
'nIDUser',
|
||||
'sRegID',
|
||||
'sStatus',
|
||||
'sKodeResep',
|
||||
'sDiagnose',
|
||||
'sKodeRS',
|
||||
|
||||
@@ -19,6 +19,7 @@ class PrescriptionItem extends Model
|
||||
'sSatuan',
|
||||
'sSigna',
|
||||
'sNote',
|
||||
'nHarga',
|
||||
'isRacikan',
|
||||
'ParentCode',
|
||||
];
|
||||
|
||||
@@ -15,4 +15,9 @@ class Prescription extends Model
|
||||
'organization_id',
|
||||
'icd_code'
|
||||
];
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(PrescriptionItem::class, 'prescription_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,8 @@ class PrescriptionItem extends Model
|
||||
'signa',
|
||||
'direction'
|
||||
];
|
||||
|
||||
public function drug(){
|
||||
return $this->hasOne(Drug::class, 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@@ -29,6 +33,7 @@ class User extends Authenticatable
|
||||
'phone',
|
||||
'otp',
|
||||
'otp_created_at',
|
||||
'role_id'
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -53,13 +58,15 @@ class User extends Authenticatable
|
||||
|
||||
public $with = [
|
||||
'metas',
|
||||
'person'
|
||||
'person',
|
||||
'role',
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'meta',
|
||||
'avatar_url',
|
||||
'full_name'
|
||||
'full_name',
|
||||
'permissions'
|
||||
];
|
||||
|
||||
public function getAvatarUrlAttribute()
|
||||
@@ -82,6 +89,24 @@ class User extends Authenticatable
|
||||
return (object) $orgMeta;
|
||||
}
|
||||
|
||||
public function getPermissionsAttribute()
|
||||
{
|
||||
$roleId = $this->role_id;
|
||||
|
||||
if (!$roleId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Ambil permissions dari role_has_permissions dan permissions tabel
|
||||
$permissions = DB::table('role_has_permissions')
|
||||
->join('permissions', 'role_has_permissions.permission_id', '=', 'permissions.id')
|
||||
->where('role_has_permissions.role_id', $roleId)
|
||||
->select('permissions.id', 'permissions.name', 'permissions.guard_name')
|
||||
->get();
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
public function managedCorporates()
|
||||
{
|
||||
return $this->belongsToMany(Corporate::class, 'corporate_manager', 'user_id', 'corporate_id');
|
||||
@@ -97,7 +122,12 @@ class User extends Authenticatable
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
}
|
||||
|
||||
public function ownedPersons()
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'role_id');
|
||||
}
|
||||
|
||||
public function ownedPersons()
|
||||
{
|
||||
return $this->hasMany(Person::class, 'owner_user_id');
|
||||
}
|
||||
@@ -114,6 +144,6 @@ class User extends Authenticatable
|
||||
|
||||
public function routeNotificationForFcm()
|
||||
{
|
||||
return $this->notificationTokens()->pluck('token')->toArray();
|
||||
return $this->notificationTokens()->orderBy('created_at', 'desc')->pluck('token')->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,22 +54,27 @@ class SendNotification extends Notification
|
||||
'body' => $this->body,
|
||||
];
|
||||
|
||||
if (count($deviceTokens)){
|
||||
foreach($deviceTokens as $token) {
|
||||
$message = CloudMessage::withTarget('token', $token)
|
||||
->withNotification($notification) // optional
|
||||
->withData($this->data);
|
||||
Firebase::messaging()->send($message);
|
||||
}
|
||||
}
|
||||
// if (count($deviceTokens)){
|
||||
// foreach($deviceTokens as $token) {
|
||||
// $message = CloudMessage::withTarget('token', $token)
|
||||
// ->withNotification($notification) // optional
|
||||
// ->withData($this->data);
|
||||
// Firebase::messaging()->send($message);
|
||||
// }
|
||||
// }
|
||||
|
||||
// $datas = [
|
||||
// 'channel_id' => 2,
|
||||
|
||||
// ]
|
||||
|
||||
$dataFcm = FcmMessage::create()
|
||||
->setToken($deviceTokens[0])
|
||||
->setData([])
|
||||
->setData($this->data)
|
||||
->setNotification(
|
||||
FcmNotification::create()
|
||||
->setTitle('ini title')
|
||||
->setBody('ini body')
|
||||
->setTitle($this->title)
|
||||
->setBody($this->body)
|
||||
)
|
||||
->setAndroid(
|
||||
AndroidConfig::create()
|
||||
|
||||
Reference in New Issue
Block a user