Skip to content

Commit bd68d84

Browse files
committed
Expiry w-i-p
1 parent bd6f2e9 commit bd68d84

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/Models/WpPost.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public function __construct(array $attributes = [])
6969
$this->metatable = $this->wpPrefix.'postmeta';
7070

7171
$this->appends = [
72-
'wichtig',
7372
'verantwortlicher',
7473
'gultig_bis',
7574
'turnus',
@@ -82,16 +81,8 @@ public function __construct(array $attributes = [])
8281
'post_date_gmt' => 'datetime',
8382
'post_modified' => 'datetime',
8483
'post_modified_gmt' => 'datetime',
85-
'wichtig' => 'boolean',
8684
];
8785

88-
public function scopeWichtig($query)
89-
{
90-
return $query->whereHas('meta', function ($query) {
91-
$query->where('meta_key', 'wichtig');
92-
});
93-
}
94-
9586
public function getVerantwortlicherAttribute()
9687
{
9788
return $this->getMeta('verantwortlicher') ?? null;
@@ -177,4 +168,19 @@ public function author()
177168
{
178169
return $this->belongsTo(WpUser::class, 'post_author', 'ID');
179170
}
171+
172+
public function taxonomies()
173+
{
174+
return $this->belongsToMany(WpTermTaxonomy::class, config('press.wordpress_prefix').'term_relationships', 'object_id', 'term_taxonomy_id');
175+
}
176+
177+
public function categories()
178+
{
179+
return $this->taxonomies()->where('taxonomy', 'category');
180+
}
181+
182+
public function tags()
183+
{
184+
return $this->taxonomies()->where('taxonomy', 'post_tag');
185+
}
180186
}

src/Models/WpTermTaxonomy.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
use Illuminate\Database\Eloquent\Factories\HasFactory;
66
use Illuminate\Database\Eloquent\Model;
77

8+
/**
9+
* @property int $term_taxonomy_id
10+
* @property int $term_id
11+
* @property string $taxonomy
12+
* @property string $description
13+
* @property int $parent
14+
* @property int $count
15+
* @property \Moox\Press\Models\WpTerm $term
16+
*/
817
class WpTermTaxonomy extends Model
918
{
1019
use HasFactory;
@@ -33,4 +42,9 @@ public function __construct(array $attributes = [])
3342
$this->wpPrefix = config('press.wordpress_prefix');
3443
$this->table = $this->wpPrefix.'term_taxonomy';
3544
}
45+
46+
public function term()
47+
{
48+
return $this->belongsTo(WpTerm::class, 'term_id', 'term_id');
49+
}
3650
}

0 commit comments

Comments
 (0)