1: <?php
2:
3: /**
4: * Deep
5: *
6: * @package rsanchez\Deep
7: * @author Rob Sanchez <info@robsanchez.com>
8: */
9:
10: namespace rsanchez\Deep\Model;
11:
12: use Illuminate\Database\Eloquent\Model;
13:
14: /**
15: * Model for the comments table
16: */
17: class Comment extends Model
18: {
19: /**
20: * {@inheritdoc}
21: *
22: * @var string
23: */
24: protected $table = 'comments';
25:
26: /**
27: * {@inheritdoc}
28: *
29: * @var string
30: */
31: protected $primaryKey = 'comment_id';
32:
33: /**
34: * Define the Author Eloquent relationship
35: * @return \Illuminate\Database\Eloquent\Relations\HasOne
36: */
37: public function author()
38: {
39: return $this->hasOne('\\rsanchez\\Deep\\Model\\Member', 'member_id', 'author_id');
40: }
41:
42: /**
43: * Get the comment_date column as a Carbon object
44: *
45: * @param int $value unix time
46: * @return \Carbon\Carbon
47: */
48: public function getCommentDateAttribute($value)
49: {
50: return Carbon::createFromFormat('U', $value);
51: }
52:
53: /**
54: * Get the edit_date column as a Carbon object
55: *
56: * @param int $value unix time
57: * @return \Carbon\Carbon|null
58: */
59: public function getEditDateAttribute($value)
60: {
61: return $value ? Carbon::createFromFormat('U', $value) : null;
62: }
63: }
64: