⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
work
/
modules
/
News
/
Models
/
View File Name :
NewsTag.php
<?php namespace Modules\News\Models; use App\BaseModel; use Illuminate\Database\Eloquent\SoftDeletes; class NewsTag extends BaseModel { use SoftDeletes; protected $table = 'core_news_tag'; protected $fillable = [ 'news_id', 'tag_id' ]; public static function getModelName() { return __("News Tag"); } public static function searchForMenu($q = false) { } public function tag() { return $this->belongsTo('Modules\News\Models\NewsTag'); } public static function getAll() { return self::with('tag')->get(); } public static function addTag($tags_ids, $news_id) { if (!empty($tags_ids)) { foreach ($tags_ids as $tag_id) { $find = parent::where('news_id', $news_id)->where('tag_id', $tag_id)->first(); if (empty($find)) { $a = new self(); $a->news_id = $news_id; $a->tag_id = $tag_id; $a->save(); } } } } public static function getTags(){ $query = Tag::query()->with('translation'); $query->select(['core_tags.*']); return $query ->join('core_news_tag as nt','nt.tag_id','=','core_tags.id')->orderByRaw('RAND()') ->groupBy('core_tags.id') ->get(10); } }