UPDATE: Logo y versión (#2)
This commit is contained in:
parent
517628b92d
commit
185f930f22
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,6 +2,8 @@
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/images
|
||||
/public/profile
|
||||
/public/storage
|
||||
/public/vendor
|
||||
/storage/*.key
|
||||
|
||||
39
app/Enums/SettingTypeEk.php
Normal file
39
app/Enums/SettingTypeEk.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php namespace App\Enums;
|
||||
|
||||
use Notsoweb\LaravelCore\Traits\Enums\Extended;
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2001-2023 Golsystems (https://www.golsystems.mx) - All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tipos de configuración
|
||||
*
|
||||
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
enum SettingTypeEk : string
|
||||
{
|
||||
use Extended;
|
||||
|
||||
/**
|
||||
* Texto
|
||||
*/
|
||||
case STRING = 'S';
|
||||
|
||||
/**
|
||||
* JSON
|
||||
*/
|
||||
case JSON = 'J';
|
||||
|
||||
/**
|
||||
* Booleano
|
||||
*/
|
||||
case BOOL = 'B';
|
||||
|
||||
/**
|
||||
* Entero
|
||||
*/
|
||||
case INT = 'I';
|
||||
}
|
||||
38
app/Http/Controllers/ResourceController.php
Normal file
38
app/Http/Controllers/ResourceController.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* @copyright (c) 2024 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||
*/
|
||||
|
||||
use App\Models\Setting;
|
||||
use Notsoweb\ApiResponse\Enums\ApiResponse;
|
||||
use Tighten\Ziggy\Ziggy;
|
||||
|
||||
/**
|
||||
* Recursos de la aplicación
|
||||
*
|
||||
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class ResourceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Información de la aplicación
|
||||
*/
|
||||
public function app()
|
||||
{
|
||||
return ApiResponse::OK->axios([
|
||||
'logo' => Setting::value('app.logo'),
|
||||
'favicon' => Setting::value('app.favicon'),
|
||||
'version' => config('app.version'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rutas de la aplicación
|
||||
*/
|
||||
public function routes()
|
||||
{
|
||||
return ApiResponse::OK->axios((new Ziggy('api'))->toArray());
|
||||
}
|
||||
}
|
||||
65
app/Models/Setting.php
Normal file
65
app/Models/Setting.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php namespace App\Models;
|
||||
/**
|
||||
* @copyright (c) 2024 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||
*/
|
||||
|
||||
use App\Enums\SettingTypeEk;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Configuraciones del sistema
|
||||
*
|
||||
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class Setting extends Model
|
||||
{
|
||||
/**
|
||||
* Atributos permitidos
|
||||
*/
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'description',
|
||||
'value',
|
||||
'type_ek'
|
||||
];
|
||||
|
||||
/**
|
||||
* Transformación de los datos
|
||||
*/
|
||||
protected $casts = [
|
||||
'value' => 'json'
|
||||
];
|
||||
|
||||
/**
|
||||
* Solicita o registra una configuración
|
||||
*/
|
||||
public static function value(string $key, mixed $value = null, string $description = null, SettingTypeEk $type_ek = SettingTypeEk::STRING): mixed
|
||||
{
|
||||
$setting = self::where('key', $key)->first();
|
||||
|
||||
if ($value !== null || $description !== null) {
|
||||
$toSave = [];
|
||||
|
||||
if ($value !== null) {
|
||||
$toSave['value'] = $value;
|
||||
}
|
||||
|
||||
if ($description !== null) {
|
||||
$toSave['description'] = $description;
|
||||
}
|
||||
|
||||
if ($setting) {
|
||||
return $setting->update($toSave);
|
||||
} else {
|
||||
$toSave['key'] = $key;
|
||||
$toSave['type_ek'] = $type_ek;
|
||||
|
||||
return self::create($toSave);
|
||||
}
|
||||
}
|
||||
|
||||
return $setting?->value;
|
||||
}
|
||||
}
|
||||
8
composer.lock
generated
8
composer.lock
generated
@ -3430,12 +3430,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/notsoweb/laravel-core.git",
|
||||
"reference": "6c3c2841dcd9358f423005c8fe411ab5f9157f94"
|
||||
"reference": "c2c9413dd2be426fef44e38d1fef7d7386c18831"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/notsoweb/laravel-core/zipball/6c3c2841dcd9358f423005c8fe411ab5f9157f94",
|
||||
"reference": "6c3c2841dcd9358f423005c8fe411ab5f9157f94",
|
||||
"url": "https://api.github.com/repos/notsoweb/laravel-core/zipball/c2c9413dd2be426fef44e38d1fef7d7386c18831",
|
||||
"reference": "c2c9413dd2be426fef44e38d1fef7d7386c18831",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -3467,7 +3467,7 @@
|
||||
"issues": "https://github.com/notsoweb/laravel-core/issues",
|
||||
"source": "https://github.com/notsoweb/laravel-core/tree/main"
|
||||
},
|
||||
"time": "2024-10-24T23:54:14+00:00"
|
||||
"time": "2024-12-14T16:38:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nunomaduro/termwind",
|
||||
|
||||
@ -53,6 +53,14 @@
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'images' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/images'),
|
||||
'url' => env('APP_URL').'/images',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
@ -80,5 +88,6 @@
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
public_path('profile') => storage_path('app/profile'),
|
||||
public_path('images') => storage_path('app/images'),
|
||||
],
|
||||
];
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\SettingTypeEk;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key');
|
||||
$table->string('description');
|
||||
$table->json('value');
|
||||
$table->enum('type_ek', SettingTypeEk::values());
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
};
|
||||
@ -13,11 +13,8 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
$this->call(RoleSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(SettingSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,5 +11,6 @@ public function run(): void
|
||||
{
|
||||
$this->call(RoleSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(SettingSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
27
database/seeders/SettingSeeder.php
Normal file
27
database/seeders/SettingSeeder.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php namespace Database\Seeders;
|
||||
/**
|
||||
* @copyright (c) 2024 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||
*/
|
||||
|
||||
use App\Enums\SettingTypeEk;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* Descripción
|
||||
*
|
||||
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class SettingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Ejecutar sembrado de base de datos
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Setting::value('app.logo', url("images/logo.png"), 'Logo de la aplicación', SettingTypeEk::STRING);
|
||||
Setting::value('app.favicon', url("images/favicon.ico"), 'Favicon de la aplicación', SettingTypeEk::STRING);
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
/var/www/notsoweb/holos.backend/storage/app/profile
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\MyUserController;
|
||||
use App\Http\Controllers\ResourceController;
|
||||
use App\Http\Controllers\System\LoginController;
|
||||
use App\Http\Controllers\System\NotificationController;
|
||||
use App\Http\Controllers\System\SystemController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Notsoweb\ApiResponse\Enums\ApiResponse;
|
||||
use Tighten\Ziggy\Ziggy;
|
||||
|
||||
Route::get('/', function () {
|
||||
return ApiResponse::OK->response([
|
||||
@ -15,12 +15,6 @@
|
||||
]);
|
||||
});
|
||||
|
||||
Route::name('api.')->group(function () {
|
||||
Route::get('/routes', function () {
|
||||
return (new Ziggy('api'))->toArray();
|
||||
})->name('routes');
|
||||
});
|
||||
|
||||
Route::middleware('auth:api')->group(function () {
|
||||
// Aplicación
|
||||
Route::prefix('user')->name('user.')->group(function() {
|
||||
@ -57,6 +51,11 @@
|
||||
Route::post('auth/logout', [LoginController::class, 'logout'])->name('auth.logout');
|
||||
});
|
||||
|
||||
Route::prefix('resources')->name('resources.')->group(function() {
|
||||
Route::get('app', [ResourceController::class, 'app'])->name('app');
|
||||
Route::get('routes', [ResourceController::class, 'routes'])->name('routes');
|
||||
});
|
||||
|
||||
Route::prefix('auth')->name('auth.')->group(function () {
|
||||
Route::post('login', [LoginController::class, 'login'])->name('login');
|
||||
Route::post('forgot-password', [LoginController::class, 'forgotPassword'])->name('forgot-password');
|
||||
|
||||
1
storage/app/.gitignore
vendored
1
storage/app/.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
*
|
||||
!images/
|
||||
!keys/
|
||||
!private/
|
||||
!profile/
|
||||
|
||||
2
storage/app/images/.gitignore
vendored
Executable file
2
storage/app/images/.gitignore
vendored
Executable file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Loading…
x
Reference in New Issue
Block a user