Collaboration.php
3 weeks ago
CollaborationComment.php
3 weeks ago
CollaborationCommentSeen.php
3 weeks ago
CollaborationConnected.php
3 weeks ago
CollaborationSent.php
3 weeks ago
Collection.php
3 weeks ago
CollectionItem.php
3 weeks ago
Media.php
3 weeks ago
Page.php
3 weeks ago
Post.php
3 weeks ago
PostMeta.php
3 days ago
Reference.php
3 weeks ago
Term.php
3 weeks ago
TermMeta.php
3 weeks ago
TermTaxonomy.php
3 weeks ago
User.php
3 weeks ago
UserMeta.php
3 weeks ago
Media.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kirki\App\Models; |
| 4 | |
| 5 | use Kirki\App\Constants\PostStatus; |
| 6 | use Kirki\App\Constants\PostTypes; |
| 7 | |
| 8 | defined('ABSPATH') || exit; |
| 9 | |
| 10 | use Kirki\App\Traits\SearchablePost; |
| 11 | use Kirki\Framework\Database\Query\Model; |
| 12 | class Media extends Model |
| 13 | { |
| 14 | use SearchablePost; |
| 15 | |
| 16 | protected $table = 'posts'; |
| 17 | |
| 18 | protected $primary_key = 'ID'; |
| 19 | |
| 20 | protected $timestamps = false; |
| 21 | |
| 22 | public static function query() |
| 23 | { |
| 24 | return parent::query() |
| 25 | ->where('post_type', PostTypes::WP_ATTACHMENT) |
| 26 | ->where_not('post_status', PostStatus::TRASH); |
| 27 | } |
| 28 | |
| 29 | public function meta() |
| 30 | { |
| 31 | return $this->has_many(PostMeta::class, 'post_id', 'ID'); |
| 32 | } |
| 33 | } |
| 34 |