diglabby /
doika
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Diglabby\Doika\Providers; |
||
| 4 | |||
| 5 | use Collective\Html\FormFacade; |
||
| 6 | use Collective\Html\HtmlFacade; |
||
| 7 | use Illuminate\Support\Facades\View; |
||
| 8 | use Illuminate\Support\ServiceProvider; |
||
| 9 | |||
| 10 | class ViewServiceProvider extends ServiceProvider |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Bootstrap the application services. |
||
| 14 | */ |
||
| 15 | public function boot() |
||
| 16 | { |
||
| 17 | FormFacade::component('bsText', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'text']); |
||
| 18 | FormFacade::component('bsEmail', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'email']); |
||
| 19 | FormFacade::component('bsTel', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'tel']); |
||
| 20 | FormFacade::component('bsNumber', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'number']); |
||
| 21 | FormFacade::component('bsDatetime', 'components.form.input', ['name', 'value' => null, 'attributes' => [], 'type' => 'datetime']); |
||
| 22 | FormFacade::component('bsPassword', 'components.form.input', ['name', 'attributes' => [], 'value' => '', 'type' => 'password']); |
||
| 23 | FormFacade::component('bsFile', 'components.form.input', ['name', 'attributes' => [], 'value' => null, 'type' => 'file']); |
||
| 24 | FormFacade::component('bsTextarea', 'components.form.textarea', ['name', 'value' => null, 'attributes' => []]); |
||
| 25 | FormFacade::component('bsSelect', 'components.form.select', ['name', 'list' => [], 'selected' => null, 'attributes' => []]); |
||
| 26 | FormFacade::component('bsCheckbox', 'components.form.custom-control', ['name', 'description', 'value' => null, 'type' => 'checkbox']); |
||
| 27 | HtmlFacade::macro('asset', function ($manifestName, $path) { |
||
| 28 | static $manifest; |
||
| 29 | $basePath = app()->environment('production') ? 'dist' : 'build'; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 30 | if (! $manifest |
||
| 31 | && file_exists($manifestPath = public_path("{$basePath}/manifest-{$manifestName}.json")) |
||
| 32 | ) { |
||
| 33 | $manifest = json_decode(file_get_contents($manifestPath), true); |
||
| 34 | } |
||
| 35 | if ($manifest && isset($manifest[$path])) { |
||
| 36 | return $manifest[$path]; |
||
| 37 | } |
||
| 38 | }); |
||
| 39 | /* |
||
| 40 | * Prepare flash message for alerts |
||
| 41 | */ |
||
| 42 | View::composer('partials/messages', function (\Illuminate\View\View $view) { |
||
| 43 | $data = collect($view->getData()); |
||
| 44 | if ($flash = session()->get('flash_message') ?: $data->get('flashMessage')) { |
||
| 45 | $view->with('flashMessage', $flash); |
||
| 46 | $view->with('flashType', 'info'); |
||
| 47 | } elseif ($flash = session()->get('flash_success') ?: $data->get('flashSuccess')) { |
||
| 48 | $view->with('flashMessage', $flash); |
||
| 49 | $view->with('flashType', 'success'); |
||
| 50 | } elseif ($flash = session()->get('flash_info') ?: $data->get('flashInfo')) { |
||
| 51 | $view->with('flashMessage', $flash); |
||
| 52 | $view->with('flashType', 'info'); |
||
| 53 | } elseif ($flash = session()->get('flash_warning') ?: $data->get('flashWarning')) { |
||
| 54 | $view->with('flashMessage', $flash); |
||
| 55 | $view->with('flashType', 'warning'); |
||
| 56 | } elseif ($flash = session()->get('flash_danger') ?: $data->get('flashDanger')) { |
||
| 57 | $view->with('flashMessage', $flash); |
||
| 58 | $view->with('flashType', 'danger'); |
||
| 59 | } elseif ($flash = session()->get('flash_error') ?: $data->get('flashError')) { |
||
| 60 | $view->with('flashMessage', $flash); |
||
| 61 | $view->with('flashType', 'danger'); |
||
| 62 | } |
||
| 63 | }); |
||
| 64 | View::composer('*', function (\Illuminate\View\View $view) { |
||
| 65 | $view->with('loggedInUser', auth()->user()); |
||
| 66 | }); |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Register the application services. |
||
| 71 | */ |
||
| 72 | public function register() |
||
| 73 | { |
||
| 74 | } |
||
| 75 | } |
||
| 76 |