32
common/Admin/Appearance/Controllers/AppearanceController.php
Executable file
32
common/Admin/Appearance/Controllers/AppearanceController.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php namespace Common\Admin\Appearance\Controllers;
|
||||
|
||||
use Common\Admin\Appearance\AppearanceSaver;
|
||||
use Common\Admin\Appearance\AppearanceValues;
|
||||
use Common\Core\BaseController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AppearanceController extends BaseController
|
||||
{
|
||||
public function __construct(
|
||||
protected Request $request,
|
||||
protected AppearanceValues $values,
|
||||
protected AppearanceSaver $saver,
|
||||
) {
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->authorize('update', 'AppearancePolicy');
|
||||
|
||||
$this->saver->save($this->request->get('changes'));
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
public function getValues(): JsonResponse
|
||||
{
|
||||
$this->authorize('update', 'AppearancePolicy');
|
||||
|
||||
return $this->success($this->values->get());
|
||||
}
|
||||
}
|
||||
55
common/Admin/Appearance/Controllers/SeoTagsController.php
Executable file
55
common/Admin/Appearance/Controllers/SeoTagsController.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Common\Admin\Appearance\Controllers;
|
||||
|
||||
use Common\Core\BaseController;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class SeoTagsController extends BaseController
|
||||
{
|
||||
public function show(string $names)
|
||||
{
|
||||
$this->authorize('update', 'AppearancePolicy');
|
||||
|
||||
$names = explode(',', $names);
|
||||
|
||||
$response = [];
|
||||
|
||||
foreach ($names as $name) {
|
||||
try {
|
||||
$customView = storage_path(
|
||||
"app/editable-views/seo-tags/$name.blade.php",
|
||||
);
|
||||
$response[$name] = [
|
||||
'custom' => file_exists($customView)
|
||||
? file_get_contents($customView)
|
||||
: null,
|
||||
'original' => file_get_contents(
|
||||
resource_path("views/seo/$name/seo-tags.blade.php"),
|
||||
),
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($response);
|
||||
}
|
||||
|
||||
public function update(string $name)
|
||||
{
|
||||
$this->authorize('update', 'AppearancePolicy');
|
||||
|
||||
$data = $this->validate(request(), [
|
||||
'tags' => 'required|string',
|
||||
]);
|
||||
|
||||
$directory = storage_path('app/editable-views/seo-tags');
|
||||
File::ensureDirectoryExists($directory);
|
||||
|
||||
file_put_contents("$directory/$name.blade.php", $data['tags']);
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user