Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
4a4cf3c5bf | |||
f393813311 | |||
3a12ec005e | |||
83bdea458f | |||
f32c29fa8c | |||
b9a3cd5647 | |||
12496101e1 | |||
01e77cb807 |
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "laravel/leenooks",
|
"name": "leenooks/laravel",
|
||||||
"description": "Leenooks standard templates and tools.",
|
"description": "Leenooks standard templates and tools.",
|
||||||
"keywords": ["laravel","leenooks"],
|
"keywords": ["laravel","leenooks"],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
11
resources/components/button/cancel.blade.php
Normal file
11
resources/components/button/cancel.blade.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<button type="cancel" id="cancel" style="margin-top: 2.0rem !important;" {{ $attributes->class(['btn','btn-sm','btn-danger']) }}>Cancel</button>
|
||||||
|
|
||||||
|
@section('page-scripts')
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#cancel').on('click',function(item) {
|
||||||
|
return history.back();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@append
|
9
resources/components/button/error.blade.php
Normal file
9
resources/components/button/error.blade.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
@if(isset($row) && $row)
|
||||||
|
<div class="row pt-2 pb-2">
|
||||||
|
<div class="col">
|
||||||
|
@endif
|
||||||
|
@error($name)<button {{ $attributes->class(['btn','btn-sm','btn-danger']) }}>{{ $message }}</button>@enderror
|
||||||
|
@if(isset($row) && $row)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
1
resources/components/button/reset.blade.php
Normal file
1
resources/components/button/reset.blade.php
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<button type="reset" id="reset" style="margin-top: 2.0rem !important;" {{ $attributes->class(['btn','btn-sm','btn-secondary']) }}>Reset</button>
|
1
resources/components/button/submit.blade.php
Normal file
1
resources/components/button/submit.blade.php
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<button type="submit" id="submit" style="margin-top: 2.0rem !important;" {{ $attributes->class(['btn','btn-sm','btn-success']) }}>{{ $slot }}</button>
|
9
resources/components/button/success.blade.php
Normal file
9
resources/components/button/success.blade.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
@if(isset($row) && $row)
|
||||||
|
<div class="row pt-2 pb-2">
|
||||||
|
<div class="col">
|
||||||
|
@endif
|
||||||
|
@session('success')<button {{ $attributes->class(['btn','btn-sm','btn-success']) }}>{{ $value }}</button>@endsession
|
||||||
|
@if(isset($row) && $row)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
23
resources/components/form/base.blade.php
Normal file
23
resources/components/form/base.blade.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
@if(isset($label))
|
||||||
|
<label {{ $attributes->only(['class']) }} for="{{ $id ?? $name }}">{{ $label }}</label>
|
||||||
|
@endisset
|
||||||
|
<div class="form-group">
|
||||||
|
<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()
|
||||||
|
{{ $slot }}
|
||||||
|
<span class="invalid-feedback" role="alert">
|
||||||
|
@error($old ?? $name)
|
||||||
|
{{ $message }}
|
||||||
|
@elseif(isset($feedback))
|
||||||
|
{{ $feedback }}
|
||||||
|
@enderror
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
@isset($helper)
|
||||||
|
<span class="input-helper">{{ $helper }}</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
5
resources/components/form/checkbox.blade.php
Normal file
5
resources/components/form/checkbox.blade.php
Normal file
@@ -0,0 +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))>
|
||||||
|
</div>
|
||||||
|
</x-leenooks::form.base>
|
3
resources/components/form/date.blade.php
Normal file
3
resources/components/form/date.blade.php
Normal file
@@ -0,0 +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))>
|
||||||
|
</x-leenooks::form.base>
|
3
resources/components/form/email.blade.php
Normal file
3
resources/components/form/email.blade.php
Normal file
@@ -0,0 +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))>
|
||||||
|
</x-leenooks::form.base>
|
17
resources/components/form/file.blade.php
Normal file
17
resources/components/form/file.blade.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<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))>
|
||||||
|
</x-leenooks::form.base>
|
||||||
|
{{ $slot }}
|
||||||
|
|
||||||
|
@section('page-scripts')
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#{{ $id ?? $name }}').on('change',function(){
|
||||||
|
//get the file name
|
||||||
|
var fileName = $(this).val();
|
||||||
|
//replace the "Choose a file" label
|
||||||
|
$(this).parent().next('.input-helper').html(fileName);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@append
|
3
resources/components/form/password.blade.php
Normal file
3
resources/components/form/password.blade.php
Normal file
@@ -0,0 +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))>
|
||||||
|
</x-leenooks::form.base>
|
55
resources/components/form/select.blade.php
Normal file
55
resources/components/form/select.blade.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<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>
|
||||||
|
@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
|
||||||
|
</select>
|
||||||
|
</x-leenooks::form.base>
|
||||||
|
|
||||||
|
@section('page-scripts')
|
||||||
|
@css(select2)
|
||||||
|
@js(select2,autofocus)
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
// Select doesnt support read only so we'll use disable and a new field
|
||||||
|
function {{$id ?? $name}}_readonly(on) {
|
||||||
|
if (on) {
|
||||||
|
$('#{{ $name }}').prop('disabled',true);
|
||||||
|
$('#{{ $name }}_disabled').prop('disabled',false).val($('#{{ $name }}').val());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$('#{{ $name }}').prop('disabled',false);
|
||||||
|
$('#{{ $name }}_disabled').prop('disabled',true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#{{ $id ?? $name }}').select2({
|
||||||
|
dropdownAutoWidth: true,
|
||||||
|
width: 'style',
|
||||||
|
@isset($addvalues)
|
||||||
|
tags: true,
|
||||||
|
placeholder: '',
|
||||||
|
allowClear: true,
|
||||||
|
@endisset
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@append
|
3
resources/components/form/text.blade.php
Normal file
3
resources/components/form/text.blade.php
Normal file
@@ -0,0 +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))>
|
||||||
|
</x-leenooks::form.base>
|
3
resources/components/form/textarea.blade.php
Normal file
3
resources/components/form/textarea.blade.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<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>
|
17
resources/components/form/toggle.blade.php
Normal file
17
resources/components/form/toggle.blade.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<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))>
|
||||||
|
@if(isset($label))
|
||||||
|
<label class="custom-control-label" for="{{ $id ?? $name }}">{{ $label }}</label>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<span class="invalid-feedback" role="alert">
|
||||||
|
@error($name)
|
||||||
|
{{ $message }}
|
||||||
|
@elseif(isset($feedback))
|
||||||
|
{{ $feedback }}
|
||||||
|
@enderror
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
35
resources/components/modal/delete.blade.php
Normal file
35
resources/components/modal/delete.blade.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<div class="modal fade" id="confirm_delete" tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header bg-danger">
|
||||||
|
<h5 class="modal-title">WARNING: DELETING record</h5>
|
||||||
|
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close">X</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>This action is irreversible. Are you sure, your sure, that you want to delete it?</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<a type="button" class="btn btn-danger btn-ok">Delete</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@section('page-scripts')
|
||||||
|
<script type="text/javascript">
|
||||||
|
var confirm_delete = new bootstrap.Modal(document.getElementById('confirm_delete'), {});
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('.{{$trigger}}').click(function(e) {
|
||||||
|
confirm_delete.show();
|
||||||
|
console.log($('#confirm_delete')
|
||||||
|
.find('.btn-ok'));
|
||||||
|
$('#confirm_delete')
|
||||||
|
.find('.btn-ok')
|
||||||
|
.attr('href',e.currentTarget.href);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@append
|
@@ -76,11 +76,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- /.col -->
|
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<button type="submit" name="submit" class="btn btn-primary mr-0 float-right">Sign In</button>
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<button type="submit" name="submit" class="btn btn-sm btn-primary float-right">Sign In</button>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.col -->
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 pt-2">
|
||||||
|
<button type="button" id="passkey" class="btn btn-sm btn-primary float-right"><i class="bi bi-key"></i> Passkey</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@@ -103,3 +112,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- /.login-box -->
|
<!-- /.login-box -->
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@section('page-scripts')
|
||||||
|
<!-- Passkeys -->
|
||||||
|
<script type='text/javascript' src='{{ asset('/passkey/passkey.js') }}'></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#passkey').on('click',function() {
|
||||||
|
passkey_check('{{ csrf_token() }}','/passkey/loggedin');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@append
|
@@ -27,6 +27,8 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@yield('page-scripts')
|
||||||
@show
|
@show
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@@ -1,17 +0,0 @@
|
|||||||
<div class="form-group">
|
|
||||||
<label for="{{ $id }}">{{ $label }}</label>
|
|
||||||
<div class="input-group has-validation">
|
|
||||||
@empty($icon)
|
|
||||||
@else
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa-fw {{ $icon }}"></i></span>
|
|
||||||
</div>
|
|
||||||
@endempty()
|
|
||||||
<input type="date" class="form-control @error($id) is-invalid @enderror" id="{{ $id }}" name="{{ $name ?? $id}}" value="{{ old($old,$value) }}">
|
|
||||||
<span class="invalid-feedback" role="alert">
|
|
||||||
@error($id)
|
|
||||||
{{ $message }}
|
|
||||||
@enderror
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@@ -1,39 +0,0 @@
|
|||||||
<div class="form-group">
|
|
||||||
<label for="{{ $id }}">{{ $label }}</label>
|
|
||||||
<div class="input-group has-validation">
|
|
||||||
@empty($icon)
|
|
||||||
@else
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa-fw {{ $icon }}"></i></span>
|
|
||||||
</div>
|
|
||||||
@endempty()
|
|
||||||
<div class="custom-file">
|
|
||||||
<input type="file" class="custom-file-input @error($id) is-invalid @enderror" id="{{ $id }}" name="{{ $name ?? $id}}">
|
|
||||||
<label class="custom-file-label input-group-text" for="{{ $id }}">Choose file</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{--
|
|
||||||
<div class="input-group-append">
|
|
||||||
<button type="submit" class="input-group-text btn btn-success" id="">Upload</button>
|
|
||||||
</div>
|
|
||||||
--}}
|
|
||||||
<span class="invalid-feedback @error($id) d-block @enderror" role="alert">
|
|
||||||
@error($id)
|
|
||||||
{{ $message }}
|
|
||||||
@enderror
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@section('page-scripts')
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$('#{{ $id }}').on('change',function(){
|
|
||||||
//get the file name
|
|
||||||
var fileName = $(this).val();
|
|
||||||
//replace the "Choose a file" label
|
|
||||||
$(this).next('.custom-file-label').html(fileName);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@append
|
|
@@ -1,57 +0,0 @@
|
|||||||
<div class="form-group">
|
|
||||||
<label for="{{ $id }}">{{ $label }}</label>
|
|
||||||
<div class="input-group has-validation">
|
|
||||||
@empty($icon)
|
|
||||||
@else
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa-fw {{ $icon }}"></i></span>
|
|
||||||
</div>
|
|
||||||
@endempty()
|
|
||||||
|
|
||||||
<select class="form-control @error($id) is-invalid @enderror" id="{{ $id }}" name="{{ $name ?? $id}}">
|
|
||||||
@if(! isset($addvalues) || ! $addvalues)
|
|
||||||
<option id="new"></option>
|
|
||||||
@endif
|
|
||||||
@empty($groupby)
|
|
||||||
@foreach($options as $option)
|
|
||||||
@empty(Arr::get($option,'value')) @continue @endempty
|
|
||||||
<option value="{{ Arr::get($option,'id') }}" @if(Arr::get($option,'id') == old($old,$value))selected @endif>{{ 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)
|
|
||||||
@empty(Arr::get($option,'value')) @continue @endempty
|
|
||||||
<option value="{{ Arr::get($option,'id') }}" @if(Arr::get($option,'id') == old($old,$value))selected @endif>{{ Arr::get($option,'value') }}</option>
|
|
||||||
@endforeach
|
|
||||||
</optgroup>
|
|
||||||
@endforeach
|
|
||||||
@endempty
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<span class="invalid-feedback" role="alert">
|
|
||||||
@error($id)
|
|
||||||
{{ $message }}
|
|
||||||
@enderror
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@section('page-scripts')
|
|
||||||
@css(select2)
|
|
||||||
@js(select2,autofocus)
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function() {
|
|
||||||
$('#{{ $id }}').select2({
|
|
||||||
dropdownAutoWidth: true,
|
|
||||||
width: 'style',
|
|
||||||
@isset($addvalues)
|
|
||||||
tags: true,
|
|
||||||
placeholder: '',
|
|
||||||
allowClear: true,
|
|
||||||
@endisset
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@append
|
|
@@ -1,17 +0,0 @@
|
|||||||
<div class="form-group">
|
|
||||||
<label for="{{ $id }}">{{ $label }}</label>
|
|
||||||
<div class="input-group has-validation">
|
|
||||||
@empty($icon)
|
|
||||||
@else
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa-fw {{ $icon }}"></i></span>
|
|
||||||
</div>
|
|
||||||
@endempty()
|
|
||||||
<input type="text" class="form-control {{ $classes ?? ''}}@error($id) is-invalid @enderror" id="{{ $id }}" name="{{ $name ?: $id }}" value="{{ old($old ?? $name,$value) }}">
|
|
||||||
<span class="invalid-feedback" role="alert">
|
|
||||||
@error($id)
|
|
||||||
{{ $message }}
|
|
||||||
@enderror
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@@ -1,11 +0,0 @@
|
|||||||
<div class="form-group">
|
|
||||||
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
|
|
||||||
<input type="checkbox" class="custom-control-input" id="{{ $id }}" name="{{ $name ?: $id }}" {{ old($old ?? $name,$value) ? 'checked' : '' }}>
|
|
||||||
<label class="custom-control-label" for="{{ $id }}">{{ $label }}</label>
|
|
||||||
</div>
|
|
||||||
<span class="invalid-feedback @error($id) d-block @enderror" role="alert">
|
|
||||||
@error($id)
|
|
||||||
{{ $message }}
|
|
||||||
@enderror
|
|
||||||
</span>
|
|
||||||
</div>
|
|
@@ -1 +0,0 @@
|
|||||||
@if(session()->has('success'))<span class="ml-3 pt-0 pb-0 pr-1 pl-1 btn btn-outline-success float-right"><small>{{ session()->get('success') }}</small></span>@endif
|
|
30
src/Casts/LeenooksCarbon.php
Normal file
30
src/Casts/LeenooksCarbon.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Leenooks\Casts;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Leenooks\Carbon;
|
||||||
|
|
||||||
|
class LeenooksCarbon implements CastsAttributes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Cast the given value.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $attributes
|
||||||
|
*/
|
||||||
|
public function get(Model $model, string $key, mixed $value, array $attributes): Carbon
|
||||||
|
{
|
||||||
|
return Carbon::create($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the given value for storage.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $attributes
|
||||||
|
*/
|
||||||
|
public function set(Model $model, string $key, mixed $value, array $attributes): string
|
||||||
|
{
|
||||||
|
return ($value instanceof Carbon ? $value : $this->get($model,$key,$value,$attributes))->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
}
|
26
src/Http/Middleware/ActiveUser.php
Normal file
26
src/Http/Middleware/ActiveUser.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Leenooks\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ActiveUser
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(Request $request,\Closure $next)
|
||||||
|
{
|
||||||
|
if ((! Auth::user()?->exists) || (! Auth::user()->active)) {
|
||||||
|
Auth::logout();
|
||||||
|
abort(403,'Your account is not active');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace Leenooks\Providers;
|
namespace Leenooks\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
use Leenooks\Http\Middleware\GuestUser;
|
use Leenooks\Http\Middleware\GuestUser;
|
||||||
use Illuminate\Routing\Router;
|
use Illuminate\Routing\Router;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +15,7 @@ use Illuminate\Support\ServiceProvider;
|
|||||||
*/
|
*/
|
||||||
class LeenooksServiceProvider extends ServiceProvider
|
class LeenooksServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
private $_path = '';
|
private string $_path = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap the application services.
|
* Bootstrap the application services.
|
||||||
@@ -31,10 +33,12 @@ class LeenooksServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
$this->loadViewsFrom($this->_path.'/resources/themes/metronic/views/', 'metronic');
|
$this->loadViewsFrom($this->_path.'/resources/themes/metronic/views/', 'metronic');
|
||||||
|
|
||||||
// Enable a Collect::recursive() function
|
//Blade::componentNamespace('Leenooks\\Components','leenooks');
|
||||||
\Illuminate\Support\Collection::macro('recursive', function () {
|
Blade::anonymousComponentPath($this->_path.'/resources/components', 'leenooks');
|
||||||
return $this->map(function ($value) {
|
|
||||||
|
|
||||||
|
// Enable a Collect::recursive() function
|
||||||
|
Collection::macro('recursive', function () {
|
||||||
|
return $this->map(function ($value) {
|
||||||
if (is_array($value) || is_object($value)) {
|
if (is_array($value) || is_object($value)) {
|
||||||
return collect($value)->recursive();
|
return collect($value)->recursive();
|
||||||
}
|
}
|
||||||
|
@@ -25,33 +25,90 @@ trait CompositeKeys {
|
|||||||
{
|
{
|
||||||
$keys = $this->getKeyName();
|
$keys = $this->getKeyName();
|
||||||
|
|
||||||
if (! is_array($keys)) {
|
return !is_array($keys)
|
||||||
return parent::setKeysForSaveQuery($query);
|
? parent::setKeysForSaveQuery($query)
|
||||||
|
: $query->where(function($q) use($keys) {
|
||||||
|
foreach ($keys as $key){
|
||||||
|
$q->where($key,$this->getAttribute($key));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
foreach($keys as $keyName) {
|
|
||||||
$query->where($keyName, '=', $this->getKeyForSaveQuery($keyName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the primary key value for a save query.
|
* Get the casts array.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getCasts()
|
||||||
|
{
|
||||||
|
if ($this->getIncrementing())
|
||||||
|
return array_merge([$this->getKeyName() => $this->getKeyType()],$this->casts);
|
||||||
|
|
||||||
|
return $this->casts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
|
public function getIncrementing()
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of the model's primary key.
|
||||||
*
|
*
|
||||||
* @param mixed $keyName
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function getKeyForSaveQuery($keyName = null)
|
public function getKey()
|
||||||
{
|
{
|
||||||
if (is_null($keyName)) {
|
$fields = $this->getKeyName();
|
||||||
$keyName = $this->getKeyName();
|
$keys = [];
|
||||||
|
|
||||||
|
array_map(function($key) use(&$keys) {
|
||||||
|
$keys[] = $this->getAttribute($key);
|
||||||
|
}, $fields);
|
||||||
|
|
||||||
|
return $keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->original[$keyName])) {
|
/**
|
||||||
return $this->original[$keyName];
|
* Finds model by primary keys
|
||||||
|
*
|
||||||
|
* @param array $ids
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function find(array $ids)
|
||||||
|
{
|
||||||
|
$modelClass = get_called_class();
|
||||||
|
$model = new $modelClass();
|
||||||
|
$keys = $model->primaryKey;
|
||||||
|
|
||||||
|
return $model->where(function($query) use($ids,$keys) {
|
||||||
|
foreach ($keys as $idx => $key) {
|
||||||
|
if (isset($ids[$idx]))
|
||||||
|
$query->where($key, $ids[$idx]);
|
||||||
|
else
|
||||||
|
$query->whereNull($key);
|
||||||
|
}
|
||||||
|
})->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getAttribute($keyName);
|
/**
|
||||||
|
* Find model by primary key or throws ModelNotFoundException
|
||||||
|
*
|
||||||
|
* @param array $ids
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function findOrFail(array $ids)
|
||||||
|
{
|
||||||
|
$modelClass = get_called_class();
|
||||||
|
$model = new $modelClass();
|
||||||
|
$record = $model->find($ids);
|
||||||
|
|
||||||
|
if (! $record)
|
||||||
|
throw new ModelNotFoundException;
|
||||||
|
|
||||||
|
return $record;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user