Settings basics

This commit is contained in:
2024-01-26 21:19:49 +01:00
parent 5c6f2dd117
commit 17432fd705
4 changed files with 70 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Controllers;
use App\Models\Settings;
use Illuminate\Http\Request;
class SettingsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return Settings::all();
}
public function get($setting)
{
return Settings::get($setting);
}
}

40
app/Models/Settings.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Settings extends Model
{
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'c_settings';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'name';
/**
* Indicates if the model's ID is auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
use HasFactory;
protected function get($name = null)
{
return $this->where('name',$name)->get();
}
}

View File

@@ -30,6 +30,7 @@ const sdropdown = ref([
const products = ref([]);
const searchField = ref('descLong');
const searchValue = ref('');
const settings = ref({});
const countryHash = ref([]);
const countryCurrency = ref({});
@@ -222,6 +223,9 @@ const fetch = async () => {
};
});
console.log("TEST=", ccountry_filter.value, ccountry_list.value);
const response2 = await axios.get(route("settings"));
settings.value = response2.data;
} catch (e) {
const response = await Swal.fire({
title: __("are you want to try again") + "?",

View File

@@ -9,7 +9,7 @@ use App\Http\Controllers\GeoIPController;
use App\Http\Controllers\IkeaProductsController;
use App\Http\Controllers\ProductsCompareController;
use App\Http\Controllers\FeedbackController;
use App\Http\Controllers\SettingsController;
/*
|--------------------------------------------------------------------------
| Web Routes
@@ -35,6 +35,7 @@ Route::post('users-send-email', [FeedbackController::class, 'sendEmail'])->name(
Route::get('/menu/get', [App\Http\Controllers\Superuser\UserMenuController::class, 'get'])->name('menu.user');
Route::get('/ip/get/{ip?}', [GeoIPController::class, 'index'])->name('geo.ip.get');
Route::get('/ccountry/', [CountryCodeController::class, 'index'])->name('ccountry.index');
Route::get('/settings/', [SettingsController::class, 'index'])->name('ccountry.index');
Route::get('/ccountry/codes/', [CountryCodeController::class, 'codes'])->name('ccountry.codes');
Route::get('/ccountry/active/', [CountryCodeController::class, 'active'])->name('ccountry.active');
Route::get('/search/{id}',[CountryCompareController::class,'search'])->name('ccompare.search');