mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
added it_update_settings, it_get_page, it_update_settings_image test
This commit is contained in:
@@ -97,11 +97,6 @@ class SetupDevEnvironment extends Command
|
||||
->each(function ($content) {
|
||||
Setting::updateOrCreate($content);
|
||||
});
|
||||
|
||||
collect(config('content.pages'))
|
||||
->each(function ($page) {
|
||||
Page::updateOrCreate($page);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,6 +184,8 @@ class SetupDevEnvironment extends Command
|
||||
$this->call('migrate:fresh', [
|
||||
'--force' => true
|
||||
]);
|
||||
|
||||
$this->setup->seed_default_pages();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,8 +21,7 @@ class PagesController extends Controller
|
||||
public function index()
|
||||
{
|
||||
return new PageCollection(
|
||||
Page::sortable()
|
||||
->paginate(10)
|
||||
Page::sortable()->paginate(10)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -34,9 +33,7 @@ class PagesController extends Controller
|
||||
*/
|
||||
public function show(Page $page)
|
||||
{
|
||||
return new PageResource(
|
||||
$page
|
||||
);
|
||||
return new PageResource($page);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +49,9 @@ class PagesController extends Controller
|
||||
return Demo::response_204();
|
||||
}
|
||||
|
||||
$page->update(make_single_input($request));
|
||||
$page->update(
|
||||
make_single_input($request)
|
||||
);
|
||||
|
||||
return response(new PageResource($page), 204);
|
||||
}
|
||||
|
||||
@@ -336,17 +336,17 @@ class SetupWizardController extends Controller
|
||||
|
||||
// Store Logo
|
||||
if ($request->hasFile('logo')) {
|
||||
$logo = store_system_image($request->file('logo'), 'system');
|
||||
$logo = store_system_image($request->file('logo'));
|
||||
}
|
||||
|
||||
// Store Logo horizontal
|
||||
if ($request->hasFile('logo_horizontal')) {
|
||||
$logo_horizontal = store_system_image($request->file('logo_horizontal'), 'system');
|
||||
$logo_horizontal = store_system_image($request->file('logo_horizontal'));
|
||||
}
|
||||
|
||||
// Store favicon
|
||||
if ($request->hasFile('favicon')) {
|
||||
$favicon = store_system_image($request->file('favicon'), 'system');
|
||||
$favicon = store_system_image($request->file('favicon'));
|
||||
}
|
||||
|
||||
// Get options
|
||||
@@ -467,13 +467,6 @@ class SetupWizardController extends Controller
|
||||
'value' => $request->purchase_code,
|
||||
]);
|
||||
|
||||
// Create legal pages and index content
|
||||
$content = $request->license === 'Extended' ? collect(config('content.content_extended')) : collect(config('content.content_regular'));
|
||||
|
||||
$content->each(function ($content) {
|
||||
Setting::updateOrCreate($content);
|
||||
});
|
||||
|
||||
// Retrieve access token
|
||||
$response = Route::dispatch(self::make_login_request($request));
|
||||
|
||||
@@ -503,7 +496,7 @@ class SetupWizardController extends Controller
|
||||
'--force' => true
|
||||
]);
|
||||
|
||||
$this->setup->seed_pages();
|
||||
$this->setup->seed_default_pages();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Setting;
|
||||
use App\Models\Setting;
|
||||
use Artisan;
|
||||
use Stripe;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
@@ -40,7 +40,6 @@ class SettingController extends Controller
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
@@ -48,21 +47,23 @@ class SettingController extends Controller
|
||||
// Store image if exist
|
||||
if ($request->hasFile($request->name)) {
|
||||
|
||||
// Store image
|
||||
$image_path = store_system_image($request->file($request->name), 'system');
|
||||
|
||||
// Find and update image path
|
||||
Setting::updateOrCreate(['name' => $request->name], [
|
||||
'value' => $image_path
|
||||
Setting::updateOrCreate([
|
||||
'name' => $request->name
|
||||
], [
|
||||
'value' => store_system_image(
|
||||
$request->file($request->name)
|
||||
)
|
||||
]);
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
// Find and update variable
|
||||
Setting::updateOrCreate(['name' => $request->name], [
|
||||
'value' => $request->value
|
||||
]);
|
||||
Setting::updateOrCreate(
|
||||
['name' => $request->name],
|
||||
['value' => $request->value]
|
||||
);
|
||||
|
||||
return response('Done', 204);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,7 @@ function obfuscate_email($email)
|
||||
*/
|
||||
function get_setting($setting)
|
||||
{
|
||||
$row = Setting::where('name', $setting)->first();
|
||||
|
||||
return $row ? $row->value : null;
|
||||
return Setting::find($setting)->value ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,13 +254,13 @@ function store_avatar($image)
|
||||
function store_system_image($image)
|
||||
{
|
||||
// Store avatar
|
||||
$image_path = Str::random(8) . '-' . str_replace(' ', '', $image->getClientOriginalName());
|
||||
$filename = Str::random(8) . '-' . str_replace(' ', '', $image->getClientOriginalName());
|
||||
|
||||
// Store image to disk
|
||||
Storage::putFileAs('system', $image, $image_path);
|
||||
Storage::putFileAs('system', $image, $filename);
|
||||
|
||||
// Return path to image
|
||||
return `system/$image_path`;
|
||||
return "system/$filename";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,13 @@ class Setting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'value',
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $primaryKey = 'name';
|
||||
|
||||
protected $keyType = 'string';
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use App\Models\Page;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class SetupService
|
||||
@@ -29,11 +28,24 @@ class SetupService
|
||||
/**
|
||||
* Store default pages content like Terms of Service, Privacy Policy and Cookie Policy into database
|
||||
*/
|
||||
public function seed_pages()
|
||||
public function seed_default_pages()
|
||||
{
|
||||
collect(config('content.pages'))
|
||||
->each(function ($page) {
|
||||
Page::updateOrCreate($page);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Store default VueFileManager settings into database
|
||||
*
|
||||
* @param $license
|
||||
*/
|
||||
public function seed_default_settings($license)
|
||||
{
|
||||
collect(config('content.content.' . strtolower($license)))
|
||||
->each(function ($content) {
|
||||
Setting::forceCreate($content);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'pages' => [
|
||||
'pages' => [
|
||||
[
|
||||
'visibility' => 0,
|
||||
'title' => 'Terms of Service',
|
||||
@@ -21,152 +21,154 @@ return [
|
||||
'content' => 'Metus penatibus ligula dolor natoque non habitasse laoreet facilisis, libero vivamus eget semper vulputate interdum integer, phasellus lorem enim blandit consectetur nullam sollicitudin. Hendrerit interdum luctus ut in molestie himenaeos eros cum laoreet parturient est, eu lectus hac et netus viverra dictumst congue elit sem senectus litora, fames scelerisque adipiscing inceptos fringilla montes sociosqu suscipit auctor potenti. Elementum lacus vulputate viverra ac morbi ligula ipsum facilisi, sit eu imperdiet lacinia congue dis vitae.',
|
||||
],
|
||||
],
|
||||
'content_regular' => [
|
||||
[
|
||||
'name' => 'section_features',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'section_feature_boxes',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'section_get_started',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'header_title',
|
||||
'value' => 'Simple <span style="color: #41B883">&</span> Powerful Personal Cloud Storage',
|
||||
],
|
||||
[
|
||||
'name' => 'header_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'features_title',
|
||||
'value' => 'The Fastest Growing <span style="color: #41B883">File Manager</span> on the CodeCanyon Market',
|
||||
],
|
||||
[
|
||||
'name' => 'features_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_1',
|
||||
'value' => 'Truly Freedom',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_1',
|
||||
'value' => 'You have full control over VueFileManager, no third authorities will control your service or usage, only you.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_2',
|
||||
'value' => 'The Sky is the Limit',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_2',
|
||||
'value' => 'VueFileManager is cloud storage software. You have to install and running application on your own server hosting.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_3',
|
||||
'value' => 'No Monthly Fees',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_3',
|
||||
'value' => 'When you running VueFileManager on your own server hosting, anybody can\'t control your content or resell your user data. Your data is safe.',
|
||||
],
|
||||
[
|
||||
'name' => 'get_started_title',
|
||||
'value' => 'Ready to Get <span style="color: #41B883">Started</span><br> With Us?',
|
||||
],
|
||||
[
|
||||
'name' => 'get_started_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'footer_content',
|
||||
'value' => '© 2021 Simple & Powerful Personal Cloud Storage. Developed by <a href="https://hi5ve.digital" target="_blank">Hi5Ve.Digital</a>',
|
||||
],
|
||||
[
|
||||
'name' => 'allow_homepage',
|
||||
'value' => 1,
|
||||
],
|
||||
],
|
||||
'content_extended' => [
|
||||
[
|
||||
'name' => 'section_features',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'section_feature_boxes',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'section_pricing_content',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'section_get_started',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'header_title',
|
||||
'value' => 'Simple <span style="color: #41B883">&</span> Powerful Personal Cloud Storage',
|
||||
],
|
||||
[
|
||||
'name' => 'header_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'features_title',
|
||||
'value' => 'The Fastest Growing <span style="color: #41B883">File Manager</span> on the CodeCanyon Market',
|
||||
],
|
||||
[
|
||||
'name' => 'features_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_1',
|
||||
'value' => 'Truly Freedom',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_1',
|
||||
'value' => 'You have full control over VueFileManager, no third authorities will control your service or usage, only you.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_2',
|
||||
'value' => 'The Sky is the Limit',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_2',
|
||||
'value' => 'VueFileManager is cloud storage software. You have to install and running application on your own server hosting.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_3',
|
||||
'value' => 'No Monthly Fees',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_3',
|
||||
'value' => 'When you running VueFileManager on your own server hosting, anybody can\'t control your content or resell your user data. Your data is safe.',
|
||||
],
|
||||
[
|
||||
'name' => 'pricing_title',
|
||||
'value' => 'Pick the <span style="color: #41B883;">Best Plan</span> For Your Needs',
|
||||
],
|
||||
[
|
||||
'name' => 'pricing_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'get_started_title',
|
||||
'value' => 'Ready to Get <span style="color: #41B883">Started</span><br> With Us?',
|
||||
],
|
||||
[
|
||||
'name' => 'get_started_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'footer_content',
|
||||
'value' => '© 2021 Simple & Powerful Personal Cloud Storage. Developed by <a href="https://hi5ve.digital" target="_blank">Hi5Ve.Digital</a>',
|
||||
'content' => [
|
||||
'regular' => [
|
||||
[
|
||||
'name' => 'section_features',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'section_feature_boxes',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'section_get_started',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'header_title',
|
||||
'value' => 'Simple <span style="color: #41B883">&</span> Powerful Personal Cloud Storage',
|
||||
],
|
||||
[
|
||||
'name' => 'header_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'features_title',
|
||||
'value' => 'The Fastest Growing <span style="color: #41B883">File Manager</span> on the CodeCanyon Market',
|
||||
],
|
||||
[
|
||||
'name' => 'features_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_1',
|
||||
'value' => 'Truly Freedom',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_1',
|
||||
'value' => 'You have full control over VueFileManager, no third authorities will control your service or usage, only you.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_2',
|
||||
'value' => 'The Sky is the Limit',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_2',
|
||||
'value' => 'VueFileManager is cloud storage software. You have to install and running application on your own server hosting.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_3',
|
||||
'value' => 'No Monthly Fees',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_3',
|
||||
'value' => 'When you running VueFileManager on your own server hosting, anybody can\'t control your content or resell your user data. Your data is safe.',
|
||||
],
|
||||
[
|
||||
'name' => 'get_started_title',
|
||||
'value' => 'Ready to Get <span style="color: #41B883">Started</span><br> With Us?',
|
||||
],
|
||||
[
|
||||
'name' => 'get_started_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'footer_content',
|
||||
'value' => '© 2021 Simple & Powerful Personal Cloud Storage. Developed by <a href="https://hi5ve.digital" target="_blank">Hi5Ve.Digital</a>',
|
||||
],
|
||||
[
|
||||
'name' => 'allow_homepage',
|
||||
'value' => 1,
|
||||
],
|
||||
],
|
||||
'extended' => [
|
||||
[
|
||||
'name' => 'section_features',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'section_feature_boxes',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'section_pricing_content',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'section_get_started',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'header_title',
|
||||
'value' => 'Simple <span style="color: #41B883">&</span> Powerful Personal Cloud Storage',
|
||||
],
|
||||
[
|
||||
'name' => 'header_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'features_title',
|
||||
'value' => 'The Fastest Growing <span style="color: #41B883">File Manager</span> on the CodeCanyon Market',
|
||||
],
|
||||
[
|
||||
'name' => 'features_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_1',
|
||||
'value' => 'Truly Freedom',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_1',
|
||||
'value' => 'You have full control over VueFileManager, no third authorities will control your service or usage, only you.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_2',
|
||||
'value' => 'The Sky is the Limit',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_2',
|
||||
'value' => 'VueFileManager is cloud storage software. You have to install and running application on your own server hosting.',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_title_3',
|
||||
'value' => 'No Monthly Fees',
|
||||
],
|
||||
[
|
||||
'name' => 'feature_description_3',
|
||||
'value' => 'When you running VueFileManager on your own server hosting, anybody can\'t control your content or resell your user data. Your data is safe.',
|
||||
],
|
||||
[
|
||||
'name' => 'pricing_title',
|
||||
'value' => 'Pick the <span style="color: #41B883;">Best Plan</span> For Your Needs',
|
||||
],
|
||||
[
|
||||
'name' => 'pricing_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'get_started_title',
|
||||
'value' => 'Ready to Get <span style="color: #41B883">Started</span><br> With Us?',
|
||||
],
|
||||
[
|
||||
'name' => 'get_started_description',
|
||||
'value' => 'Your private cloud storage software build on Laravel & Vue.js. No limits & no monthly fees. Truly freedom.',
|
||||
],
|
||||
[
|
||||
'name' => 'footer_content',
|
||||
'value' => '© 2021 Simple & Powerful Personal Cloud Storage. Developed by <a href="https://hi5ve.digital" target="_blank">Hi5Ve.Digital</a>',
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
@@ -14,7 +14,7 @@ class CreateSettingsTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->string('name')->unique();
|
||||
$table->string('name')->unique()->primary();
|
||||
$table->longText('value')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class AdminTest extends TestCase
|
||||
->count(2)
|
||||
->create(['filesize' => 1000000]);
|
||||
|
||||
Setting::create([
|
||||
Setting::forceCreate([
|
||||
'name' => 'license',
|
||||
'value' => 'Regular'
|
||||
]);
|
||||
@@ -442,7 +442,7 @@ class AdminTest extends TestCase
|
||||
*/
|
||||
public function it_get_all_pages()
|
||||
{
|
||||
$this->setup->seed_pages();
|
||||
$this->setup->seed_default_pages();
|
||||
|
||||
collect(['terms-of-service', 'privacy-policy', 'cookie-policy'])
|
||||
->each(function ($slug) {
|
||||
@@ -459,7 +459,7 @@ class AdminTest extends TestCase
|
||||
*/
|
||||
public function it_get_page()
|
||||
{
|
||||
$this->setup->seed_pages();
|
||||
$this->setup->seed_default_pages();
|
||||
|
||||
$this->getJson('/api/admin/pages/terms-of-service')
|
||||
->assertStatus(200)
|
||||
@@ -473,7 +473,7 @@ class AdminTest extends TestCase
|
||||
*/
|
||||
public function it_update_page()
|
||||
{
|
||||
$this->setup->seed_pages();
|
||||
$this->setup->seed_default_pages();
|
||||
|
||||
$this->patchJson('/api/admin/pages/terms-of-service', [
|
||||
'name' => 'title',
|
||||
@@ -484,4 +484,52 @@ class AdminTest extends TestCase
|
||||
'title' => 'New Title'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_update_settings()
|
||||
{
|
||||
$this->setup->seed_default_settings('Extended');
|
||||
|
||||
$this->patchJson('/api/admin/settings', [
|
||||
'name' => 'header_title',
|
||||
'value' => 'New Header Title'
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'value' => 'New Header Title'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_update_settings_image()
|
||||
{
|
||||
Storage::fake('local');
|
||||
|
||||
$this->setup->create_directories();
|
||||
|
||||
Setting::forceCreate([
|
||||
'name' => 'app_logo',
|
||||
'value' => null,
|
||||
]);
|
||||
|
||||
$logo = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$this->patchJson('/api/admin/settings', [
|
||||
'name' => 'app_logo',
|
||||
'app_logo' => $logo
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('settings', [
|
||||
'app_logo' => null
|
||||
]);
|
||||
|
||||
Storage::assertExists(
|
||||
get_setting('app_logo')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user