Skip to content

Commit

Permalink
Merge pull request #14 from lapig-ufg/develop
Browse files Browse the repository at this point in the history
Pop-ups
  • Loading branch information
James-jamames authored Feb 2, 2024
2 parents cf7a896 + 8f898ac commit 9970228
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
38 changes: 38 additions & 0 deletions server/app/Models/PopUp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Traits\Translatable;

class PopUp extends Model
{
use HasFactory, Translatable;

protected $translatable = ['title', 'message'];
protected $table = "popups";

protected $fillable = [
'title',
'message',
'expiration'
];

public static function getTranslate(string $lang)
{
$popups = News::withTranslation($lang)->get();

foreach($popups as $popup)
{
foreach($popup->translations as $translation)
{
$popup[$translation->column_name] = $translation->value;
}

unset($popup->translations);
}

return $popups;
}
}
6 changes: 5 additions & 1 deletion server/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
return Methodology::getTranslate($lang);
});

Route::get('/api/FAQ/{lang}', function (string $lang) {
Route::get('/api/popup/{lang}', function (string $lang) {
return FAQ::getTranslate($lang);
});

Route::get('/api/faq/{lang}', function (string $lang) {
return FAQ::getTranslate($lang);
});

Expand Down

0 comments on commit 9970228

Please sign in to comment.