mirror of https://github.com/4xmen/xshop.git
added xController store ad update
form template edited menu and order migrationpull/44/head
parent
56110bb254
commit
22c6f45111
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UserSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->check() and auth()->user()->hasRole('developer|admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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', 'max:255'],
|
||||
'mobile' => ['required', 'string', 'min:10'],
|
||||
'role' => ['required', 'string'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', "unique:users,email,".$this->id],
|
||||
'password' => ['string', 'min:8', 'confirmed','nullable'],
|
||||
];
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
|
||||
class MenuItem extends Model
|
||||
{
|
||||
use HasFactory,HasTranslations;
|
||||
|
||||
public $translatable = ['title'];
|
||||
|
||||
public function menu()
|
||||
{
|
||||
return $this->belongsTo(Menu::class, 'menu_id', 'id');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(MenuItem::class, 'parent');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(MenuItem::class, 'parent');
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
|
||||
@if(hasRoute('create') && isset($item))
|
||||
<a class="action-btn circle-btn"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
data-bs-custom-class="custom-tooltip"
|
||||
data-bs-title="{{__("Add another one")}}"
|
||||
href="{{getRoute('create')}}"
|
||||
>
|
||||
<i class="ri-add-line"></i>
|
||||
</a>
|
||||
@else
|
||||
<a class="action-btn circle-btn"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
data-bs-custom-class="custom-tooltip"
|
||||
data-bs-title="{{__("Show list")}}"
|
||||
href="{{getRoute('index',[])}}"
|
||||
>
|
||||
<i class="ri-list-view"></i>
|
||||
</a>
|
||||
@endif
|
||||
<form
|
||||
@if(isset($item))
|
||||
id="model-form-edit"
|
||||
action="{{getRoute('update',$item->{$item->getRouteKeyName()})}}"
|
||||
@else
|
||||
id="model-form-create"
|
||||
action="{{getRoute('store')}}"
|
||||
@endif
|
||||
method="post" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@if(isset($item))
|
||||
<input type="hidden" name="id" value="{{$item->id}}"/>
|
||||
@endif
|
||||
@yield('form')
|
||||
</form>
|
||||
@endsection
|
@ -1 +1,113 @@
|
||||
<?php
|
||||
@extends('admin.templates.panel-form-template')
|
||||
@section('title')
|
||||
@if(isset($item))
|
||||
{{__("Edit user")}} [{{$item->name}}]
|
||||
@else
|
||||
{{__("Add new user")}}
|
||||
@endif -
|
||||
@endsection
|
||||
@section('form')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<div class="item-list mb-3">
|
||||
<h3 class="p-3">
|
||||
<i class="ri-message-3-line"></i>
|
||||
{{__("Tips")}}
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
{{__("If you want to change the password, choose both the same. Otherwise, leave the password field blank.")}}
|
||||
</li>
|
||||
<li>
|
||||
{{__("E-mail is unique each users")}}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@include('components.err')
|
||||
</div>
|
||||
<div class="col-lg-9 ps-xl-1 ps-xxl-1">
|
||||
<div class="general-form ">
|
||||
|
||||
<h1>
|
||||
@if(isset($item))
|
||||
{{__("Edit user")}} [{{$item->name}}]
|
||||
@else
|
||||
{{__("Add new user")}}
|
||||
@endif
|
||||
</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-xl-6 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="name">
|
||||
{{__('Name')}}
|
||||
</label>
|
||||
<input name="name" type="text" class="form-control @error('name') is-invalid @enderror"
|
||||
placeholder="{{__('Name')}}" value="{{old('name',$item->name??null)}}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-6 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="email">
|
||||
{{__('Email')}}
|
||||
</label>
|
||||
<input name="email" type="email" class="form-control @error('email') is-invalid @enderror"
|
||||
placeholder="{{__('Email')}}" value="{{old('email',$item->email??null)}}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="role">
|
||||
{{__('Role')}}
|
||||
</label>
|
||||
<searchable-select
|
||||
:items='{{arrayNormolizeVueCompatible(\App\Models\User::$roles, true)}}'
|
||||
title-field="name"
|
||||
value-field="name"
|
||||
xname="role"
|
||||
@error('role') :err="true" @enderror
|
||||
xvalue='{{old('role',$item->role??null)}}'
|
||||
:close-on-Select="true"></searchable-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="mobile">
|
||||
{{__('Mobile')}}
|
||||
</label>
|
||||
<input name="mobile" type="text" class="form-control @error('mobile') is-invalid @enderror"
|
||||
placeholder="{{__('Mobile')}}" value="{{old('mobile',$item->mobile??null)}}"
|
||||
min-length="10"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="password">
|
||||
{{__('Password')}}
|
||||
</label>
|
||||
<input name="password" type="password"
|
||||
class="form-control @error('password') is-invalid @enderror"
|
||||
placeholder="{{__('Password')}}" value="{{old('password',''??null)}}"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3 mt-3">
|
||||
<div class="form-group">
|
||||
<label for="password_confirmation">
|
||||
{{__('password repeat')}}
|
||||
</label>
|
||||
<input name="password_confirmation" type="password"
|
||||
class="form-control @error('password_confirmation') is-invalid @enderror"
|
||||
placeholder="{{__('password repeat')}}"
|
||||
value="{{old('password_confirmation',$item->password_confirmation??null)}}"/>
|
||||
</div>
|
||||
</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
|
||||
|
Loading…
Reference in New Issue