+
', '' );
@@ -20,10 +20,16 @@
}
?>
+
+
+>
+
>
>
\ No newline at end of file
diff --git a/theme/vendor/composer/autoload_psr4.php b/theme/vendor/composer/autoload_psr4.php
index 9065086..bd09f70 100644
--- a/theme/vendor/composer/autoload_psr4.php
+++ b/theme/vendor/composer/autoload_psr4.php
@@ -8,6 +8,7 @@ $baseDir = dirname($vendorDir);
return array(
'voku\\' => array($vendorDir . '/voku/portable-ascii/src/voku'),
'WoWPress\\' => array($baseDir . '/wowpress'),
+ 'Wenprise\\ORM\\' => array($vendorDir . '/wenprise/wp-orm/src'),
'Wenprise\\' => array($vendorDir . '/wenprise/eloquent/src'),
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
diff --git a/theme/vendor/composer/autoload_static.php b/theme/vendor/composer/autoload_static.php
index b5fc073..594603e 100644
--- a/theme/vendor/composer/autoload_static.php
+++ b/theme/vendor/composer/autoload_static.php
@@ -29,6 +29,7 @@ class ComposerStaticInit13829b6fd5f7bfdfd80b0a9c5c2c90b4
'W' =>
array (
'WoWPress\\' => 9,
+ 'Wenprise\\ORM\\' => 13,
'Wenprise\\' => 9,
),
'S' =>
@@ -90,6 +91,10 @@ class ComposerStaticInit13829b6fd5f7bfdfd80b0a9c5c2c90b4
array (
0 => __DIR__ . '/../..' . '/wowpress',
),
+ 'Wenprise\\ORM\\' =>
+ array (
+ 0 => __DIR__ . '/..' . '/wenprise/wp-orm/src',
+ ),
'Wenprise\\' =>
array (
0 => __DIR__ . '/..' . '/wenprise/eloquent/src',
diff --git a/theme/vendor/composer/installed.json b/theme/vendor/composer/installed.json
index 3c9f41e..dcdca06 100644
--- a/theme/vendor/composer/installed.json
+++ b/theme/vendor/composer/installed.json
@@ -2529,6 +2529,58 @@
"source": "https://github.com/iwillhappy1314/wenprise-eloquent/tree/9.0.1"
},
"install-path": "../wenprise/eloquent"
+ },
+ {
+ "name": "wenprise/wp-orm",
+ "version": "dev-main",
+ "version_normalized": "dev-main",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/iwillhappy1314/wenprise-wp-orm.git",
+ "reference": "6171efa42a6d5b07c13867acd4cd0ff4616fde1b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/iwillhappy1314/wenprise-wp-orm/zipball/6171efa42a6d5b07c13867acd4cd0ff4616fde1b",
+ "reference": "6171efa42a6d5b07c13867acd4cd0ff4616fde1b",
+ "shasum": ""
+ },
+ "require": {
+ "wenprise/eloquent": "^9.0"
+ },
+ "time": "2023-11-16T16:46:17+00:00",
+ "default-branch": true,
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Wenprise\\ORM\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Amos Lee",
+ "email": "iwillhappy1314@gmail.com"
+ }
+ ],
+ "description": "Eloquent ORM for WordPress",
+ "homepage": "https://github.com/iwillhappy1314/wenprise-wp-orm",
+ "keywords": [
+ "eloquent",
+ "orm",
+ "plugin",
+ "sql",
+ "wordpress"
+ ],
+ "support": {
+ "issues": "https://github.com/iwillhappy1314/wenprise-wp-orm/issues",
+ "source": "https://github.com/iwillhappy1314/wenprise-wp-orm/tree/main"
+ },
+ "install-path": "../wenprise/wp-orm"
}
],
"dev": true,
diff --git a/theme/vendor/composer/installed.php b/theme/vendor/composer/installed.php
index c3d7629..b7f6594 100644
--- a/theme/vendor/composer/installed.php
+++ b/theme/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '45e66ab3a0edfe4d53254637a653545e1b3d40bf',
+ 'reference' => 'd7328bb0873bd5ff981d843717b3e140b56b049b',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '45e66ab3a0edfe4d53254637a653545e1b3d40bf',
+ 'reference' => 'd7328bb0873bd5ff981d843717b3e140b56b049b',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -367,5 +367,16 @@
'aliases' => array(),
'dev_requirement' => false,
),
+ 'wenprise/wp-orm' => array(
+ 'pretty_version' => 'dev-main',
+ 'version' => 'dev-main',
+ 'reference' => '6171efa42a6d5b07c13867acd4cd0ff4616fde1b',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../wenprise/wp-orm',
+ 'aliases' => array(
+ 0 => '9999999-dev',
+ ),
+ 'dev_requirement' => false,
+ ),
),
);
diff --git a/theme/vendor/wenprise/wp-orm/.gitignore b/theme/vendor/wenprise/wp-orm/.gitignore
new file mode 100644
index 0000000..757fee3
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/.gitignore
@@ -0,0 +1 @@
+/.idea
\ No newline at end of file
diff --git a/theme/vendor/wenprise/wp-orm/composer.json b/theme/vendor/wenprise/wp-orm/composer.json
new file mode 100755
index 0000000..677fe6d
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/composer.json
@@ -0,0 +1,27 @@
+{
+ "name": "wenprise/wp-orm",
+ "description": "Eloquent ORM for WordPress",
+ "keywords": [
+ "wordpress",
+ "plugin",
+ "orm",
+ "eloquent",
+ "sql"
+ ],
+ "homepage": "https://github.com/iwillhappy1314/wenprise-wp-orm",
+ "require": {
+ "wenprise/eloquent": "^9.0"
+ },
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Amos Lee",
+ "email": "iwillhappy1314@gmail.com"
+ }
+ ],
+ "autoload": {
+ "psr-4": {
+ "Wenprise\\ORM\\": "src/"
+ }
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Builder/CommentBuilder.php b/theme/vendor/wenprise/wp-orm/src/Builder/CommentBuilder.php
new file mode 100755
index 0000000..f66dd57
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Builder/CommentBuilder.php
@@ -0,0 +1,22 @@
+
+ */
+class CommentBuilder extends Builder
+{
+ /**
+ * @return CommentBuilder
+ */
+ public function approved()
+ {
+ return $this->where('comment_approved', 1);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Builder/PostBuilder.php b/theme/vendor/wenprise/wp-orm/src/Builder/PostBuilder.php
new file mode 100755
index 0000000..9103a6f
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Builder/PostBuilder.php
@@ -0,0 +1,113 @@
+
+ */
+class PostBuilder extends Builder
+{
+ /**
+ * @param string $status
+ * @return PostBuilder
+ */
+ public function status($status)
+ {
+ return $this->where('post_status', $status);
+ }
+
+ /**
+ * @return PostBuilder
+ */
+ public function published()
+ {
+ return $this->status('publish');
+ }
+
+ /**
+ * @param string $type
+ * @return PostBuilder
+ */
+ public function type($type)
+ {
+ return $this->where('post_type', $type);
+ }
+
+ /**
+ * @param array $types
+ * @return PostBuilder
+ */
+ public function typeIn(array $types)
+ {
+ return $this->whereIn('post_type', $types);
+ }
+
+ /**
+ * @param string $slug
+ * @return PostBuilder
+ */
+ public function slug($slug)
+ {
+ return $this->where('post_name', $slug);
+ }
+
+ /**
+ * @param string $postParentId
+ * @return PostBuilder
+ */
+ public function parent($postParentId)
+ {
+ return $this->where('post_parent', $postParentId);
+ }
+
+ /**
+ * @param string $taxonomy
+ * @param mixed $terms
+ * @return PostBuilder
+ */
+ public function taxonomy($taxonomy, $terms)
+ {
+ return $this->whereHas('taxonomies', function ($query) use ($taxonomy, $terms) {
+ $query->where('taxonomy', $taxonomy)
+ ->whereHas('term', function ($query) use ($terms) {
+ $query->whereIn('slug', is_array($terms) ? $terms : [$terms]);
+ });
+ });
+ }
+
+ /**
+ * @param mixed $term
+ * @return PostBuilder
+ */
+ public function search($term = false)
+ {
+ if (empty($term)) {
+ return $this;
+ }
+
+ $terms = is_string($term) ? explode(' ', $term) : $term;
+
+ $terms = collect($terms)->map(function ($term) {
+ return trim(str_replace('%', '', $term));
+ })->filter()->map(function ($term) {
+ return '%' . $term . '%';
+ });
+
+ if ($terms->isEmpty()) {
+ return $this;
+ }
+
+ return $this->where(function ($query) use ($terms) {
+ $terms->each(function ($term) use ($query) {
+ $query->orWhere('post_title', 'like', $term)
+ ->orWhere('post_excerpt', 'like', $term)
+ ->orWhere('post_content', 'like', $term);
+ });
+ });
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Builder/TaxonomyBuilder.php b/theme/vendor/wenprise/wp-orm/src/Builder/TaxonomyBuilder.php
new file mode 100755
index 0000000..a7a8dce
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Builder/TaxonomyBuilder.php
@@ -0,0 +1,64 @@
+
+ * @author Yoram de Langen
+ */
+class TaxonomyBuilder extends Builder
+{
+ /**
+ * @return TaxonomyBuilder
+ */
+ public function category()
+ {
+ return $this->where('taxonomy', 'category');
+ }
+
+ /**
+ * @return TaxonomyBuilder
+ */
+ public function menu()
+ {
+ return $this->where('taxonomy', 'nav_menu');
+ }
+
+ /**
+ * @param string $name
+ * @return TaxonomyBuilder
+ */
+ public function name($name)
+ {
+ return $this->where('taxonomy', $name);
+ }
+
+ /**
+ * @param string $slug
+ * @return TaxonomyBuilder
+ */
+ public function slug($slug = null)
+ {
+ if (! is_null($slug) && ! empty($slug)) {
+ return $this->whereHas('term', function ($query) use ($slug) {
+ $query->where('slug', $slug);
+ });
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param null $slug
+ * @return TaxonomyBuilder
+ */
+ public function term($slug = null)
+ {
+ return $this->slug($slug);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Collection/MetaCollection.php b/theme/vendor/wenprise/wp-orm/src/Collection/MetaCollection.php
new file mode 100755
index 0000000..464dc35
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Collection/MetaCollection.php
@@ -0,0 +1,40 @@
+
+ */
+class MetaCollection extends Collection
+{
+ /**
+ * @param string $key
+ * @return mixed
+ */
+ public function __get($key)
+ {
+ if (isset($this->items) && count($this->items)) {
+ $meta = $this->first(function ($meta) use ($key) {
+ return $meta->meta_key === $key;
+ });
+
+ return $meta ? $meta->meta_value : null;
+ }
+
+ return null;
+ }
+
+ /**
+ * @param string $name
+ * @return bool
+ */
+ public function __isset($name)
+ {
+ return !is_null($this->__get($name));
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Concerns/Aliases.php b/theme/vendor/wenprise/wp-orm/src/Concerns/Aliases.php
new file mode 100755
index 0000000..8a2a941
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Concerns/Aliases.php
@@ -0,0 +1,74 @@
+
+ */
+trait Aliases
+{
+ /**
+ * @return array
+ */
+ public static function getAliases()
+ {
+ if (isset(parent::$aliases) && count(parent::$aliases)) {
+ return array_merge(parent::$aliases, static::$aliases);
+ }
+
+ return static::$aliases;
+ }
+
+ /**
+ * @param string $new
+ * @param string $old
+ */
+ public static function addAlias($new, $old)
+ {
+ static::$aliases[$new] = $old;
+ }
+
+ /**
+ * @param string $key
+ * @return mixed
+ */
+ public function getAttribute($key)
+ {
+ $value = parent::getAttribute($key);
+
+ if ($value === null && count(static::getAliases())) {
+ if ($value = Arr::get(static::getAliases(), $key)) {
+ if (is_array($value)) {
+ $meta = Arr::get($value, 'meta');
+
+ return $meta ? $this->meta->$meta : null;
+ }
+
+ return parent::getAttribute($value);
+ }
+ }
+
+ return $value;
+ }
+
+ /**
+ * Get alias value from mutator or directly from attribute
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return mixed
+ */
+ public function mutateAttribute($key, $value)
+ {
+ if ($this->hasGetMutator($key)) {
+ return parent::mutateAttribute($key, $value);
+ }
+
+ return $this->getAttribute($key);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Concerns/CustomTimestamps.php b/theme/vendor/wenprise/wp-orm/src/Concerns/CustomTimestamps.php
new file mode 100755
index 0000000..fb7ee6a
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Concerns/CustomTimestamps.php
@@ -0,0 +1,42 @@
+
+ */
+trait CustomTimestamps
+{
+ /**
+ * @param mixed $value
+ * @return mixed
+ */
+ public function setCreatedAt($value)
+ {
+ $field = static::CREATED_AT;
+ $this->{$field} = $value;
+
+ $field .= '_gmt';
+ $this->{$field} = $value;
+
+ return parent::setCreatedAt($value);
+ }
+
+ /**
+ * @param mixed $value
+ * @return mixed
+ */
+ public function setUpdatedAt($value)
+ {
+ $field = static::UPDATED_AT;
+ $this->{$field} = $value;
+
+ $field .= '_gmt';
+ $this->{$field} = $value;
+
+ return parent::setUpdatedAt($value);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Concerns/MetaFields.php b/theme/vendor/wenprise/wp-orm/src/Concerns/MetaFields.php
new file mode 100755
index 0000000..82bce4b
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Concerns/MetaFields.php
@@ -0,0 +1,205 @@
+
+ */
+trait MetaFields
+{
+ /**
+ * @var array
+ */
+ protected $builtInClasses = [
+ \Wenprise\ORM\WP\Comment::class => \Wenprise\ORM\Meta\CommentMeta::class,
+ \Wenprise\ORM\WP\Post::class => \Wenprise\ORM\Meta\PostMeta::class,
+ \Wenprise\ORM\WP\Term::class => \Wenprise\ORM\Meta\TermMeta::class,
+ \Wenprise\ORM\WP\User::class => \Wenprise\ORM\Meta\UserMeta::class,
+ ];
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function fields()
+ {
+ return $this->meta();
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function meta()
+ {
+ return $this->hasMany($this->getMetaClass(), $this->getMetaForeignKey());
+ }
+
+ /**
+ * @return string
+ *
+ * @throws \UnexpectedValueException
+ */
+ protected function getMetaClass()
+ {
+ foreach ($this->builtInClasses as $model => $meta) {
+ if ($this instanceof $model) {
+ return $meta;
+ }
+ }
+
+ throw new UnexpectedValueException(sprintf('%s must extends one of Corcel built-in models: Comment, Post, Term or User.', static::class));
+ }
+
+ /**
+ * @return string
+ *
+ * @throws \UnexpectedValueException
+ */
+ protected function getMetaForeignKey()
+ {
+ foreach ($this->builtInClasses as $model => $meta) {
+ if ($this instanceof $model) {
+ $basename = class_basename($model);
+
+ return sprintf('%s_id', strtolower($basename));
+ }
+ }
+
+ throw new UnexpectedValueException(sprintf('%s must extends one of Corcel built-in models: Comment, Post, Term or User.', static::class));
+ }
+
+ /**
+ * @param Builder $query
+ * @param string $meta
+ * @param mixed $value
+ * @return Builder
+ */
+ public function scopeHasMeta(Builder $query, $meta, $value = null)
+ {
+ if (! is_array($meta)) {
+ $meta = [$meta => $value];
+ }
+
+ foreach ($meta as $key => $value) {
+ $query->whereHas('meta', function ($query) use ($key, $value) {
+ if (is_string($key)) {
+ $query->where('meta_key', $key);
+
+ return is_null($value) ? $query : // 'foo' => null
+ $query->where('meta_value', $value); // 'foo' => 'bar'
+ }
+
+ return $query->where('meta_key', $value); // 0 => 'foo'
+ });
+ }
+
+ return $query;
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ */
+ public function saveField($key, $value)
+ {
+ return $this->saveMeta($key, $value);
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ */
+ public function saveMeta($key, $value = null)
+ {
+ if (is_array($key)) {
+ foreach ($key as $k => $v) {
+ $this->saveOneMeta($k, $v);
+ }
+
+ $this->load('meta');
+
+ return true;
+ }
+
+ return $this->saveOneMeta($key, $value);
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ */
+ private function saveOneMeta($key, $value)
+ {
+ $meta = $this->meta()->where('meta_key', $key)->firstOrNew(['meta_key' => $key]);
+
+ $result = $meta->fill(['meta_value' => $value])->save();
+
+ $this->load('meta');
+
+ return $result;
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ public function createField($key, $value)
+ {
+ return $this->createMeta($key, $value);
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection
+ */
+ public function createMeta($key, $value = null)
+ {
+ if (is_array($key)) {
+ return collect($key)->map(function ($value, $key) {
+ return $this->createOneMeta($key, $value);
+ });
+ }
+
+ return $this->createOneMeta($key, $value);
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ private function createOneMeta($key, $value)
+ {
+ $meta = $this->meta()->create([
+ 'meta_key' => $key,
+ 'meta_value' => $value,
+ ]);
+
+ $this->load('meta');
+
+ return $meta;
+ }
+
+ /**
+ * @param string $attribute
+ * @return mixed|null
+ */
+ public function getMeta($attribute)
+ {
+ if ($meta = $this->meta->{$attribute}) {
+ return $meta;
+ }
+
+ return null;
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Concerns/OrderScopes.php b/theme/vendor/wenprise/wp-orm/src/Concerns/OrderScopes.php
new file mode 100755
index 0000000..2d24846
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Concerns/OrderScopes.php
@@ -0,0 +1,32 @@
+
+ */
+trait OrderScopes
+{
+ /**
+ * @param Builder $query
+ * @return Builder
+ */
+ public function scopeNewest(Builder $query)
+ {
+ return $query->orderBy(static::CREATED_AT, 'desc');
+ }
+
+ /**
+ * @param Builder $query
+ * @return Builder
+ */
+ public function scopeOldest(Builder $query)
+ {
+ return $query->orderBy(static::CREATED_AT, 'asc');
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Meta/CommentMeta.php b/theme/vendor/wenprise/wp-orm/src/Meta/CommentMeta.php
new file mode 100755
index 0000000..e439e4c
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Meta/CommentMeta.php
@@ -0,0 +1,32 @@
+
+ */
+class CommentMeta extends Meta
+{
+ /**
+ * @var string
+ */
+ protected $table = 'commentmeta';
+
+ /**
+ * @var array
+ */
+ protected $fillable = ['meta_key', 'meta_value', 'comment_id'];
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function comment()
+ {
+ return $this->belongsTo(Comment::class);
+ }
+}
\ No newline at end of file
diff --git a/theme/vendor/wenprise/wp-orm/src/Meta/Meta.php b/theme/vendor/wenprise/wp-orm/src/Meta/Meta.php
new file mode 100755
index 0000000..203f5dc
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Meta/Meta.php
@@ -0,0 +1,56 @@
+
+ */
+abstract class Meta extends Model
+{
+ /**
+ * @var string
+ */
+ protected $primaryKey = 'meta_id';
+
+ /**
+ * @var bool
+ */
+ public $timestamps = false;
+
+ /**
+ * @var array
+ */
+ protected $appends = ['value'];
+
+ /**
+ * @return mixed
+ */
+ public function getValueAttribute()
+ {
+ try {
+ $value = unserialize($this->meta_value);
+
+ return $value === false && $this->meta_value !== false ?
+ $this->meta_value :
+ $value;
+ } catch (Exception $ex) {
+ return $this->meta_value;
+ }
+ }
+
+ /**
+ * @param array $models
+ * @return MetaCollection
+ */
+ public function newCollection(array $models = [])
+ {
+ return new MetaCollection($models);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Meta/PostMeta.php b/theme/vendor/wenprise/wp-orm/src/Meta/PostMeta.php
new file mode 100755
index 0000000..bd8d3d8
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Meta/PostMeta.php
@@ -0,0 +1,32 @@
+
+ */
+class PostMeta extends Meta
+{
+
+ protected $primaryKey = 'meta_id';
+
+ protected $table = 'postmeta';
+
+ /**
+ * @var array
+ */
+ protected $fillable = ['meta_key', 'meta_value', 'post_id'];
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function post()
+ {
+ return $this->belongsTo(Post::class);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Meta/TermMeta.php b/theme/vendor/wenprise/wp-orm/src/Meta/TermMeta.php
new file mode 100755
index 0000000..ebee77f
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Meta/TermMeta.php
@@ -0,0 +1,32 @@
+
+ */
+class TermMeta extends Meta
+{
+ /**
+ * @var string
+ */
+ protected $table = 'termmeta';
+
+ /**
+ * @var array
+ */
+ protected $fillable = ['meta_key', 'meta_value', 'term_id'];
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function term()
+ {
+ return $this->belongsTo(Term::class);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Meta/ThumbnailMeta.php b/theme/vendor/wenprise/wp-orm/src/Meta/ThumbnailMeta.php
new file mode 100755
index 0000000..a024671
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Meta/ThumbnailMeta.php
@@ -0,0 +1,66 @@
+
+ */
+class ThumbnailMeta extends PostMeta
+{
+ const SIZE_THUMBNAIL = 'thumbnail';
+ const SIZE_MEDIUM = 'medium';
+ const SIZE_LARGE = 'large';
+ const SIZE_FULL = 'full';
+
+ /**
+ * @var array
+ */
+ protected $with = ['attachment'];
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function attachment()
+ {
+ return $this->belongsTo(Attachment::class, 'meta_value');
+ }
+
+ /**
+ * @param string $size
+ * @return array
+ * @throws \Exception
+ */
+ public function size($size)
+ {
+ if ($size == self::SIZE_FULL) {
+ return $this->attachment->url;
+ }
+
+ $meta = unserialize($this->attachment->meta->_wp_attachment_metadata);
+ $sizes = Arr::get($meta, 'sizes');
+
+ if (!isset($sizes[$size])) {
+ return $this->attachment->url;
+ }
+
+ $data = Arr::get($sizes, $size);
+
+ return array_merge($data, [
+ 'url' => dirname($this->attachment->url).'/'.$data['file'],
+ ]);
+ }
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->attachment->guid;
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/Meta/UserMeta.php b/theme/vendor/wenprise/wp-orm/src/Meta/UserMeta.php
new file mode 100755
index 0000000..567ea3c
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/Meta/UserMeta.php
@@ -0,0 +1,39 @@
+
+ * @author Junior Grossi
+ */
+class UserMeta extends Meta
+{
+
+ protected $primaryKey = 'umeta_id';
+
+ public $timestamps = false;
+
+ /**
+ * @var string
+ */
+ protected $table = 'usermeta';
+
+ /**
+ * @var array
+ */
+ protected $fillable = ['meta_key', 'meta_value', 'user_id'];
+
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function user()
+ {
+ return $this->belongsTo(User::class);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/Attachment.php b/theme/vendor/wenprise/wp-orm/src/WP/Attachment.php
new file mode 100755
index 0000000..1da44a9
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/Attachment.php
@@ -0,0 +1,45 @@
+
+ * @author Junior Grossi
+ */
+class Attachment extends Post {
+ use Aliases;
+
+ /**
+ * @var string
+ */
+ protected $postType = 'attachment';
+
+ /**
+ * @var array
+ */
+ protected $appends = [
+ 'title',
+ 'url',
+ 'type',
+ 'description',
+ 'caption',
+ 'alt',
+ ];
+
+ /**
+ * @var array
+ */
+ protected static $aliases = [
+ 'title' => 'post_title',
+ 'url' => 'guid',
+ 'type' => 'post_mime_type',
+ 'description' => 'post_content',
+ 'caption' => 'post_excerpt',
+ 'alt' => [ 'meta' => '_wp_attachment_image_alt' ],
+ ];
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/Comment.php b/theme/vendor/wenprise/wp-orm/src/WP/Comment.php
new file mode 100755
index 0000000..baa9239
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/Comment.php
@@ -0,0 +1,109 @@
+where('comment_post_ID', $postId)->get();
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function post()
+ {
+ return $this->belongsTo(Post::class, 'comment_post_ID');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function parent()
+ {
+ return $this->original();
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function original()
+ {
+ return $this->belongsTo(Comment::class, 'comment_parent');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function replies()
+ {
+ return $this->hasMany(Comment::class, 'comment_parent');
+ }
+
+ /**
+ * @return bool
+ */
+ public function isApproved()
+ {
+ return $this->attributes['comment_approved'] == 1;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isReply()
+ {
+ return $this->attributes['comment_parent'] > 0;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasReplies()
+ {
+ return $this->replies->count() > 0;
+ }
+
+ /**
+ * @param \Illuminate\Database\Query\Builder $query
+ * @return CommentBuilder
+ */
+ public function newEloquentBuilder($query)
+ {
+ return new CommentBuilder($query);
+ }
+
+ /**
+ * @param mixed $value
+ * @return void
+ */
+ public function setUpdatedAt($value)
+ {
+ //
+ }
+}
\ No newline at end of file
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/Option.php b/theme/vendor/wenprise/wp-orm/src/WP/Option.php
new file mode 100755
index 0000000..fc78dd9
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/Option.php
@@ -0,0 +1,121 @@
+
+ * @author Junior Grossi
+ */
+class Option extends Model
+{
+
+ /**
+ * @var string
+ */
+ protected $primaryKey = 'option_id';
+
+ /**
+ * @var bool
+ */
+ public $timestamps = false;
+
+ /**
+ * @var array
+ */
+ protected $fillable = [
+ 'option_name',
+ 'option_value',
+ 'autoload',
+ ];
+
+ /**
+ * @var array
+ */
+ protected $appends = ['value'];
+
+ /**
+ * @return mixed
+ */
+ public function getValueAttribute()
+ {
+ try {
+ $value = unserialize($this->option_value);
+
+ return $value === false && $this->option_value !== false ?
+ $this->option_value :
+ $value;
+ } catch (Exception $ex) {
+ return $this->option_value;
+ }
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return Option
+ */
+ public static function add($key, $value)
+ {
+ return static::create([
+ 'option_name' => $key,
+ 'option_value' => is_array($value) ? serialize($value) : $value,
+ ]);
+ }
+
+ /**
+ * @param string $name
+ * @return mixed
+ */
+ public static function get($name)
+ {
+ if ($option = self::where('option_name', $name)->first()) {
+ return $option->value;
+ }
+
+ return null;
+ }
+
+ /**
+ * @return array
+ * @deprecated
+ */
+ public static function getAll()
+ {
+ return static::asArray();
+ }
+
+ /**
+ * @param array $keys
+ * @return array
+ */
+ public static function asArray($keys = [])
+ {
+ $query = static::query();
+
+ if (!empty($keys)) {
+ $query->whereIn('option_name', $keys);
+ }
+
+ return $query->get()
+ ->pluck('value', 'option_name')
+ ->toArray();
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ if ($this instanceof Option) {
+ return [$this->option_name => $this->value];
+ }
+
+ return parent::toArray();
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/Page.php b/theme/vendor/wenprise/wp-orm/src/WP/Page.php
new file mode 100755
index 0000000..f6cc442
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/Page.php
@@ -0,0 +1,30 @@
+
+ */
+class Page extends Post
+{
+ /**
+ * @var string
+ */
+ protected $postType = 'page';
+
+ /**
+ * @param Builder $query
+ * @return mixed
+ */
+ public function scopeHome(Builder $query)
+ {
+ return $query
+ ->where('ID', '=', Option::get('page_on_front'))
+ ->limit(1);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/Post.php b/theme/vendor/wenprise/wp-orm/src/WP/Post.php
new file mode 100755
index 0000000..d543fcc
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/Post.php
@@ -0,0 +1,390 @@
+ 'post_title',
+ 'content' => 'post_content',
+ 'excerpt' => 'post_excerpt',
+ 'slug' => 'post_name',
+ 'type' => 'post_type',
+ 'mime_type' => 'post_mime_type',
+ 'url' => 'guid',
+ 'author_id' => 'post_author',
+ 'parent_id' => 'post_parent',
+ 'created_at' => 'post_date',
+ 'updated_at' => 'post_modified',
+ 'status' => 'post_status',
+ ];
+
+ /**
+ * @param \Illuminate\Database\Query\Builder $query
+ * @return PostBuilder
+ */
+ public function newEloquentBuilder($query)
+ {
+ return new PostBuilder($query);
+ }
+
+ /**
+ * @return PostBuilder
+ */
+ public function newQuery()
+ {
+ return $this->postType ? parent::newQuery()->type($this->postType) : parent::newQuery();
+ }
+
+ /**
+ * Filter by post type
+ *
+ * @param $query
+ * @param string $type
+ *
+ * @return mixed
+ */
+ public function scopeType($query, $type = 'post')
+ {
+ return $query->where('post_type', '=', $type);
+ }
+
+ /**
+ * Filter by post status
+ *
+ * @param $query
+ * @param string $status
+ *
+ * @return mixed
+ */
+ public function scopeStatus($query, $status = 'publish')
+ {
+ return $query->where('post_status', '=', $status);
+ }
+
+ /**
+ * Filter by post author
+ *
+ * @param $query
+ * @param null $author
+ *
+ * @return mixed
+ */
+ public function scopeAuthor($query, $author = null)
+ {
+ if ($author) {
+ return $query->where('post_author', '=', $author);
+ }
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasOne
+ */
+ public function thumbnail()
+ {
+ return $this->hasOne(ThumbnailMeta::class, 'post_id')->where('meta_key', '_thumbnail_id');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ */
+ public function taxonomies()
+ {
+ return $this->belongsToMany(Taxonomy::class, 'term_relationships', 'object_id', 'term_taxonomy_id');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function comments()
+ {
+ return $this->hasMany(Comment::class, 'comment_post_ID');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function author()
+ {
+ return $this->belongsTo(User::class, 'post_author');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function parent()
+ {
+ return $this->belongsTo(Post::class, 'post_parent');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function children()
+ {
+ return $this->hasMany(Post::class, 'post_parent');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function attachment()
+ {
+ return $this->hasMany(Post::class, 'post_parent')->where('post_type', 'attachment');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function revision()
+ {
+ return $this->hasMany(Post::class, 'post_parent')->where('post_type', 'revision');
+ }
+
+ /**
+ * Whether the post contains the term or not.
+ *
+ * @param string $taxonomy
+ * @param string $term
+ * @return bool
+ */
+ public function hasTerm($taxonomy, $term)
+ {
+ return isset($this->terms[$taxonomy]) && isset($this->terms[$taxonomy][$term]);
+ }
+
+ /**
+ * @param string $postType
+ */
+ public function setPostType($postType)
+ {
+ $this->postType = $postType;
+ }
+
+ /**
+ * @return string
+ */
+ public function getPostType()
+ {
+ return $this->postType;
+ }
+
+ /**
+ * @return string
+ */
+ public function getContentAttribute()
+ {
+ return do_shortcode($this->post_content);
+ }
+
+ /**
+ * @return string
+ */
+ public function getExcerptAttribute()
+ {
+ return do_shortcode($this->post_excerpt);
+ }
+
+ /**
+ * Gets the featured image if any
+ * Looks in meta the _thumbnail_id field.
+ *
+ * @return string
+ */
+ public function getImageAttribute()
+ {
+ if ($this->thumbnail and $this->thumbnail->attachment) {
+ return $this->thumbnail->attachment->guid;
+ }
+ }
+
+ /**
+ * Gets all the terms arranged taxonomy => terms[].
+ *
+ * @return array
+ */
+ public function getTermsAttribute()
+ {
+ return $this->taxonomies->groupBy(function ($taxonomy) {
+ return $taxonomy->taxonomy == 'post_tag' ? 'tag' : $taxonomy->taxonomy;
+ })->map(function ($group) {
+ return $group->mapWithKeys(function ($item) {
+ return [$item->term->slug => $item->term->name];
+ });
+ })->toArray();
+ }
+
+ /**
+ * Gets the first term of the first taxonomy found.
+ *
+ * @return string
+ */
+ public function getMainCategoryAttribute()
+ {
+ $mainCategory = 'Uncategorized';
+
+ if (! empty($this->terms)) {
+ $taxonomies = array_values($this->terms);
+
+ if (! empty($taxonomies[0])) {
+ $terms = array_values($taxonomies[0]);
+ $mainCategory = $terms[0];
+ }
+ }
+
+ return $mainCategory;
+ }
+
+ /**
+ * Gets the keywords as array.
+ *
+ * @return array
+ */
+ public function getKeywordsAttribute()
+ {
+ return collect($this->terms)->map(function ($taxonomy) {
+ return collect($taxonomy)->values();
+ })->collapse()->toArray();
+ }
+
+ /**
+ * Gets the keywords as string.
+ *
+ * @return string
+ */
+ public function getKeywordsStrAttribute()
+ {
+ return implode(',', (array) $this->keywords);
+ }
+
+ /**
+ * @param string $name The post type slug
+ * @param string $class The class to be instantiated
+ */
+ public static function registerPostType($name, $class)
+ {
+ static::$postTypes[$name] = $class;
+ }
+
+ /**
+ * Clears any registered post types.
+ */
+ public static function clearRegisteredPostTypes()
+ {
+ static::$postTypes = [];
+ }
+
+ /**
+ * Get the post format, like the WP get_post_format() function.
+ *
+ * @return bool|string
+ */
+ public function getFormat()
+ {
+ $taxonomy = $this->taxonomies()->where('taxonomy', 'post_format')->first();
+
+ if ($taxonomy && $taxonomy->term) {
+ return str_replace('post-format-', '', $taxonomy->term->slug);
+ }
+
+ return false;
+ }
+
+ /**
+ * @param string $key
+ * @return mixed
+ */
+ public function __get($key)
+ {
+ $value = parent::__get($key);
+
+ if ($value === null && ! property_exists($this, $key)) {
+ return $this->meta->$key;
+ }
+
+ return $value;
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/Tag.php b/theme/vendor/wenprise/wp-orm/src/WP/Tag.php
new file mode 100755
index 0000000..a2acb00
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/Tag.php
@@ -0,0 +1,17 @@
+
+ */
+class Tag extends Taxonomy
+{
+ /**
+ * @var string
+ */
+ protected $taxonomy = 'post_tag';
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/Taxonomy.php b/theme/vendor/wenprise/wp-orm/src/WP/Taxonomy.php
new file mode 100755
index 0000000..7791b1c
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/Taxonomy.php
@@ -0,0 +1,104 @@
+
+ */
+class Taxonomy extends Model
+{
+ /**
+ * @var string
+ */
+ protected $table = 'term_taxonomy';
+
+ /**
+ * @var string
+ */
+ protected $primaryKey = 'term_taxonomy_id';
+
+ /**
+ * @var array
+ */
+ protected $with = ['term'];
+
+ /**
+ * @var bool
+ */
+ public $timestamps = false;
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function meta()
+ {
+ return $this->hasMany(TermMeta::class, 'term_id');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function term()
+ {
+ return $this->belongsTo(Term::class, 'term_id');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function parent()
+ {
+ return $this->belongsTo(Taxonomy::class, 'parent');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
+ */
+ public function posts()
+ {
+ return $this->belongsToMany(Post::class, 'term_relationships', 'term_taxonomy_id', 'object_id');
+ }
+
+ /**
+ * @param \Illuminate\Database\Query\Builder $query
+ * @return TaxonomyBuilder
+ */
+ public function newEloquentBuilder($query)
+ {
+ return new TaxonomyBuilder($query);
+ }
+
+ /**
+ * TaxonomyBuilder
+ *
+ * @return $this|\Illuminate\Database\Eloquent\Builder
+ */
+ public function newQuery()
+ {
+ return isset($this->taxonomy) && $this->taxonomy ? parent::newQuery()->where('taxonomy', $this->taxonomy) : parent::newQuery();
+ }
+
+ /**
+ * Magic method to return the meta data like the post original fields.
+ *
+ * @param string $key
+ * @return string
+ */
+ public function __get($key)
+ {
+ if (! isset($this->$key)) {
+ if (isset($this->term->$key)) {
+ return $this->term->$key;
+ }
+ }
+
+ return parent::__get($key);
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/Term.php b/theme/vendor/wenprise/wp-orm/src/WP/Term.php
new file mode 100755
index 0000000..f7571d6
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/Term.php
@@ -0,0 +1,40 @@
+
+ */
+class Term extends Model
+{
+ use MetaFields;
+
+ /**
+ * @var string
+ */
+ protected $primaryKey = 'term_id';
+
+ /**
+ * @var bool
+ */
+ public $timestamps = false;
+
+ /**
+ * @var string
+ */
+ protected $table = 'terms';
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasOne
+ */
+ public function taxonomy()
+ {
+ return $this->hasOne(Taxonomy::class, 'term_id');
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/TermRelationship.php b/theme/vendor/wenprise/wp-orm/src/WP/TermRelationship.php
new file mode 100755
index 0000000..7099ae9
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/TermRelationship.php
@@ -0,0 +1,42 @@
+
+ */
+class TermRelationship extends Model
+{
+ /**
+ * @var array
+ */
+ protected $primaryKey = ['object_id', 'term_taxonomy_id'];
+
+ /**
+ * @var bool
+ */
+ public $timestamps = false;
+
+ protected $table = 'term_relationships';
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function post()
+ {
+ return $this->belongsTo(Post::class, 'object_id');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
+ public function taxonomy()
+ {
+ return $this->belongsTo(Taxonomy::class, 'term_taxonomy_id');
+ }
+}
diff --git a/theme/vendor/wenprise/wp-orm/src/WP/User.php b/theme/vendor/wenprise/wp-orm/src/WP/User.php
new file mode 100755
index 0000000..f948f72
--- /dev/null
+++ b/theme/vendor/wenprise/wp-orm/src/WP/User.php
@@ -0,0 +1,203 @@
+
+ * @author Mickael Burguet
+ * @author Junior Grossi
+ */
+class User extends Model
+{
+ const CREATED_AT = 'user_registered';
+
+ const UPDATED_AT = null;
+
+ use Aliases;
+ use MetaFields;
+ use OrderScopes;
+
+ /**
+ * @var string
+ */
+ protected $primaryKey = 'ID';
+
+ /**
+ * @var array
+ */
+ protected $hidden = ['user_pass'];
+
+ /**
+ * @var array
+ */
+ protected $dates = ['user_registered'];
+
+ /**
+ * @var array
+ */
+ protected $with = ['meta'];
+
+ /**
+ * @var array
+ */
+ protected static $aliases = [
+ 'login' => 'user_login',
+ 'email' => 'user_email',
+ 'slug' => 'user_nicename',
+ 'url' => 'user_url',
+ 'nickname' => ['meta' => 'nickname'],
+ 'first_name' => ['meta' => 'first_name'],
+ 'last_name' => ['meta' => 'last_name'],
+ 'created_at' => 'user_registered',
+ ];
+
+ /**
+ * The accessors to append to the model's array form.
+ *
+ * @var array
+ */
+ protected $appends = [
+ 'login',
+ 'email',
+ 'slug',
+ 'url',
+ 'nickname',
+ 'first_name',
+ 'last_name',
+ 'avatar',
+ 'created_at',
+ ];
+
+ /**
+ * @param mixed $value
+ */
+ public function setUpdatedAtAttribute($value)
+ {
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function posts()
+ {
+ return $this->hasMany(Post::class, 'post_author');
+ }
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
+ public function comments()
+ {
+ return $this->hasMany(Comment::class, 'user_id');
+ }
+
+ /**
+ * Get the name of the unique identifier for the user.
+ *
+ * @return string
+ */
+ public function getAuthIdentifierName()
+ {
+ return $this->primaryKey;
+ }
+
+ /**
+ * Get the unique identifier for the user.
+ *
+ * @return mixed
+ */
+ public function getAuthIdentifier()
+ {
+ return $this->attributes[$this->primaryKey];
+ }
+
+ /**
+ * Get the password for the user.
+ *
+ * @return string
+ */
+ public function getAuthPassword()
+ {
+ return $this->user_pass;
+ }
+
+ /**
+ * Get the token value for the "remember me" session.
+ *
+ * @return string
+ */
+ public function getRememberToken()
+ {
+ $tokenName = $this->getRememberTokenName();
+
+ return $this->meta->{$tokenName};
+ }
+
+ /**
+ * Set the token value for the "remember me" session.
+ *
+ * @param string $value
+ */
+ public function setRememberToken($value)
+ {
+ $tokenName = $this->getRememberTokenName();
+
+ $this->meta->{$tokenName} = $value;
+ }
+
+ /**
+ * Get the column name for the "remember me" token.
+ *
+ * @return string
+ */
+ public function getRememberTokenName()
+ {
+ return 'remember_token';
+ }
+
+ /**
+ * Get the e-mail address where password reset links are sent.
+ *
+ * @return string
+ */
+ public function getEmailForPasswordReset()
+ {
+ return $this->user_email;
+ }
+
+ /**
+ * @param string $token
+ */
+ public function sendPasswordResetNotification($token)
+ {
+ }
+
+ /**
+ * Get the avatar url from Gravatar
+ *
+ * @return string
+ */
+ public function getAvatarAttribute()
+ {
+ $hash = ! empty($this->email) ? md5(strtolower(trim($this->email))) : '';
+
+ return sprintf('//secure.gravatar.com/avatar/%s?d=mm', $hash);
+ }
+
+ /**
+ * @param mixed $value
+ * @return void
+ */
+ public function setUpdatedAt($value)
+ {
+ //
+ }
+}
diff --git a/theme/wowpress/Api/BattleNet.php b/theme/wowpress/Api/BattleNet.php
index a58fefb..128a759 100644
--- a/theme/wowpress/Api/BattleNet.php
+++ b/theme/wowpress/Api/BattleNet.php
@@ -24,6 +24,7 @@ class BattleNet extends Api{
public function getGuildRank($name,$realm){
$char = $this->getCharacter($name,$realm);
$guild = $char['guild']['key']['href'];
+ $rank = 99;
if($char['guild']['name'] != "Nebelkrieger" || $char['guild']['realm']['name'] != "Alexstrasza"){
$guild = $char['guild']['name'];
@@ -45,9 +46,12 @@ class BattleNet extends Api{
if($member['character']['name'] == $name && $member['character']['realm']['slug'] == $char['realm']['slug']){
$guild = $char['guild']['name'];
$rank = intval($member['rank']);
+ return compact('guild','rank');
}
}
+ $guild = "-";
+
return compact('guild','rank');
}
diff --git a/theme/wowpress/Api/WoWAudit.php b/theme/wowpress/Api/WoWAudit.php
index d083b32..4b87a46 100644
--- a/theme/wowpress/Api/WoWAudit.php
+++ b/theme/wowpress/Api/WoWAudit.php
@@ -11,9 +11,9 @@ class WoWAudit extends Api{
return $this->get('raids', ['include_past' => $include_past?"true":"false"],true,5);
}
- public function getRaid($id)
+ public function getRaid($id,$force)
{
- return $this->get("raids/$id", [], true, 5);
+ return $this->get("raids/$id", [], true, $force?-1:5);
}
public function getRoster(){
diff --git a/theme/wowpress/Database/CreateCharacterTable.php b/theme/wowpress/Database/CreateCharacterTable.php
index cef5db6..b9c8329 100644
--- a/theme/wowpress/Database/CreateCharacterTable.php
+++ b/theme/wowpress/Database/CreateCharacterTable.php
@@ -11,10 +11,11 @@ class CreateCharacterTable extends CreateTable
'realm' => 'text NOT NULL',
'class' => "text DEFAULT Adventurer",
'spec' => "text DEFAULT Brave",
- 'id_blizz' => 'mediumint(9)',
+ 'id_blizz' => 'mediumint',
+ 'id_wowaudit' => 'mediumint',
'guild' => "text",
'rank' => 'tinyint DEFAULT 99',
- 'user_id' => 'mediumint(9)',
+ 'user_id' => 'mediumint',
];
}
diff --git a/theme/wowpress/Database/CreateSKSTable.php b/theme/wowpress/Database/CreateSKSTable.php
new file mode 100644
index 0000000..2385b60
--- /dev/null
+++ b/theme/wowpress/Database/CreateSKSTable.php
@@ -0,0 +1,18 @@
+ 'text NOT NULL',
+ 'char_name' => 'text NOT NULL',
+ 'realm_name' => 'text NOT NULL',
+ 'rank' => 'tinyint NOT NULL',
+ 'active' => 'boolean NOT NULL',
+ ];
+
+}
diff --git a/theme/wowpress/Database/CreateSignupTable.php b/theme/wowpress/Database/CreateSignupTable.php
new file mode 100644
index 0000000..effb568
--- /dev/null
+++ b/theme/wowpress/Database/CreateSignupTable.php
@@ -0,0 +1,19 @@
+ 'mediumint NOT NULL',
+ 'raid_id' => 'mediumint NOT NULL',
+ 'boss_id' => 'mediumint',
+ 'status' => 'text NOT NULL',
+ 'role' => 'text NOT NULL',
+ 'created_at' => 'timestamp NOT NULL',
+ 'updated_at' => 'timestamp NOT NULL',
+ ];
+
+}
diff --git a/theme/wowpress/Models/Character.php b/theme/wowpress/Models/Character.php
index 8cf6d2a..afec447 100644
--- a/theme/wowpress/Models/Character.php
+++ b/theme/wowpress/Models/Character.php
@@ -29,6 +29,16 @@ class Character extends Model
$this->api = new BattleNet($id,$key);
}
+ public function user(){
+ return $this->belongsTo(User::class);
+ }
+
+ public function getCanEditAttribute(){
+ return current_user_can('wowpress_edit_raids') || (get_current_user_id() == $this->ID);
+ }
+
+
+
protected function sanitize($string,$delimiter_space="")
{
$string = strtolower(str_replace(" ", $delimiter_space, $string));
@@ -47,7 +57,8 @@ class Character extends Model
case 5: return "Raider";
case 6: return "Raider-Twink";
case 7: return "F&F";
- case 8: return "Sleeper";
+ case 8: return "Novize";
+ case 9: return "Sleeper";
default: return "Gast";
}
}
@@ -81,9 +92,12 @@ class Character extends Model
$this->spec = $char_from_api['active_spec']['name'];
$this->id_blizz = $char_from_api['id'];
$guild_data = $this->api->getGuildRank($this->name,$realm);
+ if(!empty($guild_data['rank'])){
$this->guild = $guild_data['guild'];
$this->rank = $guild_data['rank'];
-
+ }else{
+ $this->rank = 99;
+ }
$this->save();
return $char_from_api;
}
diff --git a/theme/wowpress/Models/Raid.php b/theme/wowpress/Models/Raid.php
index f1b0f1e..9273245 100644
--- a/theme/wowpress/Models/Raid.php
+++ b/theme/wowpress/Models/Raid.php
@@ -2,8 +2,10 @@
namespace WoWPress\Models;
+use MO;
use Wenprise\Eloquent\Model;
use WoWPress\Api\BattleNet;
+use WoWPress\Api\WoWAudit;
class Raid extends Model
{
@@ -13,42 +15,201 @@ class Raid extends Model
protected $primaryKey = 'ID';
protected $guarded = ['ID'];
+ public $signups;
+
private $api;
+ public $notes;
+
+ public $encounters;
+ public $status;
+ public $partial;
public function __construct($attrs = [])
{
parent::__construct($attrs);
$options = get_option('wowpress_api');
- if(isset($options['bnet'])){
+ if (isset($options['bnet'])) {
$key = get_option('wowpress_api')['wowaudit']['key'];
- }else{
+ } else {
return false;
}
- $this->api = new BattleNet(null,$key);
+ $this->api = new WoWAudit(null, $key);
}
+ private function sortRoles($a, $b)
+ {
+ switch ($a->role) {
+ case 'Tank':
+ $asort = 0;
+ break;
+ case 'Heal':
+ $asort = 1;
+ break;
+ case 'Ranged':
+ $asort = 2;
+ break;
+ case 'Melee':
+ $asort = 3;
+ break;
+ default:
+ $asort = 4;
+ break;
+ }
+ switch ($b->role) {
+ case 'Tank':
+ $bsort = 0;
+ break;
+ case 'Heal':
+ $bsort = 1;
+ break;
+ case 'Ranged':
+ $bsort = 2;
+ break;
+ case 'Melee':
+ $bsort = 3;
+ break;
+ default:
+ $bsort = 4;
+ break;
+ }
+ return $asort - $bsort;
+ }
- public function getColorAttribute($type=""){
- switch($this->difficulty){
- case 'Normal': return "shaman";
- case 'Heroic': return "warlock";
- case 'Mythic': return "deathknight";
- case 'Teamspeak': return "hunter";
- default: return "priest";
+ public function sync($force = false)
+ {
+
+ if (!empty($this->id_wowaudit)) {
+ $raid = (object)$this->api->getRaid($this->id_wowaudit, $force);
+ if (!empty($raid->id)) {
+ $this->title = $raid->instance;
+ $this->start = $raid->date . " " . $raid->start_time;
+ $this->end = $raid->date . " " . $raid->end_time;
+ $this->difficulty = $raid->difficulty;
+ $this->status = $raid->status;
+ $encounters = $raid->encounters;
+
+ $partial = false;
+ $signups = [];
+ $sup = [];
+ foreach ($encounters as $key => &$encounter) {
+ $partial = $encounter['enabled'] || $partial;
+ if (empty($encounter['selections'])) {
+ $encounter['selections'] = [];
+ }
+ $encounters[$key]['selections'] = collect($encounter['selections']);
+ }
+ $this->partial = $partial;
+ foreach ($raid->signups as $signup) {
+ $character = Character::whereName($signup['character']['name'])->whereRealm($signup['character']['realm'])->first();
+ if (empty($character)) {
+ $character = new Character();
+ $character->name = $signup['character']['name'];
+ $character->realm = $signup['character']['realm'];
+ $character->updateFromAPI();
+ }
+ if ($character->class != $signup['class']) {
+ if (!empty($character->user)) {
+ $newchar = $character->user->characters()->where('class', $signup['class'])->first();
+ if (!empty($newchar->ID)) {
+ $character = $newchar;
+ }
+ }
+ }
+ $character->id_wowaudit = $signup['character']['id'];
+ $character->save();
+ $sup[$character->id_wowaudit] = $signup['status'];
+ $s = new Signup();
+ $s->character_id = $character->ID;
+ $s->raid_ID = $this->ID;
+ if ($this->partial) {
+ foreach ($encounters as $encounter) {
+ if ($signup['selected']) break;
+ if (empty($encounter['selections'])) continue;
+ foreach ($encounter['selections'] as $selection) {
+ if ($selection['character_id'] == $signup['character']['id']) {
+ $signup['selected'] = $selection['selected'] || $signup['selected'];
+ if ($signup['selected']) {
+ break 2;
+ }
+ }
+ }
+ }
+ }
+ $s->status = $signup['selected'] ? "Selected" : $signup['status'];
+ $s->role = $signup['status'] == "Unknown" ? "Unknown" : $signup['role'];
+ $signups[] = $s;
+ }
+
+ $this->signups = collect($signups);
+
+
+
+ foreach ($encounters as $encounter) {
+ foreach ($encounter['selections'] as $key => &$selection) {
+ $character = Character::where('id_wowaudit', $selection['character_id'])->first();
+ $selection['status'] = $sup[$character->id_wowaudit];
+
+ $s = new Signup();
+ $s->character_id = $character->ID;
+ $s->raid_ID = $this->ID;
+ $s->boss_id = $encounter['id'];
+ $s->status = $selection['selected'] ? "Selected" : $selection['status'];
+ $s->role = $selection['role'];
+
+ $encounter['selections'][$key] = $s;
+ }
+ }
+
+
+
+ array_unshift($encounters, [
+ 'name' => "Alle Bosse",
+ 'id' => 0,
+ 'enabled' => true,
+ 'notes' => $raid->notes,
+ 'selections' => $this->signups,
+ ]);
+
+ foreach ($encounters as &$encounter) {
+ $encounter['selections'] = collect($encounter['selections'])->sortBy([fn ($a, $b) => $this->sortRoles($a, $b), 'character_id']);
+ }
+
+ $this->encounters = collect($encounters);
+ }
+ }
+
+ return false;
+ }
+
+ public function getColorAttribute($type = "")
+ {
+ switch ($this->difficulty) {
+ case 'Normal':
+ return "shaman";
+ case 'Heroic':
+ return "warlock";
+ case 'Mythic':
+ return "deathknight";
+ case 'Teamspeak':
+ return "hunter";
+ default:
+ return "priest";
}
}
- public function getLinkAttribute(){
- return "/raid/".$this->ID;
+ public function getLinkAttribute()
+ {
+ return "/raid/" . $this->ID;
}
- public function getPreviousAttribute(){
+ public function getPreviousAttribute()
+ {
$id = $this->ID;
- while($id){
+ while ($id) {
$raid = Raid::find(--$id);
- if(!empty($raid->ID)){
+ if (!empty($raid->ID)) {
return $raid;
}
}
@@ -56,19 +217,40 @@ class Raid extends Model
}
- public function getNextAttribute(){
+ public function getNextAttribute()
+ {
$id = $this->ID;
- while($id <= Raid::max('ID')){
+ while ($id <= Raid::max('ID')) {
$raid = Raid::find(++$id);
- if(!empty($raid->ID)){
+ if (!empty($raid->ID)) {
return $raid;
}
}
return false;
}
- public function showSignup(Character $character){
- require(get_template_directory()."/components/raid-signup.php");
- }
+ public function showSignup($character, $showRole = false, $showStatus = false, $vertical = false)
+ {
+ $u = $character->user;
+ if (!empty($u->ID)) {
+ $chars = $u->characters;
+ } else {
+ $chars = [$character];
+ }
+ if (!empty($character->ID) && !empty($this->signups)) {
+ foreach ($this->signups as $signup) {
+ foreach ($chars as $character) {
+ if ($signup->character->ID == $character->ID) {
+ return $signup->showForm($showRole, $showStatus, $vertical);
+ }
+ }
+ }
+ }
-}
\ No newline at end of file
+ $s = new Signup();
+ $s->raid_id = $this->ID;
+ $s->character_id = $character->ID;
+ return $s->showForm($showRole,$showStatus,$vertical);
+
+ }
+}
diff --git a/theme/wowpress/Models/SKS.php b/theme/wowpress/Models/SKS.php
new file mode 100644
index 0000000..8e9e365
--- /dev/null
+++ b/theme/wowpress/Models/SKS.php
@@ -0,0 +1,28 @@
+orderBy('rank')->get();
+ }
+
+ public static function getLists(){
+ return static::distinct('list_name')->get();
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/theme/wowpress/Models/Signup.php b/theme/wowpress/Models/Signup.php
new file mode 100644
index 0000000..7c438eb
--- /dev/null
+++ b/theme/wowpress/Models/Signup.php
@@ -0,0 +1,163 @@
+statusList = [
+ 'Unknown' => (object)[
+ 'selectable' => false,
+ 'name' => 'Keine Rückmeldung',
+ 'icon' => 'o-no-symbol',
+ 'color' => 'slate-500',
+ ],
+ 'Present' => (object)[
+ 'selectable' => true,
+ 'name' => 'Anwesend',
+ 'icon' => 'o-check-circle',
+ 'color' => 'green-500',
+ ],
+ 'Absent' => (object)[
+ 'selectable' => true,
+ 'name' => 'Abwesend',
+ 'icon' => 'o-x-circle',
+ 'color' => 'red-500',
+ ],
+ 'Late' => (object)[
+ 'selectable' => true,
+ 'name' => 'Verspätet',
+ 'icon' => 'o-clock',
+ 'color' => 'orange-500',
+ ],
+ 'Tentative' => (object)[
+ 'selectable' => true,
+ 'name' => 'Ersatzbank',
+ 'icon' => 'o-question-mark-circle',
+ 'color' => 'yellow-500',
+ ],
+ 'Selected' => (object)[
+ 'selectable' => false,
+ 'name' => 'Bestätigt',
+ 'icon' => 's-star',
+ 'color' => 'paladin',
+ ],
+ ];
+
+ $this->roleList = [
+ 'Unknown' => (object)[
+ 'selectable' => false,
+ 'name' => 'Keine Rolle',
+ 'icon' => 'o-no-symbol',
+ 'color' => 'slate-500',
+ ],
+ 'Tank' => (object)[
+ 'selectable' => true,
+ 'name' => 'Tank',
+ 'icon' => 'o-shield-exclamation',
+ 'color' => 'white',
+ ],
+ 'Heal' => (object)[
+ 'selectable' => true,
+ 'name' => 'Heilung',
+ 'icon' => 'o-heart',
+ 'color' => 'white',
+ ],
+ 'Ranged' => (object)[
+ 'selectable' => true,
+ 'name' => 'Ranged',
+ 'icon' => 'o-bolt',
+ 'color' => 'white',
+ ],
+ 'Melee' => (object)[
+ 'selectable' => true,
+ 'name' => 'Melee',
+ 'icon' => 'o-hand-raised',
+ 'color' => 'white',
+ ],
+ ];
+ }
+
+ public function character(){
+ return $this->belongsTo(Character::class);
+ }
+
+ public function raid(){
+ return $this->belongsTo(Raid::class);
+ }
+
+ public function showForm($showRole = false, $showStatus = false,$vertical = false,$doSignup = true){
+ require(get_template_directory()."/components/raid-signup.php");
+ }
+
+ public function getStatusList($selectable = false){
+ $out = [];
+ foreach($this->statusList as $key => $status){
+ if($selectable){
+ if($status->selectable){
+ $out[$key] = $status;
+ }
+ }else{
+ $out[$key] = $status;
+ }
+ }
+
+ return $out;
+ }
+
+ public function getRoleList(){
+ $out = [];
+ foreach($this->roleList as $key => $status){
+ if($status->selectable){
+ $out[$key] = $status;
+ }
+ }
+
+ return $out;
+ }
+
+
+ public function getStatus(){
+ if (key_exists($this->status, $this->statusList)) {
+ return $this->statusList[$this->status];
+ }
+ return $this->statusList['Unknown'];
+ }
+
+ public function getRole(){
+ if (key_exists($this->role, $this->roleList)) {
+ return $this->roleList[$this->role];
+ }
+ return $this->roleList['Unknown'];
+ }
+
+ public function setStatus($status){
+ if (key_exists($status, $this->statusList)) {
+ $this->status = $status;
+ return true;
+ }
+ return false;
+ }
+
+ public function setRole($role){
+ if (key_exists($role, $this->roleList)) {
+ $this->role = $role;
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/theme/wowpress/Models/User.php b/theme/wowpress/Models/User.php
new file mode 100644
index 0000000..a66aed0
--- /dev/null
+++ b/theme/wowpress/Models/User.php
@@ -0,0 +1,15 @@
+hasMany(Character::class)->orderBy('rank');
+ }
+
+
+}
\ No newline at end of file
-
+
+
+
+
- =get_the_date('d')?>
- =get_the_date('F')?>
+ = get_the_date('d') ?>
+ = get_the_date('F') ?>
term_id, 'color', true );
+ $color = get_term_meta($category->term_id, 'color', true);
?>
- =$category->name?>
-
+ = $category->name ?>
+
-
+ ID)) : ?>
+
+ = $author->display_name ?>
+
+
+ = $author->display_name ?>
+
+