-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Zae/feature/l6
updates for laravel 6
- Loading branch information
Showing
17 changed files
with
1,177 additions
and
589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,283 @@ | ||
<?php | ||
|
||
namespace Zae\LaraPress\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Class Comment | ||
* | ||
* @package Zae\LaraPress\Models | ||
*/ | ||
class Comment extends Model | ||
{ | ||
const CREATED_AT = 'comment_date'; | ||
const UPDATED_AT = 'comment_date'; | ||
|
||
protected $table = 'wp_comments'; | ||
protected $primaryKey = 'comment_ID'; | ||
protected $appends = [ | ||
'id', | ||
'author', | ||
'author_email', | ||
'author_url', | ||
'author_IP', | ||
'content', | ||
'karma', | ||
'approved', | ||
'user_agent', | ||
'type' | ||
]; | ||
|
||
protected $hidden = [ | ||
'comment_ID', | ||
'comment_post_ID', | ||
'comment_parent', | ||
'user_id', | ||
'comment_author', | ||
'comment_author_email', | ||
'comment_author_url', | ||
'comment_author_IP', | ||
'comment_content', | ||
'comment_karma', | ||
'comment_approved', | ||
'comment_agent', | ||
'comment_type' | ||
]; | ||
|
||
/* | ||
* Relations | ||
*/ | ||
|
||
/** | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function post() | ||
{ | ||
return $this->belongsTo(Post::class, 'comment_post_ID', 'ID'); | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function user() | ||
{ | ||
return $this->belongsTo(User::class, 'user_id', 'ID'); | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function commentmeta() | ||
{ | ||
return $this->hasMany(CommentMeta::class, 'comment_id', $this->primaryKey); | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function meta() | ||
{ | ||
return $this->commentmeta(); | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function parent() | ||
{ | ||
return $this->belongsTo(__CLASS__, 'comment_parent', $this->primaryKey); | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function children() | ||
{ | ||
return $this->hasMany(__CLASS__, 'comment_parent', $this->primaryKey); | ||
} | ||
|
||
/* | ||
* Accessors & Mutators | ||
*/ | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setIdAttribute($value) | ||
{ | ||
$this->attributes[$this->primaryKey] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getIdAttribute() | ||
{ | ||
return $this->attributes[$this->primaryKey]; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setAuthorAttribute($value) | ||
{ | ||
$this->attributes['comment_author'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getAuthorAttribute() | ||
{ | ||
return $this->attributes['comment_author']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setAuthorEmailAttribute($value) | ||
{ | ||
$this->attributes['comment_author_email'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getAuthorEmailAttribute() | ||
{ | ||
return $this->attributes['comment_author_email']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setAuthorUrlAttribute($value) | ||
{ | ||
$this->attributes['comment_author_url'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getAuthorUrlAttribute() | ||
{ | ||
return $this->attributes['comment_author_url']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setAuthorIPAttribute($value) | ||
{ | ||
$this->attributes['comment_author_IP'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getAuthorIPAttribute() | ||
{ | ||
return $this->attributes['comment_author_IP']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setContentAttribute($value) | ||
{ | ||
$this->attributes['comment_content'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getContentAttribute() | ||
{ | ||
return $this->attributes['comment_content']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setKarmaAttribute($value) | ||
{ | ||
$this->attributes['comment_karma'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getKarmaAttribute() | ||
{ | ||
return $this->attributes['comment_karma']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setApprovedAttribute($value) | ||
{ | ||
$this->attributes['comment_approved'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getApprovedAttribute() | ||
{ | ||
return $this->attributes['comment_approved']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setUserAgentAttribute($value) | ||
{ | ||
$this->attributes['comment_agent'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getUserAgentAttribute() | ||
{ | ||
return $this->attributes['comment_agent']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setTypeAttribute($value) | ||
{ | ||
$this->attributes['comment_type'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getTypeAttribute() | ||
{ | ||
return $this->attributes['comment_type']; | ||
} | ||
|
||
/* | ||
* Scopes | ||
*/ | ||
|
||
/** | ||
* @param $query | ||
*/ | ||
public function scopeApproved($query) | ||
{ | ||
$query->where('comment_approved', true); | ||
} | ||
|
||
/** | ||
* @param $query | ||
*/ | ||
public function scopeNotApproved($query) | ||
{ | ||
$query->where('comment_approved', false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Zae\LaraPress\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Class CommentMeta | ||
* | ||
* @package Zae\LaraPress\Models | ||
*/ | ||
class CommentMeta extends Model | ||
{ | ||
protected $table = 'wp_commentmeta'; | ||
protected $primaryKey = 'meta_id'; | ||
protected $appends = ['id', 'key', 'value']; | ||
protected $hidden = ['meta_id', 'comment_id', 'meta_key', 'meta_value']; | ||
|
||
public $timestamps = false; | ||
|
||
/* | ||
* Relations | ||
*/ | ||
|
||
/** | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function comment() | ||
{ | ||
return $this->belongsTo(Comment::class); | ||
} | ||
|
||
/* | ||
* Accessors & Mutators | ||
*/ | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setIdAttribute($value) | ||
{ | ||
$this->attributes[$this->primaryKey] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getIdAttribute() | ||
{ | ||
return $this->attributes[$this->primaryKey]; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setKeyAttribute($value) | ||
{ | ||
$this->attributes['meta_key'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getKeyAttribute() | ||
{ | ||
return $this->attributes['meta_key']; | ||
} | ||
|
||
/** | ||
* @param $value | ||
*/ | ||
public function setValueAttribute($value) | ||
{ | ||
$this->attributes['meta_value'] = $value; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getValueAttribute() | ||
{ | ||
return $this->attributes['meta_value']; | ||
} | ||
} |
Oops, something went wrong.