Version model

This commit is contained in:
Anna-Sara Sélea 2025-11-15 17:09:14 +01:00
parent 91e9f49d85
commit 0d5601505b
4 changed files with 191 additions and 0 deletions

View file

@ -0,0 +1,114 @@
<?php
namespace App\Http\Controllers;
use App\Models\Version;
use Illuminate\Http\Request;
class VersionController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$ability = $request->ability;
if ($ability === "key_1") {
$latest_version_participants = Version::where('table', 'participants')->latest()->first();
$latest_version_volunteers = Version::where('table', 'volunteers')->latest()->first();
return response()->json([
'success' => true, 'participants' => $latest_version_participants ? $latest_version_participants->version : null , 'volunteers' => $latest_version_volunteers ? $latest_version_volunteers->version : null
]);
}
if ($ability === "key_2") {
$latest_version_participants = Version::where('table', 'participants')->latest()->first();
$latest_version_volunteers = Version::where('table', 'volunteers')->latest()->first();
return response()->json([
'success' => true, 'participants' => $latest_version_participants ? $latest_version_participants->version : null , 'volunteers' => $latest_version_volunteers ? $latest_version_volunteers->version : null
]);
}
if ($ability === "key_3") {
$latest_version_participants = Version::where('table', 'participants')->latest()->first();
return response()->json([
'success' => true, 'participants' => $latest_version_participants ? $latest_version_participants->version : null
]);
}
if ($ability === "key_4") {
$latest_version_participants = Version::where('table', 'participants')->latest()->first();
return response()->json([
'success' => true, 'participants' => $latest_version_participants ? $latest_version_participants->version : null
]);
}
return response()->json([
'success' => false, 'message' => 'Unauthorized'
]);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(Version $version)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Version $version)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Version $version)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Version $version)
{
//
}
}

13
app/Models/Version.php Normal file
View file

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Version extends Model
{
protected $fillable = [
'table',
'version'
];
}

View file

@ -0,0 +1,29 @@
<?php
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('versions', function (Blueprint $table) {
$table->id();
$table->string('table')->nullable();
$table->integer('version')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('versions');
}
};

View file

@ -0,0 +1,35 @@
/* We use this to prevent the gap/space creating ghost elements */
div:has(> .gaze-banner:not(.gaze-banner--has-content)) {
display: none;
}
.fi-gaze-banner {
display: flex;
flex-direction: row;
align-items: center;
gap: 1rem;
border-radius: 0.75rem;
padding: 1.5rem;
border: 1px solid var(--primary-500);
color: var(--primary-500);
background-color: var(--gray-100);
}
.fi.dark .fi-gaze-banner {
background-color: var(--color-gray-900);
}
.fi-gaze-banner .icon-container {
flex-shrink: 0;
}
.fi-gaze-banner .text-container {
display: flex;
flex-direction: column;
flex: 1;
}
.fi-gaze-banner .button-container {
flex-shrink: 0;
}