File: /home/armgroup/libs/app/Models/Point.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Point extends Model
{
use HasFactory;
protected $guarded = ['id'];
public const TYPE = [
[
'name' => 'ادمین',
'show-name' => 'ادمین',
'slug' => 'User',
'className' => User::class,
],
[
'name' => 'سفارشات',
'show-name' => 'سفارش',
'slug' => 'Order',
'className' => Order::class,
],
];
public function pointable()
{
return $this->morphTo();
}
public function user()
{
return $this->belongsTo(User::class);
}
public function getWalletType()
{
return collect(self::TYPE)->firstWhere('className', $this->pointable_type);
}
}