FamilyEvent::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\SoftDeletes;
6
use LaravelEnso\Tables\Traits\TableCache;
7
use ModularSoftware\LaravelGedcom\Observers\EventActionsObserver;
8
9
class FamilyEvent extends Event
10
{
11
    use SoftDeletes;
12
    use TableCache;
13
    // public function __construct(Array $attributes = [])
14
    // {
15
    //     parent::__construct($attributes);
16
    //     $db = \Session::get('db');
17
    //     error_log('+++FamilyEvent++++++++++++++++++++++++++++++++'.$db);
18
    //     if(empty($db)) {
19
    //         $db = env('DB_DATABASE', 'enso');
20
    //     }
21
    //     if($db === env('DB_DATABASE')) {
22
    //         $key = 'database.connections.mysql.database';
23
    //         config([$key => $db]);
24
    //     } else {
25
    //         $key = 'database.connections.mysql.database';
26
    //         config([$key => $db]);
27
    //     }
28
    //     \DB::purge('mysql');
29
    //     \DB::reconnect('mysql');
30
    //     $this->setConnection('mysql');
31
    //     error_log('-----------------------------------'.$this->getConnection()->getDatabaseName());
32
    // }
33
    /**
34
     * The attributes that should be mutated to dates.
35
     *
36
     * @var array
37
     */
38
    protected $dates = ['deleted_at'];
39
40
    protected $table = 'family_events';
41
42
    protected $fillable = [
43
        'family_id',
44
        'places_id',
45
        'date',
46
        'title',
47
        'description',
48
        'year',
49
        'month',
50
        'day',
51
        'type',
52
        'plac',
53
        'phon',
54
        'caus',
55
        'age',
56
        'husb',
57
        'wife',
58
    ];
59
60
    public static function boot()
61
    {
62
        parent::boot();
63
64
        self::observe(new EventActionsObserver());
65
    }
66
67
    public function family()
68
    {
69
        return $this->hasOne(Family::class, 'id', 'family_id');
70
    }
71
}
72