You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xshop/resources/views/segments/index/InlineMap/InlineMap.php

42 lines
1.3 KiB
PHTML

<?php
namespace Resources\Views\Segments;
use App\Models\Part;
use App\Models\Setting;
class InlineMap
{
public static function onAdd(Part $part = null)
{
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_loc';
$setting->value = '35.83266,50.99155,10';
$setting->size = 12;
$setting->type = 'LOCATION';
// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]);
$setting->title = $part->area->name . ' ' . $part->part. ' location';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_dark';
$setting->value = 0;
$setting->size = 12;
$setting->type = 'CHECKBOX';
// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]);
$setting->title = $part->area->name . ' ' . $part->part. ' dark mode';
$setting->save();
}
public static function onRemove(Part $part = null)
{
Setting::where('key',$part->area->name . '_' . $part->part.'_loc')->first()?->delete();
Setting::where('key',$part->area->name . '_' . $part->part.'_dark')->first()?->delete();
}
public static function onMount(Part $part = null)
{
return $part;
}
}