Issues (172)

app/Event.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Event extends Model
8
{
9
    // public function __construct(Array $attributes = [])
10
    // {
11
    //     parent::__construct($attributes);
12
    //     $db = \Session::get('db');
13
    //     error_log('Event+++++++++++++++++++++++++++++++++++'.$db);
14
    //     if(empty($db)) {
15
    //         $db = env('DB_DATABASE', 'enso');
16
    //     }
17
    //     if($db === env('DB_DATABASE')) {
18
    //         $key = 'database.connections.mysql.database';
19
    //         config([$key => $db]);
20
    //     } else {
21
    //         $key = 'database.connections.mysql.database';
22
    //         config([$key => $db]);
23
    //     }
24
    //     \DB::purge('mysql');
25
    //     \DB::reconnect('mysql');
26
    //     $this->setConnection('mysql');
27
    //     error_log('-----------------------------------'.$this->getConnection()->getDatabaseName());
28
    // }
29
    protected $gedcom_event_names = [];
30
31
    public function place()
32
    {
33
        return $this->hasOne(Place::class, 'id', 'places_id');
34
    }
35
36
    public function getPlacename()
37
    {
38
        if ($this->place) {
39
            return $this->place->title;
40
        } else {
41
            return 'unknown place';
42
        }
43
    }
44
45
    public function getTitle()
46
    {
47
        return $this->gedcom_event_names[$this->title] ?? $this->title;
0 ignored issues
show
The property title does not seem to exist on App\Event. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
48
    }
49
50
    public function scopeOrderByDate($query)
51
    {
52
        return $query->orderBy('year')->orderBy('month')->orderBy('day');
53
    }
54
}
55