diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 485c35a..dcdbb9d 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -4,7 +4,6 @@ on: push: tags: - "*" - branches: [ "master" ] pull_request: branches: [ "master" ] diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 5879273..f4e1177 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -999,7 +999,7 @@ function isGuestMaxAttemptTry($action, $max = 5, $minutes = 60) { if (\App\Models\GuestLog::where('ip', request()->ip()) ->where('action', $action) - ->where('created_at', '<', time() - ($minutes * 60))->count() >= $max) { + ->where('created_at', '>', time() - ($minutes * 60))->count() >= $max) { return true; } else { return false; diff --git a/app/Http/Controllers/Admin/GuestLogController.php b/app/Http/Controllers/Admin/GuestLogController.php new file mode 100644 index 0000000..2d4f44c --- /dev/null +++ b/app/Http/Controllers/Admin/GuestLogController.php @@ -0,0 +1,108 @@ + +// ['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(GuestLog::class, GuestLogSaveRequest::class); + } + + /** + * @param $guestlog GuestLog + * @param $request GuestLogSaveRequest + * @return GuestLog + */ + public function save($guestlog, $request) + { + + $guestlog->save(); + return $guestlog; + + } + + + /** + * Show the form for creating a new resource. + */ + public function create() + { + // + return view($this->formView); + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(GuestLog $item) + { + // + return view($this->formView, compact('item')); + } + + 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; + + default: + $msg = __('Unknown bulk action : :ACTION', ["ACTION" => $action]); + } + + return $this->do_bulk($msg, $action, $ids); + } + + public function destroy(GuestLog $item) + { + return parent::delete($item); + } + + + public function update(Request $request, GuestLog $item) + { + return $this->bringUp($request, $item); + } + + +} diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 3c4183f..373ac6a 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Contracts\Payment; use App\Http\Requests\ContactSubmitRequest; +use App\Mail\AuthMail; use App\Models\Attachment; use App\Models\Category; use App\Models\Clip; @@ -20,6 +21,7 @@ use App\Models\Rate; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Route; use Plank\Metable\Meta; use Spatie\Tags\Tag; @@ -231,6 +233,14 @@ class ClientController extends Controller public function search(Request $request) { + + + if (isGuestMaxAttemptTry('search', 5, 1)) { + return abort(403); + } + + guestLog('search'); + $q = trim($request->input('q')); if (mb_strlen($q) < 3) { return abort(403, __('Search word is too short')); @@ -476,7 +486,45 @@ class ClientController extends Controller public function signUp() { + if (config('app.sms.sign')){ + return abort(403); + } + $area = 'register'; + $title = __("sign up"); + $subtitle = __('Sign up as customer'); + return view('client.default-list', compact('area', 'title', 'subtitle')); + } + public function signUpNow(Request $request) + { + if (config('app.sms.sign')){ + return abort(403); + } + + $request->validate([ + 'email' => ['required','email'] + ]); + + if (isGuestMaxAttemptTry('email', 1, 5)) { + return redirect()->back()->withErrors( __('You try attempts, Try it a few minutes')); + } + + guestLog('email'); + + $passwd = generateUniqueID(12); + Mail::to($request->input('email'))->send(new AuthMail($passwd)); + $c = Customer::where('email', $request->email); + if ($c->count() > 0) { + $customer = $c->first(); + $msg = __('Your account password has been changed successfully.'); + }else{ + $customer = new Customer(); + $customer->email = $request->email; + $msg = __('Your account has been created successfully.'); + } + $customer->password = bcrypt($passwd); + $customer->save(); + return redirect()->back()->with(['message' => $msg]); } public function singInDo(Request $request) diff --git a/app/Http/Requests/GuestLogSaveRequest.php b/app/Http/Requests/GuestLogSaveRequest.php new file mode 100644 index 0000000..9a8f50c --- /dev/null +++ b/app/Http/Requests/GuestLogSaveRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Mail/AuthMail.php b/app/Mail/AuthMail.php new file mode 100644 index 0000000..c1ff42a --- /dev/null +++ b/app/Mail/AuthMail.php @@ -0,0 +1,60 @@ + $this->code + ], + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/config/app.php b/config/app.php index 8d6dbb6..5dce2cd 100644 --- a/config/app.php +++ b/config/app.php @@ -15,8 +15,8 @@ return [ | */ - 'name' => env('APP_NAME', 'Laravel'), - 'version' => env('APP_VERSION', '2.0.0-beta-3'), + 'name' => env('APP_NAME', 'xShop'), + 'version' => env('APP_VERSION', '2.0.0'), 'demo' => env('APP_DEMO', false), /* |-------------------------------------------------------------------------- diff --git a/database/seeders/PartSeeder.php b/database/seeders/PartSeeder.php index 164177c..9d637eb 100644 --- a/database/seeders/PartSeeder.php +++ b/database/seeders/PartSeeder.php @@ -263,6 +263,15 @@ class PartSeeder extends Seeder // ------------------------------------------------------------- + $part = new Part(); + $part->segment = 'register'; + $part->part = 'SimpleRegister'; + $part->area_id = Area::where('name', 'register')->first()->id; + $part->sort = 1; + $part->save(); + + // ------------------------------------------------------------- + $part = new Part(); $part->segment = 'customer'; $part->part = 'AvisaCustomer'; diff --git a/resources/js/client.js b/resources/js/client.js index 8b1f314..12a125e 100644 --- a/resources/js/client.js +++ b/resources/js/client.js @@ -37,6 +37,7 @@ import "../views/segments/galleries_page/GalleriesList/GalleriesList.js"; import "../views/segments/gallery/GallaryGrid/GallaryGrid.js"; import "../views/segments/compare/CompareProducts/CompareProducts.js"; import "../views/segments/login/LoginPatternBg/LoginPatternBg.js"; +import "../views/segments/register/SimpleRegister/SimpleRegister.js"; import "../views/segments/customer/AvisaCustomer/AvisaCustomer.js"; import "../views/segments/attachments_page/DenaAttachList/DenaAttachList.js"; import "../views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview.js"; diff --git a/resources/sass/client.scss b/resources/sass/client.scss index 2ceaad4..2561e8e 100644 --- a/resources/sass/client.scss +++ b/resources/sass/client.scss @@ -48,6 +48,7 @@ $xshop-shadow:2px 2px 4px #777777; @import "../views/segments/gallery/GallaryGrid/GallaryGrid"; @import "../views/segments/compare/CompareProducts/CompareProducts"; @import "../views/segments/login/LoginPatternBg/LoginPatternBg"; +@import "../views/segments/register/SimpleRegister/SimpleRegister"; @import "../views/segments/customer/AvisaCustomer/AvisaCustomer"; @import "../views/segments/attachments_page/DenaAttachList/DenaAttachList"; @import "../views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview"; diff --git a/resources/views/admin/guestlogs/guestlog-form.blade.php b/resources/views/admin/guestlogs/guestlog-form.blade.php new file mode 100644 index 0000000..4b40052 --- /dev/null +++ b/resources/views/admin/guestlogs/guestlog-form.blade.php @@ -0,0 +1,42 @@ +@extends('admin.templates.panel-form-template') +@section('title') + @if(isset($item)) + {{__("Edit guestlog")}} [{{$item->id}}] + @else + {{__("Add new guestlog")}} + @endif - +@endsection +@section('form') + +
+
+ + @include('components.err') +
+

+ + {{__("Tips")}} +

+
    +
  • + {{__("Recommends")}} +
  • +
+
+ +
+
+
+ +

+ @if(isset($item)) + {{__("Edit guestlog")}} [{{$item->id}}] + @else + {{__("Add new guestlog")}} + @endif +

+ +
+
+
+@endsection diff --git a/resources/views/admin/guestlogs/guestlog-list.blade.php b/resources/views/admin/guestlogs/guestlog-list.blade.php new file mode 100644 index 0000000..586ccbd --- /dev/null +++ b/resources/views/admin/guestlogs/guestlog-list.blade.php @@ -0,0 +1,15 @@ +@extends('admin.templates.panel-list-template') + +@section('list-title') + + {{__("GuestLogs list")}} +@endsection +@section('title') + {{__("GuestLogs list")}} - +@endsection +@section('filter') + {{-- Other filters --}} +@endsection +@section('bulk') + {{-- --}} +@endsection diff --git a/resources/views/components/panel-header.blade.php b/resources/views/components/panel-header.blade.php index 388a32d..435b50c 100644 --- a/resources/views/components/panel-header.blade.php +++ b/resources/views/components/panel-header.blade.php @@ -6,7 +6,13 @@ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> - + + + {{-- open graph --}} + + + + diff --git a/resources/views/components/panel-side-navbar.blade.php b/resources/views/components/panel-side-navbar.blade.php index 708b07d..181060f 100644 --- a/resources/views/components/panel-side-navbar.blade.php +++ b/resources/views/components/panel-side-navbar.blade.php @@ -301,7 +301,7 @@ @endif @if( auth()->user()->hasAnyAccess( 'guestlog' ))
  • - + {{__('Logs of guests')}} diff --git a/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php b/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php index bfbd557..8dd5ecb 100644 --- a/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php +++ b/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php @@ -78,6 +78,34 @@
     
     
    @include('components.err') + @if(cardCount() > 0) +
    + + {{__("Continue")}} + +
    + {{__("System notification")}} +
    + {{__("You have some products in your shopping card.")}} +
    +
    + @endif + @if( auth('customer')->user()->name == null || trim(auth('customer')->user()->name) == '') +
    +
    + {{__("System notification")}} +
    + {{__("Your information is insufficient, Please complete your information")}} +
    + @endif + @if( auth('customer')->user()->addresses()->count() == 0) +
    +
    + {{__("System notification")}} +
    + {{__("You need at least one address to order, Please add address")}} +
    + @endif
    @@ -148,34 +176,6 @@
    - @if(cardCount() > 0) -
    - - {{__("Continue")}} - -
    - {{__("System notification")}} -
    - {{__("You have some products in your shopping card.")}} -
    -
    - @endif - @if( auth('customer')->user()->name == null || trim(auth('customer')->user()->name) == '') -
    -
    - {{__("System notification")}} -
    - {{__("Your information is insufficient, Please complete your information")}} -
    - @endif - @if( auth('customer')->user()->addresses()->count() == 0) -
    -
    - {{__("System notification")}} -
    - {{__("You need at least one address to order, Please add address")}} -
    - @endif
    diff --git a/resources/views/segments/register/SimpleRegister/SimpleRegister.blade.php b/resources/views/segments/register/SimpleRegister/SimpleRegister.blade.php new file mode 100644 index 0000000..5f40bb2 --- /dev/null +++ b/resources/views/segments/register/SimpleRegister/SimpleRegister.blade.php @@ -0,0 +1,23 @@ +
    +
    +
    + @csrf + @include('components.err') + +
    + {{__("Register or Reset password")}} +
    +
    + + +
    + + + +
    +
    diff --git a/resources/views/segments/register/SimpleRegister/SimpleRegister.js b/resources/views/segments/register/SimpleRegister/SimpleRegister.js new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/segments/register/SimpleRegister/SimpleRegister.json b/resources/views/segments/register/SimpleRegister/SimpleRegister.json new file mode 100644 index 0000000..795db20 --- /dev/null +++ b/resources/views/segments/register/SimpleRegister/SimpleRegister.json @@ -0,0 +1,10 @@ +{ + "name": "SimpleRegister", + "version": "1.0", + "author": "xStack", + "email": "xshop@xstack.ir", + "license": "GPL-3.0-or-later", + "url": "https:\/\/xstack.ir", + "author_url": "https:\/\/4xmen.ir", + "packages": [] +} \ No newline at end of file diff --git a/resources/views/segments/register/SimpleRegister/SimpleRegister.php b/resources/views/segments/register/SimpleRegister/SimpleRegister.php new file mode 100644 index 0000000..937b8b8 --- /dev/null +++ b/resources/views/segments/register/SimpleRegister/SimpleRegister.php @@ -0,0 +1,21 @@ + + {{__("Your Authentication Mail")}} + +

    + {{__("Password or new password is:")}} {{$code}} +

    diff --git a/resources/views/website/inc/website-head.blade.php b/resources/views/website/inc/website-head.blade.php index 3854bfa..05b03a6 100644 --- a/resources/views/website/inc/website-head.blade.php +++ b/resources/views/website/inc/website-head.blade.php @@ -6,7 +6,9 @@ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> - + @if(! config('app.demo')) + + @endif {{-- Please don't modify or remove generator --}} @@ -15,7 +17,7 @@ @yield('title') - @if(langIsRTL(config('app.locale'))) + @if(langIsRTL(app()->getLocale())) @else @@ -30,7 +32,7 @@ {{-- seo --}} - + @if(isset($breadcrumb)) {!! markUpBreadcrumbList($breadcrumb) !!} @endif diff --git a/routes/web.php b/routes/web.php index dfc4d33..21770f7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -20,6 +20,7 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group( Route::post('ckeditor/upload', [\App\Http\Controllers\Admin\CkeditorController::class, 'upload'])->name('ckeditor.upload'); Route::get('adminlogs', [\App\Http\Controllers\Admin\AdminLogController::class, 'index'])->name('adminlog.index'); + Route::get('guestlog', [\App\Http\Controllers\Admin\GuestLogController::class, 'index'])->name('guestlog.index'); Route::get('rates', [\App\Http\Controllers\Admin\RateController::class, 'index'])->name('rate.index'); Route::get('adminlogs/{user}', [\App\Http\Controllers\Admin\AdminLogController::class, 'log'])->name('adminlog.show'); Route::post('images/store/{gallery}', [\App\Http\Controllers\Admin\ImageController::class, 'store'])->name('image.store'); @@ -396,6 +397,7 @@ Route::middleware([\App\Http\Middleware\VisitorCounter::class]) Route::post('/customer/sign-in/do', [ClientController::class, 'singInDo'])->name('sign-in-do'); Route::get('/customer/sign-in', [ClientController::class, 'signIn'])->name('sign-in'); Route::get('/customer/sign-up', [ClientController::class, 'signUp'])->name('sign-up'); + Route::post('/customer/sign-up/now', [ClientController::class, 'signUpNow'])->name('sign-up-now'); Route::get('/customer/send/auth-code', [ClientController::class, 'sendSms'])->name('send-sms'); Route::get('/customer/check/auth-code', [ClientController::class, 'checkAuth'])->name('check-auth'); Route::get('/customer/profile', [ClientController::class, 'profile'])->name('profile');