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
Reference.php
51 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kirki\App\Models; |
| 4 | |
| 5 | use Kirki\Framework\Database\Query\Model; |
| 6 | |
| 7 | /** |
| 8 | * Reference model for the `kirki_cm_reference` table. |
| 9 | * |
| 10 | * Stores the relationship between a content manager item (`post_id`), |
| 11 | * the field it belongs to (`field_meta_key`) and the referenced post |
| 12 | * (`ref_post_id`). Replaces the raw `$wpdb` access used by the legacy |
| 13 | * ContentManagerHelper. |
| 14 | * |
| 15 | * @see database/migrations/CreateCmReferenceTable.php |
| 16 | */ |
| 17 | class Reference extends Model |
| 18 | { |
| 19 | protected $table = 'kirki_cm_reference'; |
| 20 | protected $primary_key = 'id'; |
| 21 | public $timestamps = false; |
| 22 | |
| 23 | protected $fillable = [ |
| 24 | 'post_id', |
| 25 | 'field_meta_key', |
| 26 | 'ref_post_id', |
| 27 | ]; |
| 28 | |
| 29 | protected $casts = [ |
| 30 | 'id' => 'integer', |
| 31 | 'post_id' => 'integer', |
| 32 | 'ref_post_id' => 'integer', |
| 33 | ]; |
| 34 | |
| 35 | /** |
| 36 | * The post that owns the reference row. |
| 37 | */ |
| 38 | public function post() |
| 39 | { |
| 40 | return $this->belongs_to(Post::class, 'post_id', 'ID'); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * The referenced post. |
| 45 | */ |
| 46 | public function ref_post() |
| 47 | { |
| 48 | return $this->belongs_to(Post::class, 'ref_post_id', 'ID'); |
| 49 | } |
| 50 | } |
| 51 |