mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-16 05:50:55 +08:00
tag add more customized options + NexusDB::rememter()
This commit is contained in:
@@ -46,10 +46,7 @@ class TagController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate($this->getRules());
|
||||
$data = $request->all();
|
||||
if (isset($data['priority'])) {
|
||||
$data['priority'] = intval($data['priority']);
|
||||
}
|
||||
$data = array_filter($request->all());
|
||||
$result = $this->repository->store($data);
|
||||
$resource = new TagResource($result);
|
||||
return $this->success($resource);
|
||||
|
||||
@@ -18,6 +18,11 @@ class TagResource extends JsonResource
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'color' => $this->color,
|
||||
'font_color' => $this->font_color,
|
||||
'font_size' => $this->font_size,
|
||||
'padding' => $this->padding,
|
||||
'margin' => $this->margin,
|
||||
'border_radius' => $this->border_radius,
|
||||
'priority' => $this->priority,
|
||||
'created_at' => format_datetime($this->created_at),
|
||||
'updated_at' => format_datetime($this->updated_at),
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class Setting extends NexusModel
|
||||
{
|
||||
@@ -10,9 +12,9 @@ class Setting extends NexusModel
|
||||
|
||||
public static function get($name = null)
|
||||
{
|
||||
static $settings;
|
||||
if (is_null($settings)) {
|
||||
$settings = NexusDB::remember("nexus_settings_in_laravel", 10, function () {
|
||||
$rows = self::query()->get(['name', 'value']);
|
||||
$result = [];
|
||||
foreach ($rows as $row) {
|
||||
$value = $row->value;
|
||||
if (!is_null($value)) {
|
||||
@@ -21,9 +23,10 @@ class Setting extends NexusModel
|
||||
$value = $arr;
|
||||
}
|
||||
}
|
||||
Arr::set($settings, $row->name, $value);
|
||||
Arr::set($result, $row->name, $value);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
});
|
||||
if (is_null($name)) {
|
||||
return $settings;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class Tag extends NexusModel
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'id', 'name', 'color', 'priority', 'created_at', 'updated_at'
|
||||
'id', 'name', 'color', 'priority', 'created_at', 'updated_at', 'font_size', 'font_color', 'padding', 'margin', 'border_radius'
|
||||
];
|
||||
|
||||
const DEFAULTS = [
|
||||
|
||||
@@ -67,7 +67,10 @@ class TagRepository extends BaseRepository
|
||||
foreach ($renderIdArr as $tagId) {
|
||||
$value = $tagKeyById->get($tagId);
|
||||
if ($value) {
|
||||
$item = "<span style=\"background-color:{$value->color};color:white;border-radius:15%\">{$value->name}</span> ";
|
||||
$item = sprintf(
|
||||
"<span style=\"background-color:%s;color:%s;border-radius:%s;font-size:%s;margin:%s;padding:%s\">%s</span>",
|
||||
$value->color, $value->font_color, $value->border_radius, $value->font_size, $value->margin, $value->padding, $value->name
|
||||
);
|
||||
if ($withFilterLink) {
|
||||
$html .= sprintf('<a href="torrents.php?tag_id=%s">%s</a>', $tagId, $item);
|
||||
} else {
|
||||
|
||||
@@ -661,8 +661,17 @@ class TrackerRepository extends BaseRepository
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Torrent $torrent
|
||||
* @param $queries
|
||||
*/
|
||||
private function updateTorrent(Torrent $torrent, $queries)
|
||||
{
|
||||
if (empty($queries['event'])) {
|
||||
do_log("no event, return", 'debug');
|
||||
return;
|
||||
}
|
||||
$torrent->seeders = Peer::query()
|
||||
->where('torrent', $torrent->id)
|
||||
->where('to_go', '=',0)
|
||||
|
||||
Reference in New Issue
Block a user