Skip to content

Commit

Permalink
Merge pull request #616 from nasirkhan/dev
Browse files Browse the repository at this point in the history
Update Settings Module
  • Loading branch information
nasirkhan authored Oct 10, 2024
2 parents fb22f4d + ddc2875 commit 5be07ff
Show file tree
Hide file tree
Showing 10 changed files with 522 additions and 503 deletions.
1 change: 0 additions & 1 deletion app/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ public function setMetaOgImageAttribute($value)
* Scope a query to only include active models.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return void
*/
public function scopeActive(Builder $query): void
{
Expand Down
447 changes: 227 additions & 220 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/views/backend/includes/sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
$text = __('Settings');
$icon = "fa-solid fa-gears";
$permission = "edit_".$module_name;
$url = route('backend.'.$module_name);
$url = route('backend.'.$module_name.'.index');
@endphp
<x-backend.sidebar-nav-item :permission="$permission" :url="$url" :icon="$icon" :text="$text" />

Expand Down
23 changes: 16 additions & 7 deletions resources/views/backend/settings/fields/checkbox.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
@php
$required = (Str::contains($field['rules'], 'required')) ? "required" : "";
$required_mark = ($required != "") ? '<span class="text-danger"> <strong>*</strong> </span>' : '';
$required = Str::contains($field['rules'], 'required') ? 'required' : '';
$required_mark = $required != '' ? '<span class="text-danger"> <strong>*</strong> </span>' : '';
@endphp

<div class="form-group mt-3 {{ $errors->has($field['name']) ? ' has-error' : '' }}">
<div class="form-group {{ $errors->has($field['name']) ? ' has-error' : '' }} mt-3">
<div class="checkbox">

<label class='form-label' for="{{ $field['name'] }}"> <strong>{{ __($field['label']) }}</strong>
({{ $field['name'] }})</label> {!! $required_mark !!}
<br>

<label>
<input type='hidden' value='0' name='{{ $field['name'] }}' class='form-label'>
<input name=" {{ $field['name'] }}" value="{{ \Illuminate\Support\Arr::get($field, 'value', '1') }}" type="checkbox" @if(old($field['name'], setting($field['name']))) checked="checked" @endif>
<input class='form-label' name='{{ $field['name'] }}' type='hidden' value='0'>
<input name=" {{ $field['name'] }}" type="checkbox"
value="{{ \Illuminate\Support\Arr::get($field, 'value', '1') }}"
@if (old($field['name'], setting($field['name']))) checked="checked" @endif>
{{ $field['label'] }}
</label> {!! $required_mark !!}

@if ($errors->has($field['name'])) <small class="help-block">{{ $errors->first($field['name']) }}</small> @endif
@if ($errors->has($field['name']))
<small class="help-block">{{ $errors->first($field['name']) }}</small>
@endif
</div>
</div>
</div>
98 changes: 44 additions & 54 deletions resources/views/backend/settings/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,68 +1,58 @@
@extends('backend.layouts.app')

@section('title') {{ __($module_action) }} {{ __($module_title) }} @endsection
@section('title')
{{ __($module_action) }} {{ __($module_title) }}
@endsection

@section('breadcrumbs')
<x-backend.breadcrumbs>
<x-backend.breadcrumb-item type="active" icon='{{ $module_icon }}'>{{ __($module_title) }}</x-backend.breadcrumb-item>
</x-backend.breadcrumbs>
<x-backend.breadcrumbs>
<x-backend.breadcrumb-item type="active"
icon='{{ $module_icon }}'>{{ __($module_title) }}</x-backend.breadcrumb-item>
</x-backend.breadcrumbs>
@endsection

@section('content')
<div class="card">
<div class="card-body">

<x-backend.section-header>
<i class="{{ $module_icon }}"></i> {{ __($module_title) }} <small class="text-muted">{{ __($module_action) }}</small>

<x-slot name="toolbar">
<x-backend.buttons.return-back />
</x-slot>
</x-backend.section-header>

<div class="row mt-4">
<div class="col">
<form method="post" action="{{ route('backend.settings.store') }}" class="form-horizontal" role="form">
{!! csrf_field() !!}

@if(count(config('setting_fields', [])) )

@foreach(config('setting_fields') as $section => $fields)
<div class="card card-accent-primary mb-4">
<div class="card-header">
<i class="{{ Arr::get($fields, 'icon', 'glyphicon glyphicon-flash') }}"></i>
&nbsp;{{ $fields['title'] }}
</div>
<div class="card-body">
<p class="text-muted">{{ $fields['desc'] }}</p>

<div class="row mt-3">
<div class="col">
@foreach($fields['elements'] as $field)
@includeIf('backend.settings.fields.' . $field['type'] )
@endforeach
<div class="card">
<div class="card-body">

<x-backend.section-header :module_name="$module_name" :module_title="$module_title" :module_icon="$module_icon" :module_action="$module_action" />

<div class="row mt-4">
<div class="col">

{{ html()->form('POST', route("backend.$module_name.store"))->open() }}

@if (count(config('setting_fields', [])))
@foreach (config('setting_fields') as $section => $fields)
<div class="card card-accent-primary mb-4">
<div class="card-header">
<i class="{{ Arr::get($fields, 'icon', 'glyphicon glyphicon-flash') }}"></i>
&nbsp;{{ $fields['title'] }}
</div>
<div class="card-body">
<p class="text-muted">{{ $fields['desc'] }}</p>

<div class="row mt-3">
<div class="col">
@foreach ($fields['elements'] as $field)
@includeIf('backend.settings.fields.' . $field['type'])
@endforeach
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endforeach
@endforeach
@endif

@endif

<div class="row m-b-md">
<div class="col-md-12">
<x-backend.buttons.save />
<div class="row m-b-md">
<div class="col-md-12">
<x-backend.buttons.save />
</div>
</div>
</div>

</form>
{{ html()->form()->close() }}
</div>
</div>
</div>
</div>
<div class="card-footer">
<div class="row">

</div>
</div>
</div>
@endsection
@endsection
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@props(["small"=>""])
@props(["small"=>"true"])
<button onclick="window.history.back();" class="btn btn-warning m-1 {{($small=='true')? 'btn-sm' : ''}}" data-toggle="tooltip" title="{{__('Return Back')}}"><i class="fas fa-reply fa-fw"></i>&nbsp;{!! ($slot != "") ? '&nbsp;' . $slot : '' !!}</button>
119 changes: 66 additions & 53 deletions resources/views/components/backend/section-header.blade.php
Original file line number Diff line number Diff line change
@@ -1,66 +1,79 @@
@props(["data"=>"", "toolbar"=>"", "title"=>"", "subtitle"=>"", "module_name"=>"", "module_title"=>"", "module_icon"=>"", "module_action"=>""])
@props([
'data' => '',
'toolbar' => '',
'title' => '',
'subtitle' => '',
'module_name' => '',
'module_title' => '',
'module_icon' => '',
'module_action' => '',
])

<div class="d-flex justify-content-between">
<div class="align-self-center">
@if($slot != "")
<h4 class="card-title mb-0">
{{ $slot }}
</h4>
@if ($slot != '')
<h4 class="card-title mb-0">
{{ $slot }}
</h4>
@else
<h4 class="card-title mb-0">
<i class="{{ $module_icon }}"></i> {{ __($module_title) }} <small class="text-muted">{{ __($module_action) }}</small>
</h4>
<h4 class="card-title mb-0">
<i class="{{ $module_icon }}"></i> {{ __($module_title) }} <small
class="text-muted">{{ __($module_action) }}</small>
</h4>
@endif

@if($subtitle)
<div class="small text-medium-emphasis">
{{ $subtitle }}
</div>
@if ($subtitle)
<div class="small text-medium-emphasis">
{{ $subtitle }}
</div>
@endif
</div>
@if($toolbar)
<div class="btn-toolbar d-block text-end" role="toolbar" aria-label="Toolbar with buttons">
{{ $toolbar }}
</div>
@if ($toolbar)
<div class="btn-toolbar d-block text-end" role="toolbar" aria-label="Toolbar with buttons">
{{ $toolbar }}
</div>
@else
<div class="btn-toolbar d-block text-end" role="toolbar" aria-label="Toolbar with buttons">
@if (Str::endsWith(Route::currentRouteName(), 'index'))
@can('add_' . $module_name)
<x-backend.buttons.create title="{{ __('Create') }} {{ ucwords(Str::singular($module_name)) }}"
small="true" route='{{ route("backend.$module_name.create") }}' />
@endcan
@can('restore_' . $module_name)
<div class="btn-group">
<button class="btn btn-secondary btn-sm dropdown-toggle" data-coreui-toggle="dropdown"
type="button" aria-expanded="false">
<i class="fas fa-cog"></i>
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href='{{ route("backend.$module_name.trashed") }}'>
<i class="fas fa-eye-slash"></i> @lang('View trash')
</a>
</li>
</ul>
</div>
@endcan
@elseif (Str::endsWith(Route::currentRouteName(), 'create'))
<x-backend.buttons.return-back small="true" />
<a href='{{ route("backend.$module_name.index") }}' class="btn btn-secondary btn-sm ms-1" data-toggle="tooltip" title="{{ __($module_title) }} List"><i class="fas fa-list-ul"></i> List</a>

@elseif (Str::endsWith(Route::currentRouteName(), 'edit'))
<x-backend.buttons.return-back small="true" />
<x-buttons.show route='{!!route("backend.$module_name.show", $data)!!}' title="{{__('Show')}} {{ ucwords(Str::singular($module_name)) }}" class="ms-1" small="true" />
<div class="btn-toolbar d-block text-end" role="toolbar" aria-label="Toolbar with buttons">
@if (Str::endsWith(Route::currentRouteName(), 'index'))
<x-backend.buttons.return-back />

@elseif (Str::endsWith(Route::currentRouteName(), 'show'))
<x-backend.buttons.return-back small="true" />
@can('edit_'.$module_name)
<x-buttons.edit route='{!!route("backend.$module_name.edit", $data)!!}' title="{{__('Edit')}} {{ ucwords(Str::singular($module_name)) }}" class="m-1" small="true" />
@endcan
<a href="{{ route("backend.$module_name.index") }}" class="btn btn-secondary btn-sm" data-toggle="tooltip" title="{{ ucwords($module_name) }} List"><i class="fas fa-list"></i> List</a>
@endif
</div>
@if (auth()->user()->can('add_' . $module_name) && Route::has('backend.'.$module_name.'.create'))
<x-backend.buttons.create title="{{ __('Create') }} {{ ucwords(Str::singular($module_name)) }}"
small="true" route='{{ route("backend.$module_name.create") }}' />
@endif
@if (auth()->user()->can('restore_' . $module_name) && Route::has('backend.'.$module_name.'.create'))
<div class="btn-group">
<button class="btn btn-secondary btn-sm dropdown-toggle" data-coreui-toggle="dropdown"
type="button" aria-expanded="false">
<i class="fas fa-cog"></i>
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href='{{ route("backend.$module_name.trashed") }}'>
<i class="fas fa-eye-slash"></i> @lang('View trash')
</a>
</li>
</ul>
</div>
@endif
@elseif (Str::endsWith(Route::currentRouteName(), 'create'))
<a class="btn btn-secondary btn-sm ms-1" data-toggle="tooltip"
href='{{ route("backend.$module_name.index") }}' title="{{ __($module_title) }} List"><i
class="fas fa-list-ul"></i> List</a>
@elseif (Str::endsWith(Route::currentRouteName(), 'edit'))
<x-buttons.show class="ms-1" title="{{ __('Show') }} {{ ucwords(Str::singular($module_name)) }}"
route='{!! route("backend.$module_name.show", $data) !!}' small="true" />
@elseif (Str::endsWith(Route::currentRouteName(), 'show'))
@if (auth()->user()->can('edit_' . $module_name) && Route::has('backend.'.$module_name.'.edit'))
<x-buttons.edit class="m-1" title="{{ __('Edit') }} {{ ucwords(Str::singular($module_name)) }}"
route='{!! route("backend.$module_name.edit", $data) !!}' small="true" />
@endif
<a class="btn btn-secondary btn-sm" data-toggle="tooltip"
href="{{ route("backend.$module_name.index") }}" title="{{ ucwords($module_name) }} List"><i
class="fas fa-list"></i> {{ __('List') }}</a>
@endif
</div>
@endif
</div>

<hr>
<hr>
4 changes: 3 additions & 1 deletion resources/views/components/frontend/card.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@props(['url', 'name', 'image' => ''])
@props(['url' => null, 'name', 'image' => ''])

<div class="flex flex-col rounded-lg border border-gray-200 bg-white shadow dark:border-gray-700 dark:bg-gray-800">
@if ($image)
Expand All @@ -19,6 +19,7 @@
<div class="mb-2 flex-1 px-5 text-sm font-normal sm:mb-4 sm:text-base">
{!! $slot !!}
</div>
@if ($url)
<div class="px-5 pb-5 text-end">
<a class="inline-flex items-center rounded bg-gray-200 px-3 py-2 text-sm text-gray-700 outline outline-1 outline-gray-800 hover:bg-gray-700 hover:text-gray-100 focus:outline-none dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"
href="{{ $url }}">
Expand All @@ -30,4 +31,5 @@
</svg>
</a>
</div>
@endif
</div>
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
Route::group(['middleware' => ['can:edit_settings']], function () {
$module_name = 'settings';
$controller_name = 'SettingController';
Route::get("{$module_name}", "{$controller_name}@index")->name("{$module_name}");
Route::get("{$module_name}", "{$controller_name}@index")->name("{$module_name}.index");
Route::post("{$module_name}", "{$controller_name}@store")->name("{$module_name}.store");
});

Expand Down
Loading

0 comments on commit 5be07ff

Please sign in to comment.