mirror of https://github.com/4xmen/xshop.git
parent
c7f582ed46
commit
970dfd0795
@ -0,0 +1,42 @@
|
||||
@extends('admin.templates.panel-form-template')
|
||||
@section('title')
|
||||
@if(isset($item))
|
||||
{{__("Edit user")}} [{{$item->id}}]
|
||||
@else
|
||||
{{__("Add new user")}}
|
||||
@endif -
|
||||
@endsection
|
||||
@section('form')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
|
||||
@include('components.err')
|
||||
<div class="item-list mb-3">
|
||||
<h3 class="p-3">
|
||||
<i class="ri-message-3-line"></i>
|
||||
{{__("Tips")}}
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
{{__("Recommends")}}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-9 ps-xl-1 ps-xxl-1">
|
||||
<div class="general-form ">
|
||||
|
||||
<h1>
|
||||
@if(isset($item))
|
||||
{{__("Edit user")}} [{{$item->id}}]
|
||||
@else
|
||||
{{__("Add new user")}}
|
||||
@endif
|
||||
</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -0,0 +1,15 @@
|
||||
@extends('admin.templates.panel-list-template')
|
||||
|
||||
@section('list-title')
|
||||
<i class="ri-user-3-line"></i>
|
||||
{{__("Users list")}}
|
||||
@endsection
|
||||
@section('title')
|
||||
{{__("Users list")}} -
|
||||
@endsection
|
||||
@section('filter')
|
||||
{{-- Other filters --}}
|
||||
@endsection
|
||||
@section('bulk')
|
||||
{{-- <option value="-"> - </option> --}}
|
||||
@endsection
|
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\XController;
|
||||
use App\Http\Requests\GroupSaveRequest;
|
||||
use App\Models\Access;
|
||||
use App\Models\Group;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Helper;
|
||||
use function App\Helpers\hasCreateRoute;
|
||||
|
||||
class GroupController extends XController
|
||||
{
|
||||
|
||||
// protected $_MODEL_ = Group::class;
|
||||
// protected $SAVE_REQUEST = GroupSaveRequest::class;
|
||||
|
||||
protected $cols = ['name','subtitle','parent_id'];
|
||||
protected $extra_cols = ['id','slug'];
|
||||
|
||||
protected $searchable = ['name','subtitle','description'];
|
||||
|
||||
protected $listView = 'admin.groups.group-list';
|
||||
protected $formView = 'admin.groups.group-form';
|
||||
|
||||
|
||||
protected $buttons = [
|
||||
'edit' =>
|
||||
['title' => "Edit", 'class' => 'btn-outline-primary', 'icon' => 'ri-edit-2-line'],
|
||||
'show' =>
|
||||
['title' => "Detail", 'class' => 'btn-outline-light', 'icon' => 'ri-eye-line'],
|
||||
'destroy' =>
|
||||
['title' => "Remove", 'class' => 'btn-outline-danger delete-confirm', 'icon' => 'ri-close-line'],
|
||||
];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(Group::class, GroupSaveRequest::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $group Group
|
||||
* @param $request GroupSaveRequest
|
||||
* @return Group
|
||||
*/
|
||||
public function save($group, $request)
|
||||
{
|
||||
|
||||
$group->name = $request->input('name');
|
||||
$group->subtitle = $request->input('subtitle');
|
||||
$group->description = $request->input('description');
|
||||
$group->parent_id = $request->input('parent_id');
|
||||
$group->slug = $this->getSlug($group);
|
||||
if ($request->has('image')){
|
||||
$group->image = $this->storeFile('image',$group, 'groups');
|
||||
}
|
||||
if ($request->has('bg')){
|
||||
$group->bg = $this->storeFile('bg',$group, 'groups');
|
||||
}
|
||||
$group->save();
|
||||
return $group;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
$cats = Group::all();
|
||||
return view($this->formView,compact('cats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Group $item)
|
||||
{
|
||||
//
|
||||
$cats = Group::all();
|
||||
return view($this->formView, compact('item','cats'));
|
||||
}
|
||||
|
||||
public function bulk(Request $request)
|
||||
{
|
||||
|
||||
// dd($request->all());
|
||||
$data = explode('.', $request->input('action'));
|
||||
$action = $data[0];
|
||||
$ids = $request->input('id');
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
$msg = __(':COUNT items deleted successfully', ['COUNT' => count($ids)]);
|
||||
$this->_MODEL_::destroy($ids);
|
||||
break;
|
||||
/**restore*/
|
||||
case 'restore':
|
||||
$msg = __(':COUNT items restored successfully', ['COUNT' => count($ids)]);
|
||||
foreach ($ids as $id) {
|
||||
$this->_MODEL_::withTrashed()->find($id)->restore();
|
||||
}
|
||||
break;
|
||||
/*restore**/
|
||||
default:
|
||||
$msg = __('Unknown bulk action : :ACTION', ["ACTION" => $action]);
|
||||
}
|
||||
|
||||
return $this->do_bulk($msg, $action, $ids);
|
||||
}
|
||||
|
||||
public function destroy(Group $item)
|
||||
{
|
||||
return parent::delete($item);
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, Group $item)
|
||||
{
|
||||
return $this->bringUp($request, $item);
|
||||
}
|
||||
|
||||
/**restore*/
|
||||
public function restore($item)
|
||||
{
|
||||
return parent::restoreing(Group::withTrashed()->where('id', $item)->first());
|
||||
}
|
||||
/*restore**/
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class GroupSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'min:2', 'max:128'],
|
||||
'subtitle' => ['nullable', 'string',],
|
||||
'image' => ['nullable', 'file', 'mimes:jpg,svg,png'],
|
||||
'bg' => ['nullable', 'file', 'mimes:jpg,svg,png'],
|
||||
'description' => ['nullable', 'string',],
|
||||
'parent_id' => ['nullable', 'exists:groups,id'],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
@extends('admin.templates.panel-form-template')
|
||||
@section('title')
|
||||
@if(isset($item))
|
||||
{{__("Edit group")}} [{{$item->name}}]
|
||||
@else
|
||||
{{__("Add new group")}}
|
||||
@endif -
|
||||
@endsection
|
||||
@section('form')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
@include('components.err')
|
||||
<div class="item-list mb-3">
|
||||
<h3 class="p-3">
|
||||
<i class="ri-message-3-line"></i>
|
||||
{{__("Tips")}}
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
{{__("You can leave the slug empty; it will be generated automatically.")}}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@if(isset($item))
|
||||
<div class="item-list mb-3">
|
||||
<h3 class="p-3">
|
||||
<i class="ri-image-2-line"></i>
|
||||
{{__('Feature image')}}
|
||||
</h3>
|
||||
<img src="{{$item->imgUrl()}}" alt="{{$item->name}}" class="img-fluid">
|
||||
|
||||
</div>
|
||||
<div class="item-list mb-3">
|
||||
<h3 class="p-3">
|
||||
<i class="ri-image-2-line"></i>
|
||||
{{__('Background image')}}
|
||||
</h3>
|
||||
<img src="{{$item->bgUrl()}}" alt="{{$item->name}}" class="img-fluid">
|
||||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-lg-9 ps-xl-1 ps-xxl-1">
|
||||
<div class="general-form ">
|
||||
|
||||
<h1>
|
||||
@if(isset($item))
|
||||
{{__("Edit group")}} [{{$item->name}}]
|
||||
@else
|
||||
{{__("Add new group")}}
|
||||
@endif
|
||||
</h1>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-6 mt-3">
|
||||
<label for="name">
|
||||
{{__('Category name')}}
|
||||
</label>
|
||||
<input name="name" type="text" class="form-control @error('name') is-invalid @enderror"
|
||||
placeholder="{{__('Group name')}}" value="{{old('name',$item->name??null)}}"/>
|
||||
</div>
|
||||
<div class="col-md-6 mt-3">
|
||||
<label for="name">
|
||||
{{__('Category slug')}}
|
||||
</label>
|
||||
<input name="slug" type="text" class="form-control @error('slug') is-invalid @enderror"
|
||||
placeholder="{{__('Group slug')}}" value="{{old('slug',$item->slug??null)}}"/>
|
||||
</div>
|
||||
<div class="col-md-12 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="subtitle">
|
||||
{{__('Subtitle')}}
|
||||
</label>
|
||||
<input name="subtitle" type="text"
|
||||
class="form-control @error('subtitle') is-invalid @enderror" id="subtitle"
|
||||
placeholder="{{__('Subtitle')}}" value="{{old('subtitle',$item->subtitle??null)}}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mt-3">
|
||||
<label for="parent">
|
||||
{{__('Group Parent')}}
|
||||
</label>
|
||||
<select name="parent_id" id="parent"
|
||||
class="form-control @error('parent') is-invalid @enderror">
|
||||
<option value=""> {{__('No parent')}} </option>
|
||||
@foreach($cats as $cat )
|
||||
@if($cat->id != $item->id)
|
||||
<option value="{{ $cat->id }}"
|
||||
@if (old('parent',$item->parent_id??null) == $cat->id ) selected @endif >
|
||||
{{$cat->name}}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="image">
|
||||
{{__('Feature image')}}
|
||||
</label>
|
||||
<input accept=".jpg,.png,.svg" name="image" type="file"
|
||||
class="form-control @error('image') is-invalid @enderror" id="image"
|
||||
placeholder="{{__('Feature image')}}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="bg">
|
||||
{{__('Background image')}}
|
||||
</label>
|
||||
<input accept=".jpg,.png,.svg" name="bg" type="file"
|
||||
class="form-control @error('bg') is-invalid @enderror" id="bg"
|
||||
placeholder="{{__('Background image')}}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 mt-3">
|
||||
<label for="description">
|
||||
{{__('Description')}}
|
||||
</label>
|
||||
<textarea rows="5" name="description"
|
||||
class="form-control @error('description') is-invalid @enderror"
|
||||
placeholder="{{__('Description')}}">{{old('description',$item->description??null)}}</textarea>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label> </label>
|
||||
<input name="" type="submit" class="btn btn-primary mt-2" value="{{__('Save')}}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -0,0 +1,15 @@
|
||||
@extends('admin.templates.panel-list-template')
|
||||
|
||||
@section('list-title')
|
||||
<i class="ri-user-3-line"></i>
|
||||
{{__("Groups list")}}
|
||||
@endsection
|
||||
@section('title')
|
||||
{{__("Groups list")}} -
|
||||
@endsection
|
||||
@section('filter')
|
||||
{{-- Other filters --}}
|
||||
@endsection
|
||||
@section('bulk')
|
||||
{{-- <option value="-"> - </option> --}}
|
||||
@endsection
|
Loading…
Reference in New Issue