403Webshell
Server IP : 157.230.181.24  /  Your IP : 216.73.217.11
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/vhosts/conductive-digital.bak/app/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/conductive-digital.bak/app/models/Term.php
<?php

	namespace Theme\Models;

	use Illuminate\Database\Eloquent\Model;

	class Term extends Model {

		/** @var string The table */
		protected $table = 'terms';

		/** @var string Primary key for the table */
		protected $primaryKey = 'term_id';

		/** @var null|string Automatically target a taxonomy (category, bus-category, etc) */
		protected $taxonomy = 'category';

		/** @var array Its own term meta array (basically a local cache) */
		protected $termMeta = [];

		/**
		 * Allow __gets on ACF fields
		 *
		 * @param string $name
		 * @return bool|mixed|null
		 */
		public function __get($name) {
			$value = parent::__get($name);

			if($value !== 'category') {
				return get_field($name, $this->taxonomy . '_' . $this->getAttribute('term_id'), TRUE);
			}

			return $value;
		}

		/**
		 * Get terms
		 *
		 * @param $postID
		 * @return array|\WP_Error
		 */
		public static function get($postID = NULL) {
			$class = get_called_class();
			$self  = new $class();
			$terms = wp_get_post_terms($postID, $self->taxonomy);
			$terms = $class::hydrate($terms);

			return $terms;
		}

		/**
		 * Get the permalink to the category
		 *
		 * @return string|\WP_Error
		 */
		public function getPermalinkAttribute() {
			return get_term_link($this->getAttribute('term_id'), $this->taxonomy);
		}

		/**
		 * Automatically filter to specific taxonomy (set to NULL to match any)
		 *
		 * @return \Illuminate\Database\Eloquent\Builder
		 */
		public function newQuery() {
			$query = parent::newQuery();

			if($this->taxonomy) {
				$query->leftJoin('term_taxonomy', 'term_taxonomy.term_id', '=', 'terms.term_id')
				      ->where('taxonomy', $this->taxonomy);
			}

			// Get term meta specified in $this->termMeta
			if(!empty($this->termMeta)) {
				// Setup selects
				$selects = ['terms.*'];

				foreach($this->termMeta as $meta) {
					array_push($selects, "termmeta_$meta.meta_value as $meta");
				}

				$query->select($selects);

				// Join terms in
				foreach($this->termMeta as $meta) {
					$query->rightJoin("termmeta as termmeta_$meta", "termmeta_$meta.term_id", '=', 'terms.term_id')
					      ->where("termmeta_$meta.meta_key", $meta);
				}
			}

			return $query;
		}

		/**
		 * Filter by a taxonomy
		 *
		 * @param string $taxonomy
		 * @return mixed
		 */
		public static function filterByTaxonomy($taxonomy) {
			return self::leftJoin('term_taxonomy', 'term_taxonomy.term_id', '=', 'terms.term_id')
			           ->where('term_taxonomy.taxonomy', $taxonomy);
		}

		/**
		 * Relationship to posts
		 *
		 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
		 */
		public function posts() {
			return $this->belongsToMany(Post::class, 'term_relationships', 'term_taxonomy_id', 'object_id');
		}

	}

Youez - 2016 - github.com/yon3zu
LinuXploit