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/login/LoginPatternBg/LoginPatternBg.php

58 lines
2.0 KiB
PHP

<?php
namespace Resources\Views\Segments;
use App\Models\Part;
use App\Models\Setting;
use Illuminate\Support\Facades\File;
class LoginPatternBg
{
public static function onAdd(Part $part = null)
{
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_color1';
$setting->value = gfx()['primary'];
$setting->type = 'COLOR';
$setting->data = json_encode(['name' => 'login-bg-color-1']);
$setting->size = 6;
$setting->title = $part->area->name . ' ' . $part->part .' second gradiant color 1';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_color2';
$setting->value = gfx()['secondary'];
$setting->data = json_encode(['name' => 'login-bg-color-2']);
$setting->type = 'COLOR';
$setting->size = 6;
$setting->title = $part->area->name . ' ' . $part->part .' second gradiant color 2';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_png';
$setting->value = null;
$setting->type = 'FILE';
$setting->size = 12;
$setting->title = $part->area->name . ' ' . $part->part.' background pattern image';
$setting->save();
File::copy(__DIR__.'/../../default-assets/pattern.png',public_path('upload/images/').$part->area->name . '.' . $part->part.'.jpg');
}
public static function onRemove(Part $part = null)
{
Setting::where('key',$part->area->name . '_' . $part->part.'_png')->first()?->delete();
Setting::where('key',$part->area->name . '_' . $part->part.'_color1')->first()?->delete();
Setting::where('key',$part->area->name . '_' . $part->part.'_color2')->first()?->delete();
}
public static function onMount(Part $part = null)
{
return $part;
}
}