mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-25 04:27:22 +08:00
change TorrentExtra.pt_gen setter/getter
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Nexus\Database\NexusDB;
|
use Nexus\Database\NexusDB;
|
||||||
use Nexus\Torrent\TechnicalInformation;
|
use Nexus\Torrent\TechnicalInformation;
|
||||||
|
|
||||||
@@ -11,9 +12,23 @@ class TorrentExtra extends NexusModel
|
|||||||
|
|
||||||
protected $fillable = ['torrent_id', 'descr', 'ori_descr', 'media_info', 'nfo', 'pt_gen'];
|
protected $fillable = ['torrent_id', 'descr', 'ori_descr', 'media_info', 'nfo', 'pt_gen'];
|
||||||
|
|
||||||
protected $casts = [
|
protected function ptGen(): Attribute
|
||||||
'pt_gen' => 'array',
|
{
|
||||||
];
|
return Attribute::make(
|
||||||
|
get: function ($value) {
|
||||||
|
$jsonDecoded = json_decode($value, true);
|
||||||
|
if (is_array($jsonDecoded)) {
|
||||||
|
return $jsonDecoded;
|
||||||
|
} else {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
set: function ($value) {
|
||||||
|
return is_array($value) ? json_encode($value) : $value;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function torrent()
|
public function torrent()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user