Issues (20)

src/Traits/HasSchemalessTable.php (1 issue)

1
<?php
2
3
namespace PrismX\Schemaless\Traits;
4
5
use Illuminate\Database\Eloquent\Model;
6
use PrismX\Schemaless\Support\DocumentScope;
7
8
trait HasSchemalessTable
9
{
10
    public static function bootHasSchemalessTable()
11
    {
12
        static::saving(function (Model &$model) {
13
            $model->model = $model->model ?: get_class($model);
14
            $model->locale = $model->locale ?: app()->getLocale();
0 ignored issues
show
The method getLocale() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
            $model->locale = $model->locale ?: app()->/** @scrutinizer ignore-call */ getLocale();
Loading history...
15
        });
16
17
        // limit query of this model to its type
18
        static::addGlobalScope(new DocumentScope());
19
    }
20
21
    public function getTable()
22
    {
23
        return '_documents';
24
    }
25
26
    public function getFillable()
27
    {
28
        return array_merge(
29
            parent::getFillable(),
30
            [
31
                'model',
32
                'locale',
33
                'collection',
34
            ]
35
        );
36
    }
37
}
38