-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrix.php
44 lines (38 loc) · 869 Bytes
/
Matrix.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* Created by IntelliJ IDEA.
* User: fernando
* Date: 7/5/16
* Time: 10:47 PM
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use MatrixSeeder;
/**
* Matrix entity, containing size information.
*
* Class Matrix
* @package App\Models
*/
class Matrix extends Model
{
protected $fillable = ['size'];
/**
* Eloquent relation that maps all cells belonging to a Matrix
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function cells()
{
return $this->hasMany('App\Models\Cell', 'matrix_id', 'id');
}
/**
* Declaring the event handler for matrix deleting (deleting related cells)
*/
protected static function boot() {
parent::boot();
static::deleting(function($matrix) {
$matrix->cells()->delete();
});
}
}