kiroushi /
laravel-db-blade
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Kiroushi\DbBlade; |
||||||
| 4 | |||||||
| 5 | use Illuminate\View\Factory as ViewFactory; |
||||||
| 6 | use Illuminate\Contracts\Events\Dispatcher as Dispatcher; |
||||||
| 7 | |||||||
| 8 | class Factory extends ViewFactory |
||||||
| 9 | { |
||||||
| 10 | protected $contentField = null; |
||||||
| 11 | |||||||
| 12 | /** |
||||||
| 13 | * Create a new dbview factory instance. |
||||||
| 14 | * |
||||||
| 15 | * @param \Kiroushi\DbBlade\DbViewFinder $finder |
||||||
| 16 | * @param \Illuminate\Contracts\Events\Dispatcher $events |
||||||
| 17 | */ |
||||||
| 18 | public function __construct(DbViewFinder $finder, Dispatcher $events) |
||||||
| 19 | { |
||||||
| 20 | $this->finder = $finder; |
||||||
| 21 | $this->events = $events; |
||||||
| 22 | |||||||
| 23 | $this->share('__env', $this); |
||||||
| 24 | } |
||||||
| 25 | |||||||
| 26 | /** |
||||||
| 27 | * Set the DB View model and its name field at run time. |
||||||
| 28 | * |
||||||
| 29 | * @param string $modelName |
||||||
| 30 | * @param string|null $nameField |
||||||
| 31 | * @return $this |
||||||
| 32 | */ |
||||||
| 33 | public function model(string $modelName, string $nameField = null) |
||||||
| 34 | { |
||||||
| 35 | $this->finder->model($modelName, $nameField); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 36 | |||||||
| 37 | return $this; |
||||||
| 38 | } |
||||||
| 39 | |||||||
| 40 | /** |
||||||
| 41 | * Set the model name field at run time. |
||||||
| 42 | * |
||||||
| 43 | * @param string $nameField |
||||||
| 44 | * @return $this |
||||||
| 45 | */ |
||||||
| 46 | public function field(string $nameField) |
||||||
| 47 | { |
||||||
| 48 | $this->finder->field($nameField); |
||||||
|
0 ignored issues
–
show
The method
field() does not exist on Illuminate\View\ViewFinderInterface. It seems like you code against a sub-type of Illuminate\View\ViewFinderInterface such as Kiroushi\DbBlade\DbViewFinder.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 49 | |||||||
| 50 | return $this; |
||||||
| 51 | } |
||||||
| 52 | |||||||
| 53 | /** |
||||||
| 54 | * Set the content field at run time. |
||||||
| 55 | * |
||||||
| 56 | * @param string $contentField |
||||||
| 57 | * @return $this |
||||||
| 58 | */ |
||||||
| 59 | public function contentField(string $contentField) |
||||||
| 60 | { |
||||||
| 61 | $this->contentField = $contentField; |
||||||
| 62 | |||||||
| 63 | return $this; |
||||||
| 64 | } |
||||||
| 65 | |||||||
| 66 | /** |
||||||
| 67 | * Create a new view instance from the given arguments. |
||||||
| 68 | * |
||||||
| 69 | * @param string $view |
||||||
| 70 | * @param Model $model |
||||||
| 71 | * @param \Illuminate\Contracts\Support\Arrayable|array $data |
||||||
| 72 | * @return \Kiroushi\DbBlade\DbView |
||||||
| 73 | */ |
||||||
| 74 | protected function viewInstance($view, $model, $data) |
||||||
| 75 | { |
||||||
| 76 | return new DbView($this, $view, $model, $data, $this->contentField); |
||||||
| 77 | } |
||||||
| 78 | } |
||||||
| 79 |