1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PrismX\Schemaless\Support; |
4
|
|
|
|
5
|
|
|
use App\Nova\Resource; |
|
|
|
|
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use Illuminate\Support\Str; |
8
|
|
|
use Laravel\Nova\Fields\Text; |
|
|
|
|
9
|
|
|
use Laravel\Nova\Http\Requests\NovaRequest; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class DocumentResource extends Resource |
12
|
|
|
{ |
13
|
|
|
public static $collection = 'documents'; |
14
|
|
|
|
15
|
|
|
public static $model = 'PrismX\Schemaless\Document'; |
16
|
|
|
|
17
|
|
|
public static $title = 'model'; |
18
|
|
|
|
19
|
|
|
public static $search = ['model']; |
20
|
|
|
|
21
|
|
|
public function __construct($resource) |
22
|
|
|
{ |
23
|
|
|
if ($resource->model) { |
24
|
|
|
static::$model = $resource->model; |
25
|
|
|
$this->resource = (new $resource->model())->find($resource->id); |
|
|
|
|
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function fields(Request $request) |
30
|
|
|
{ |
31
|
|
|
return array_merge([ |
32
|
|
|
Text::make('Document', function () { |
33
|
|
|
return Str::normalize(Str::afterLast($this->model, '\\')); |
34
|
|
|
})->onlyOnIndex(), |
35
|
|
|
], $this->resource->getNovaFields() |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public static function indexQuery(NovaRequest $request, $query) |
40
|
|
|
{ |
41
|
|
|
return $query |
42
|
|
|
->where('collection', static::$collection) |
43
|
|
|
->where('locale', app()->getLocale()); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public static function detailQuery(NovaRequest $request, $query) |
47
|
|
|
{ |
48
|
|
|
return parent::detailQuery($request, $query |
49
|
|
|
->where('collection', static::$collection) |
50
|
|
|
->where('locale', app()->getLocale())); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public static function authorizedToCreate(Request $request) |
54
|
|
|
{ |
55
|
|
|
return false; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function authorizedToDelete(Request $request) |
59
|
|
|
{ |
60
|
|
|
return false; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths