Completed
Push — master ( cfed93...a79400 )
by Phecho
03:52
created

ProjectNamespace::projects()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 * 
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
# == Schema Information
13
#
14
# Table name: namespaces
15
#
16
#  id          :integer          not null, primary key
17
#  name        :string(255)      not null
18
#  path        :string(255)      not null
19
#  owner_id    :integer
20
#  created_at  :datetime
21
#  updated_at  :datetime
22
#  type        :string(255)
23
#  description :string(255)      default(""), not null
24
#  avatar      :string(255)
25
#  public      :boolean          default(FALSE)
26
#
27
28
namespace Gitamin\Models;
29
30
use AltThree\Validator\ValidatingTrait;
31
use Illuminate\Database\Eloquent\Model;
32
33
class ProjectNamespace extends Model
34
{
35
    use ValidatingTrait;
36
37
    /**
38
     * The attributes that should be casted to native types.
39
     *
40
     * @var string[]
41
     */
42
    protected $casts = [
43
        'id'   => 'int',
44
        'name' => 'string',
45
        'path' => 'string',
46
        'type' => 'string',
47
    ];
48
49
    /**
50
     * The fillable properties.
51
     *
52
     * @var string[]
53
     */
54
    protected $fillable = ['name', 'path', 'type'];
55
56
    /**
57
     * The validation rules.
58
     *
59
     * @var string[]
60
     */
61
    public $rules = [
62
        'name'  => 'required|string',
63
        'path'  => 'required|string',
64
        'type'  =>  'string',
65
    ];
66
67
    /**
68
     * A namespace can have many projects.
69
     *
70
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
71
     */
72
    public function projects()
73
    {
74
        return $this->hasMany(Project::class, 'namespace_id', 'id');
75
    }
76
}
77