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();
}
}