News::comments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * rmarchiv.tk
5
 * (c) 2016-2017 by Marcel 'ryg' Hering
6
 */
7
8
namespace App\Models;
9
10
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
11
use Illuminate\Database\Eloquent\Model;
12
13
/**
14
 * Class News.
15
 *
16
 * @property int $id
17
 * @property string $title
18
 * @property string $news_md
19
 * @property string $news_html
20
 * @property string $news_category
21
 * @property int $user_id
22
 * @property string $deleted_at
23
 * @property \Carbon\Carbon $created_at
24
 * @property \Carbon\Carbon $updated_at
25
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereId($value)
26
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereTitle($value)
27
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereNewsMd($value)
28
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereNewsHtml($value)
29
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereNewsCategory($value)
30
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereUserId($value)
31
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereDeletedAt($value)
32
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereCreatedAt($value)
33
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereUpdatedAt($value)
34
 * @mixin \Eloquent
35
 * @property-read \App\Models\User $user
36
 * @property int $approved
37
 * @method static \Illuminate\Database\Query\Builder|\App\Models\News whereApproved($value)
38
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Comment[] $comments
39
 * @property-read \Illuminate\Database\Eloquent\Collection|\Venturecraft\Revisionable\Revision[] $revisionHistory
40
 */
41
class News extends Model
42
{
43
    use \Venturecraft\Revisionable\RevisionableTrait;
44
    public $timestamps = true;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
45
    protected $table = 'news';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
46
    protected $fillable = [
47
        'title',
48
        'news_md',
49
        'news_html',
50
        'news_category',
51
        'user_id',
52
        'approved',
53
    ];
54
55
    protected $guarded = [];
56
57
    public function user()
58
    {
59
        return $this->hasOne('App\Models\User', 'id', 'user_id');
60
    }
61
62
    public function comments()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
63
    {
64
        return $this->hasMany('App\Models\Comment', 'content_id', 'id')
65
            ->Where('content_type', '=', \DB::raw("'news'"))
66
            ->with('user');
67
    }
68
}
69