2022-03-05 16:02:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2022-07-20 06:35:12 +02:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2022-03-05 16:02:12 +01:00
|
|
|
|
|
|
|
class Misc extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
public $incrementing = false;
|
|
|
|
|
|
|
|
protected $table = 'misc_services';
|
|
|
|
|
2022-07-22 15:49:18 +02:00
|
|
|
protected $keyType = 'string';
|
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
protected $fillable = ['id', 'name', 'owned_since'];
|
2022-07-20 06:35:12 +02:00
|
|
|
|
|
|
|
public static function allMisc()
|
|
|
|
{//All misc and relationships (no using joins)
|
|
|
|
return Cache::remember("all_misc", now()->addMonth(1), function () {
|
|
|
|
return Misc::with(['price'])->get();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function misc(string $misc_id)
|
|
|
|
{//Single misc and relationships (no using joins)
|
|
|
|
return Cache::remember("misc.$misc_id", now()->addMonth(1), function () use ($misc_id) {
|
|
|
|
return Misc::where('id', $misc_id)
|
|
|
|
->with(['price'])->get();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function price()
|
|
|
|
{
|
|
|
|
return $this->hasOne(Pricing::class, 'service_id', 'id');
|
|
|
|
}
|
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
}
|