Compare commits

...

12 Commits

29 changed files with 357 additions and 266 deletions

View File

@ -1,4 +1,4 @@
<button type="cancel" id="cancel" style="margin-top: 2.0rem !important;" {{ $attributes->class(['btn','btn-sm','btn-danger']) }}>Cancel</button>
<button type="cancel" id="cancel" {{ $attributes->class(['mt-4','btn','btn-sm','btn-danger']) }}>Cancel</button>
@section('page-scripts')
<script type="text/javascript">

View File

@ -1 +1 @@
<button type="reset" id="reset" style="margin-top: 2.0rem !important;" {{ $attributes->class(['btn','btn-sm','btn-secondary']) }}>Reset</button>
<button type="reset" id="reset" {{ $attributes->class(['mt-4','btn','btn-sm','btn-secondary']) }}>Reset</button>

View File

@ -1 +1 @@
<button type="submit" id="submit" style="margin-top: 2.0rem !important;" {{ $attributes->class(['btn','btn-sm','btn-success']) }}>{{ $slot }}</button>
<button type="submit" id="submit" {{ $attributes->class(['mt-4','btn','btn-sm','btn-success']) }} @disabled(isset($disabled))>{{ $slot }}</button>

View File

@ -1,4 +1,3 @@
<!-- Errors -->
@if ($errors->any())
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

View File

@ -1,16 +1,16 @@
@if(isset($label))
<label {{ $attributes->only(['class']) }} for="{{ $id ?? $name }}">{{ $label }}</label>
@endisset
<div class="form-group">
@if(isset($label))
<label {{ $attributes->only(['class']) }} for="{{ $id ?? $name }}">{{ $label }}</label>
@endisset
<div class="input-group has-validation">
@if(isset($icon) || isset($prepend))
<div class="input-group-prepend">
<span class="input-group-text">@isset($icon)<i class="fas fa-fw {{ $icon }}"></i>@endisset @isset($prepend){!! $prepend !!}@endisset</span>
</div>
@endif()
@endif
{{ $slot }}
<span class="invalid-feedback" role="alert">
@error($old ?? $name)
<span class="invalid-feedback">
@error((! empty($old)) ? $old : $name)
{{ $message }}
@elseif(isset($feedback))
{{ $feedback }}
@ -20,4 +20,4 @@
@isset($helper)
<span class="input-helper">{{ $helper }}</span>
@endif
</div>
</div>

View File

@ -1,5 +1,5 @@
<x-leenooks::form.base {{ $attributes }}>
<div class="form-check text-right">
<input type="checkbox" class="form-check-input {{ $class ?? ''}}@error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @checked(isset($checked)) @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
<input type="checkbox" class="form-check-input {{ $class ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @checked(old($old ?? $name)) @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</div>
</x-leenooks::form.base>

View File

@ -1,3 +1,3 @@
<x-leenooks::form.base {{ $attributes }}>
<input type="date" class="form-control {{ $classes ?? ''}}@error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
<input type="date" class="form-control {{ $class ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</x-leenooks::form.base>

View File

@ -1,3 +1,3 @@
<x-leenooks::form.base {{ $attributes }}>
<input type="email" class="form-control {{ $classes ?? ''}}@error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
<input type="email" class="form-control {{ $class ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</x-leenooks::form.base>

View File

@ -1,5 +1,5 @@
<x-leenooks::form.base {{ $attributes }}>
<input type="file" class="form-control {{ $classes ?? ''}}@error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
<input type="file" class="form-control {{ $class ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</x-leenooks::form.base>
{{ $slot }}

View File

@ -0,0 +1,3 @@
<x-leenooks::form.base {{ $attributes }}>
<input type="number" class="form-control {{ $class ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</x-leenooks::form.base>

View File

@ -1,3 +1,3 @@
<x-leenooks::form.base {{ $attributes }}>
<input type="password" class="form-control {{ $classes ?? ''}}@error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
<input type="password" class="form-control {{ $class ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</x-leenooks::form.base>

View File

@ -1,32 +1,37 @@
<x-leenooks::form.base {{ $attributes }}>
<input type="hidden" id="{{ $name }}_disabled" name="{{ $name }}" value="" disabled>
<select class="form-control @error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @required(isset($required)) @disabled(isset($disabled))>
@if(isset($addvalues) && $addvalues)
<option id="new"></option>
<select class="form-control @error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @required(isset($required)) @disabled(isset($disabled))>
@if(empty($value) || isset($addnew) || isset($choose))
<option value=""></option>
@isset($addnew)
<option value="new">{{ $addnew ?: 'Add New' }}</option>
@endisset
@endif
@empty($groupby)
@foreach($options as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
@else
@foreach($options->groupBy($groupby) as $group)
<optgroup label="{{ $groupby == 'active' ? (Arr::get($group->first(),$groupby) ? 'Active' : 'Not Active') : Arr::get($group->first(),$groupby) }}">
@foreach($group as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
</optgroup>
@endforeach
@endempty
@isset($options)
@empty($groupby)
@foreach($options as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
@else
@foreach($options->groupBy($groupby) as $group)
<optgroup label="{{ $groupby == 'active' ? (Arr::get($group->first(),$groupby) ? 'Active' : 'Not Active') : Arr::get($group->first(),$groupby) }}">
@foreach($group as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
</optgroup>
@endforeach
@endempty
@endisset
</select>
</x-leenooks::form.base>
@section('page-scripts')
@css(select2)
@js(select2,autofocus)
@pa(select2)
@section('page-scripts')
<script type="text/javascript">
// Select doesnt support read only so we'll use disable and a new field
function {{$id ?? $name}}_readonly(on) {

View File

@ -1,3 +1,3 @@
<x-leenooks::form.base {{ $attributes }}>
<input type="text" class="form-control {{ $class ?? ''}}@error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
<input type="text" class="form-control {{ $class ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" placeholder="{{ $placeholder ?? '' }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</x-leenooks::form.base>

View File

@ -1,3 +1,43 @@
<x-leenooks::form.base {{ $attributes }}>
<textarea class="form-control {{ $classes ?? ''}} @error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @isset($placeholder)placeholder="{{ $placeholder }}"@endisset @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>{{ old($old ?? $name,$value ?? '') }}</textarea>
</x-leenooks::form.base>
<div class="form-group">
@if(isset($label))
<label {{ $attributes->only(['class']) }} for="{{ $id ?? $name }}">{{ $label }}</label>
@endisset
<div class="input-group has-validation">
@if(isset($icon) || isset($prepend))
<div class="input-group-prepend">
<span class="input-group-text">@isset($icon)<i class="fas fa-fw {{ $icon }}"></i>@endisset @isset($prepend){!! $prepend !!}@endisset</span>
</div>
@endif
<div class="w-100">
<textarea class="form-control {{ $class ?? ''}} @error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @isset($placeholder)placeholder="{{ $placeholder }}"@endisset @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>{{ old($old ?? $name,$value ?? '') }}</textarea>
<span class="invalid-feedback">
@error($old ?? $name)
{{ $message }}
@elseif(isset($feedback))
{{ $feedback }}
@enderror
</span>
</div>
</div>
@isset($helper)
<span class="input-helper">{{ $helper }}</span>
@endif
</div>
@pa(simplemde)
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
new SimpleMDE({
element: $('#{{ $id ?? $name }}')[0],
forceSync: true
});
@error($old ?? $name)
$('div.CodeMirror-wrap').addClass('form-control is-invalid');
@enderror
});
</script>
@append

View File

@ -0,0 +1,3 @@
<x-leenooks::form.base {{ $attributes }}>
<input type="time" class="form-control {{ $class ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" value="{{ old($old ?? $name,$value ?? '') }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</x-leenooks::form.base>

View File

@ -1,12 +1,12 @@
<div class="form-group">
<div class="input-group has-validation">
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
<input type="checkbox" class="custom-control-input @error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @checked(old($old ?? $name,$value ?? '')) @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
<input type="checkbox" class="custom-control-input @error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @checked(old($old ?? $name,$value ?? '')) @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
@if(isset($label))
<label class="custom-control-label" for="{{ $id ?? $name }}">{{ $label }}</label>
@endif
</div>
<span class="invalid-feedback" role="alert">
<span class="invalid-feedback">
@error($name)
{{ $message }}
@elseif(isset($feedback))

View File

@ -120,7 +120,7 @@
<script type="text/javascript">
$(document).ready(function() {
$('#passkey').on('click',function() {
passkey_check('{{ csrf_token() }}','/passkey/loggedin');
passkey_check('{{ csrf_token() }}','{{ redirect()->intended("/passkey/loggedin")->getTargetUrl() }}');
return false;
});
});

View File

@ -38,8 +38,6 @@
@section('scripts')
@include('adminlte::layouts.partials.scripts')
@yield('page-scripts')
@show
</body>
</html>

View File

@ -41,6 +41,9 @@
<![endif]-->
--}}
<!-- Page Styles -->
{!! PageAssets::css() !!}
@yield('page-styles')
@if(file_exists('css/fixes.css'))

View File

@ -101,6 +101,11 @@
});
</script>
<!-- Page Scripts -->
{!! PageAssets::js() !!}
@yield('page-scripts')
@if(file_exists('js/custom.js'))
<!-- Any Custom JS -->
<script src="{{ asset('js/custom.js') }}"></script>

View File

@ -26,7 +26,7 @@
<!-- Sidebar Menu -->
<nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" data-accordion="false">
<!-- Add icons to the links using the .nav-icon class with font-awesome or any other icon font library -->
@include('adminlte::layouts.partials.sidebarmenu')
</ul>

View File

@ -1,3 +0,0 @@
@include('adminlte::widget.success')
@include('adminlte::widget.errors')

View File

@ -1,10 +0,0 @@
<!-- Success -->
@if(session()->has('success'))
<div class="alert alert-success alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-check"></i> Success!</h5>
<ul>
<li>{{ session()->get('success') }}</li>
</ul>
</div>
@endif

View File

@ -13,9 +13,9 @@ class LeenooksCarbon implements CastsAttributes
*
* @param array<string, mixed> $attributes
*/
public function get(Model $model, string $key, mixed $value, array $attributes): Carbon
public function get(Model $model, string $key, mixed $value, array $attributes): ?Carbon
{
return Carbon::create($value);
return $value ? Carbon::create($value) : NULL;
}
/**
@ -23,8 +23,8 @@ class LeenooksCarbon implements CastsAttributes
*
* @param array<string, mixed> $attributes
*/
public function set(Model $model, string $key, mixed $value, array $attributes): string
public function set(Model $model, string $key, mixed $value, array $attributes): string|null
{
return ($value instanceof Carbon ? $value : $this->get($model,$key,$value,$attributes))->format('Y-m-d H:i:s');
return ($value instanceof Carbon ? $value : $this->get($model,$key,$value,$attributes))?->format('Y-m-d H:i:s');
}
}

View File

@ -1,66 +0,0 @@
<?php
namespace Leenooks\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\Scheduling\Schedule;
class ScheduleList extends Command
{
protected $signature = 'schedule:list';
protected $description = 'List when scheduled commands are executed.';
/**
* @var Schedule
*/
protected $schedule;
/**
* ScheduleList constructor.
*
* @param Schedule $schedule
*/
public function __construct(Schedule $schedule)
{
parent::__construct();
$this->schedule = $schedule;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$events = array_map(function ($event) {
return [
'cron' => $event->expression,
'command' => static::fixupCommand($event->command),
];
}, $this->schedule->events());
$this->table(
['Cron', 'Command'],
$events
);
}
/**
* If it's an artisan command, strip off the PHP
*
* @param $command
* @return string
*/
protected static function fixupCommand($command)
{
$parts = explode(' ', $command);
if (count($parts) > 2 && $parts[1] === "'artisan'") {
array_shift($parts);
}
return implode(' ', $parts);
}
}

213
src/PageAssets.php Normal file
View File

@ -0,0 +1,213 @@
<?php
namespace Leenooks;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
/**
* Useful tools (js/css) used when rendering pages
*/
class PageAssets
{
// Types that we can handle
private const array types = [
'css',
'js',
];
public const array assets = [
'datatables' => [
'base' => [
'css' => [
'//cdn.datatables.net/2.1.2/css/dataTables.bootstrap4.css',
//'//cdn.datatables.net/2.1.2/css/dataTables.dataTables.min.css',
],
'js' => [
'//cdn.datatables.net/2.1.2/js/dataTables.min.js',
'//cdn.datatables.net/2.1.2/js/dataTables.bootstrap4.min.js',
],
],
'buttons' => [
'css' => [
'//cdn.datatables.net/buttons/3.1.0/css/buttons.bootstrap4.min.css',
//'//cdn.datatables.net/buttons/3.1.0/css/buttons.dataTables.min.css',
],
'js' => [
'//cdn.datatables.net/buttons/3.1.0/js/dataTables.buttons.min.js',
//'//cdn.datatables.net/buttons/3.1.0/js/buttons.dataTables.min.js',
'//cdn.datatables.net/buttons/3.1.0/js/buttons.bootstrap4.min.js',
'//cdnjs.cloudflare.com/ajax/libs/jszip/3.2.0/jszip.min.js',
],
],
'conditionalpaging' => [
'js' => [
'//cdn.datatables.net/plug-ins/2.0.5/features/conditionalPaging/dataTables.conditionalPaging.min.js',
],
],
'fixedheader' => [
'css' => [
'//cdn.datatables.net/fixedheader/4.0.1/css/fixedHeader.bootstrap4.min.css',
//'//cdn.datatables.net/fixedheader/4.0.1/css/fixedHeader.dataTables.min.css',
],
'js' => [
'//cdn.datatables.net/fixedheader/4.0.1/js/dataTables.fixedHeader.min.js',
//'//cdn.datatables.net/fixedheader/4.0.1/js/fixedHeader.dataTables.min.js',
'//cdn.datatables.net/fixedheader/4.0.1/js/fixedHeader.bootstrap4.min.js',
]
],
'responsive' => [
'css' => [
'//cdn.datatables.net/responsive/3.0.2/css/responsive.bootstrap4.min.css',
//'//cdn.datatables.net/responsive/3.0.2/css/responsive.dataTables.min.css',
],
'js' => [
'//cdn.datatables.net/responsive/3.0.2/js/dataTables.responsive.min.js',
//'//cdn.datatables.net/responsive/3.0.2/js/responsive.bootstrap.min.js',
'//cdn.datatables.net/responsive/3.0.2/js/responsive.bootstrap4.min.js',
]
],
'rowgroup' => [
'css' => [
'//cdn.datatables.net/rowgroup/1.5.0/css/rowGroup.bootstrap4.min.css',
//'//cdn.datatables.net/rowgroup/1.5.0/css/rowGroup.dataTables.min.css',
],
'js' => [
'//cdn.datatables.net/rowgroup/1.5.0/js/dataTables.rowGroup.min.js',
//'//cdn.datatables.net/rowgroup/1.5.0/js/rowGroup.dataTables.min.js',
'//cdn.datatables.net/rowgroup/1.5.0/js/rowGroup.bootstrap4.min.js',
],
],
'searchpanes' => [
'css' => [
'//cdn.datatables.net/searchpanes/2.3.1/css/searchPanes.bootstrap4.min.css',
//'//cdn.datatables.net/searchpanes/2.3.1/css/searchPanes.dataTables.min.css',
],
'js' => [
'//cdn.datatables.net/searchpanes/2.3.1/js/dataTables.searchPanes.min.js',
//'//cdn.datatables.net/searchpanes/2.3.1/js/searchPanes.dataTables.min.js',
'//cdn.datatables.net/searchpanes/2.3.1/js/searchPanes.bootstrap4.min.js',
],
],
'searchpanes-left' => [
'css' => [
'/plugin/dataTables/leftSearchPanes.css',
],
],
'select' => [
'css' => [
'//cdn.datatables.net/select/2.0.3/css/select.bootstrap4.min.css',
//'//cdn.datatables.net/select/2.0.3/css/select.dataTables.min.css',
],
'js' => [
'//cdn.datatables.net/select/2.0.3/js/dataTables.select.min.js',
//'//cdn.datatables.net/select/2.0.3/js/select.dataTables.min.js',
'//cdn.datatables.net/select/2.0.3/js/select.bootstrap4.min.js',
]
],
],
'select2' => [
'base' => [
'css' => [
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css',
],
'js' => [
'//cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js',
],
],
'autofocus' => [
'js' => [
'/plugin/select2/fix-autofocus.js',
],
]
],
'simplemde' => [
'base' => [
'css' => [
'//cdn.jsdelivr.net/simplemde/latest/simplemde.min.css',
],
'js' => [
'//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js',
],
],
],
];
// Items to manage
public static Collection $items;
// Add an item to the list
public static function add(string $type,Collection|array|string $asset): void
{
if (! in_array($type,self::types))
throw new \Exception('Invalid type: '.$type);
if (! isset(self::$items))
self::init();
if (is_string($asset))
self::$items
->get($type)
->push($asset)
->unique();
else
self::$items->put($type,
self::$items
->get($type)
->merge($asset->values())
->unique());
}
// Add a predefined asset
public static function asset(string $id): void
{
if (! isset(self::$items))
self::init();
if (str_contains($id,',')) {
[$item,$arguments] = explode(',',$id,2);
$arguments = collect(explode('|',$arguments));
} else {
$item = $id;
$arguments = collect();
}
$arguments = $arguments->prepend('base');
$asset = collect(Arr::get(self::assets,$item))->only($arguments);
foreach (self::types as $type)
if ($x=$asset->pluck($type)->filter()->flatten())
self::add($type,$x);
}
// Render the CSS items
public static function css(): string
{
return isset(self::$items)
? self::$items
->get('css')
->map(fn($item)=>sprintf('<link rel="stylesheet" href="%s">',$item))
->join('')
: '';
}
public static function init(): void
{
self::$items = collect([
'js' => collect(),
'css' => collect(),
]);
}
// Render the JS items
public static function js(): string
{
return isset(self::$items)
? self::$items
->get('js')
->map(fn($item)=>sprintf('<script type="text/javascript" src="%s"></script>',$item))
->join('')
: '';
}
}

View File

@ -15,11 +15,11 @@ class CustomBladeServiceProvider extends ServiceProvider
*/
public function boot()
{
Blade::directive('css',function(string $expression,array $args=[]) {
Blade::directive('css',function(string $expression) {
return $this->resolve('css',$expression);
});
Blade::directive('js',function($expression,string $options=NULL) {
Blade::directive('js',function($expression) {
return $this->resolve('js',$expression);
});
}
@ -41,97 +41,9 @@ class CustomBladeServiceProvider extends ServiceProvider
switch ($type) {
case 'datatables':
switch ($content) {
case 'css':
// Base
$css->put($type,'https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css');
foreach ($arguments as $option) {
$key = $type.':'.$option;
switch ($option) {
case 'bootstrap4':
$css->put($key,'/plugin/dataTables/dataTables.bootstrap4.css');
break;
case 'buttons':
$css->put($key,'https://cdn.datatables.net/buttons/1.6.5/css/buttons.dataTables.min.css');
break;
case 'fixedheader':
$css->put($key,'https://cdn.datatables.net/fixedheader/3.1.7/css/fixedHeader.dataTables.min.css');
break;
case 'rowgroup':
$css->put($key,'https://cdn.datatables.net/rowgroup/1.1.2/css/rowGroup.dataTables.min.css');
break;
case 'responsive':
$css->put($key,'http://cdn.datatables.net/responsive/2.2.6/css/responsive.dataTables.min.css');
break;
case 'searchpanes':
$css->put($key,'https://cdn.datatables.net/searchpanes/1.2.1/css/searchPanes.dataTables.min.css');
break;
case 'searchpanes-left':
$css->put('searchpanes:searchpanes-left','/plugin/dataTables/leftSearchPanes.css');
break;
case 'select':
$css->put($key,'https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css');
break;
default:
throw new \Exception(sprintf('Unknown [%s] option: [%s:%s]',$type,$content,$option));
}
}
break;
case 'js':
// Base
$js->put($type,'https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js');
foreach ($arguments as $option) {
$key = $type.':'.$option;
switch ($option) {
case 'bootstrap4':
$js->put($key,'/plugin/dataTables/dataTables.bootstrap4.js');
break;
case 'buttons':
$js->put($key,'https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js');
$js->put($key.'html5','https://cdn.datatables.net/buttons/1.6.5/js/buttons.html5.min.js');
$js->put($key.'jszip','https://cdnjs.cloudflare.com/ajax/libs/jszip/3.2.0/jszip.min.js');
break;
case 'fixedheader':
$js->put($key,'https://cdn.datatables.net/fixedheader/3.1.7/js/dataTables.fixedHeader.min.js');
break;
case 'responsive':
$js->put($key,'https://cdn.datatables.net/responsive/2.2.6/js/dataTables.responsive.min.js');
break;
case 'rowgroup':
$js->put($key,'https://cdn.datatables.net/rowgroup/1.1.2/js/dataTables.rowGroup.min.js');
break;
case 'searchpanes':
$js->put($key,'https://cdn.datatables.net/searchpanes/1.2.1/js/dataTables.searchPanes.min.js');
break;
case 'select':
$js->put($key,'https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js');
break;
default:
throw new \Exception(sprintf('Unknown [%s] option: [%s:%s]',$type,$content,$option));
}
}
}
case 'select2':
case 'simplemde':
Log::alert(sprintf('Blade @css/@js for %s deprecicated, use @pa',$type));
break;
case 'datepick':
@ -236,48 +148,6 @@ class CustomBladeServiceProvider extends ServiceProvider
break;
case 'select2':
switch ($content) {
case 'css':
// Base
$css->put($type,'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css');
break;
case 'js':
// Base
$js->put($type,'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js');
foreach ($arguments as $option) {
$key = $type.':'.$option;
switch ($option) {
case 'autofocus':
$js->put($key,'/plugin/select2/fix-autofocus.js');
break;
default:
throw new \Exception(sprintf('Unknown [%s] option: [%s:%s]',$type,$content,$option));
}
}
}
break;
case 'simplemde':
switch ($content) {
case 'css':
// Base
$css->put($type,'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css');
break;
case 'js':
// Base
$js->put($type,'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js');
}
break;
case 'summernote':
switch ($content) {
case 'css':

View File

@ -2,11 +2,14 @@
namespace Leenooks\Providers;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Blade;
use Leenooks\Http\Middleware\GuestUser;
use Illuminate\Routing\Router;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
use Leenooks\Http\Middleware\GuestUser;
use Leenooks\PageAssets;
use Leenooks\Traits\SingleOrFail;
/**
* Class GuestUserServiceProvider.
@ -15,6 +18,8 @@ use Illuminate\Support\ServiceProvider;
*/
class LeenooksServiceProvider extends ServiceProvider
{
use SingleOrFail;
private string $_path = '';
/**
@ -24,6 +29,12 @@ class LeenooksServiceProvider extends ServiceProvider
*/
public function boot(Router $router)
{
self::bootSingleOrfail();
// Custom Aliases
$loader = AliasLoader::getInstance();
$loader->alias('PageAssets',PageAssets::class);
$router->pushMiddlewareToGroup('web',GuestUser::class);
$this->loadViewsFrom($this->_path.'/resources/themes/adminlte/views/', 'adminlte');
@ -36,6 +47,11 @@ class LeenooksServiceProvider extends ServiceProvider
//Blade::componentNamespace('Leenooks\\Components','leenooks');
Blade::anonymousComponentPath($this->_path.'/resources/components', 'leenooks');
// Add our page assets
Blade::directive('pa',function($expression) {
return sprintf('<?php PageAssets::asset(\'%s\') ?>',$expression);
});
// Enable a Collect::recursive() function
Collection::macro('recursive', function () {
return $this->map(function ($value) {

View File

@ -0,0 +1,15 @@
<?php
/**
* Fix for when there is a call to pluck() for values resolved via __get()
*/
namespace Leenooks\Traits;
trait ObjectIssetFix
{
// Fix for a call to pluck('something') (which is resolved via __get()), but it returns false.
public function __isset($key)
{
return (bool)$this->{$key};
}
}