-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from lapig-ufg/develop
Pop-ups
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters