1 | <?php namespace Arcanedev\LaravelSeo\Models; |
||
24 | class Seo extends Model |
||
25 | { |
||
26 | /* ------------------------------------------------------------------------------------------------ |
||
27 | | Properties |
||
28 | | ------------------------------------------------------------------------------------------------ |
||
29 | */ |
||
30 | /** |
||
31 | * The table associated with the model. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $table = 'seo'; |
||
36 | |||
37 | /** |
||
38 | * The attributes that are mass assignable. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $fillable = ['title', 'description', 'keywords', 'metas', 'noindex']; |
||
43 | |||
44 | /** |
||
45 | * The attributes that should be casted to native types. |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $casts = [ |
||
50 | 'id' => 'integer', |
||
51 | 'seoable_id' => 'integer', |
||
52 | 'metas' => 'collection', |
||
53 | 'noindex' => 'boolean', |
||
54 | ]; |
||
55 | |||
56 | /* ------------------------------------------------------------------------------------------------ |
||
57 | | Constructor |
||
58 | | ------------------------------------------------------------------------------------------------ |
||
59 | */ |
||
60 | /** |
||
61 | * Create a new Eloquent model instance. |
||
62 | * |
||
63 | * @param array $attributes |
||
64 | */ |
||
65 | public function __construct(array $attributes = []) |
||
71 | |||
72 | /* ------------------------------------------------------------------------------------------------ |
||
73 | | Relationships |
||
74 | | ------------------------------------------------------------------------------------------------ |
||
75 | */ |
||
76 | /** |
||
77 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
78 | */ |
||
79 | public function seoable() |
||
83 | } |
||
84 |
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: