1 | <?php |
||
2 | |||
3 | namespace App\Models; |
||
4 | |||
5 | use GenealogiaWebsite\LaravelGedcom\Models\Place; |
||
0 ignored issues
–
show
|
|||
6 | use GenealogiaWebsite\LaravelGedcom\Observers\EventActionsObserver; |
||
7 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
8 | |||
9 | class FamilyEvent extends Event |
||
10 | { |
||
11 | use SoftDeletes; |
||
12 | |||
13 | /** |
||
14 | * The attributes that should be mutated to dates. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $dates = ['deleted_at']; |
||
19 | |||
20 | protected $table = 'family_events'; |
||
21 | |||
22 | protected $fillable = [ |
||
23 | 'family_id', |
||
24 | 'places_id', |
||
25 | 'date', |
||
26 | 'title', |
||
27 | 'description', |
||
28 | 'year', |
||
29 | 'month', |
||
30 | 'day', |
||
31 | 'type', |
||
32 | 'plac', |
||
33 | 'phon', |
||
34 | 'caus', |
||
35 | 'age', |
||
36 | 'husb', |
||
37 | 'wife', |
||
38 | ]; |
||
39 | |||
40 | public static function boot() |
||
41 | { |
||
42 | parent::boot(); |
||
43 | |||
44 | self::observe(new EventActionsObserver()); |
||
45 | } |
||
46 | |||
47 | public function family() |
||
48 | { |
||
49 | return $this->hasMany(Family::class, 'id', 'family_id'); |
||
50 | } |
||
51 | |||
52 | public function place() |
||
53 | { |
||
54 | return $this->hasMany(Place::class, 'id', 'places_id'); |
||
55 | } |
||
56 | } |
||
57 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: