forked from a1gard/xshop
init
parent
82fb5f0499
commit
3b9d0670f8
@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
@ -0,0 +1,65 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=999999
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
|
||||
CURRENCY_TYPE="تومان"
|
||||
INVOICE_PREFIX="SHOP-9900-"
|
||||
SIGNUP_SMS=true
|
||||
SMS_URL=""
|
||||
SMS_USER=""
|
||||
SMS_PASS=""
|
||||
SMS_NUMBER=""
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
ZARINPAL_MERCHANT='12000000-0220-0000-0220-220000000001'
|
||||
PAY_GATWAY=zarinpal
|
@ -0,0 +1,10 @@
|
||||
* text=auto
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
@ -0,0 +1,243 @@
|
||||
|
||||
### Laravel ###
|
||||
/vendor/
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# Laravel 4 specific
|
||||
bootstrap/compiled.php
|
||||
app/storage/
|
||||
|
||||
# Laravel 5 & Lumen specific
|
||||
public/storage
|
||||
public/hot
|
||||
public/images/site.image
|
||||
public/favicon
|
||||
# Laravel 5 & Lumen specific with changed public path
|
||||
public_html/storage
|
||||
public_html/hot
|
||||
|
||||
storage/*.key
|
||||
|
||||
storage/*.*
|
||||
storage/media-library/*
|
||||
.env
|
||||
Homestead.yaml
|
||||
Homestead.json
|
||||
/.vagrant
|
||||
.phpunit.result.cache
|
||||
|
||||
### NetBeans ###
|
||||
**/nbproject/private/
|
||||
**/nbproject/Makefile-*.mk
|
||||
**/nbproject/Package-*.bash
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
### Node Patch ###
|
||||
# Serverless Webpack directories
|
||||
.webpack/
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
# SvelteKit build / generate output
|
||||
.svelte-kit
|
||||
|
||||
### PhpStorm ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
.idea
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,12 @@
|
||||
php:
|
||||
preset: laravel
|
||||
disabled:
|
||||
- no_unused_imports
|
||||
finder:
|
||||
not-name:
|
||||
- index.php
|
||||
js:
|
||||
finder:
|
||||
not-name:
|
||||
- webpack.mix.js
|
||||
css: true
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,749 @@
|
||||
<?php
|
||||
|
||||
// @formatter:off
|
||||
/**
|
||||
* A helper file for your Eloquent Models
|
||||
* Copy the phpDocs from this file to the correct Model,
|
||||
* And remove them from this file, to prevent double declarations.
|
||||
*
|
||||
* @author Barry vd. Heuvel <barryvdh@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Attachment
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property string $file
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereFile($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Attachment extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Cat
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $slug
|
||||
* @property string|null $description
|
||||
* @property int $sort
|
||||
* @property string|null $image
|
||||
* @property int|null $parent_id
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $active_products
|
||||
* @property-read int|null $active_products_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Cat[] $children
|
||||
* @property-read int|null $children_count
|
||||
* @property-read \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection|Media[] $media
|
||||
* @property-read int|null $media_count
|
||||
* @property-read Cat|null $parent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $products
|
||||
* @property-read int|null $products_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Prop[] $props
|
||||
* @property-read int|null $props_count
|
||||
* @method static \Database\Factories\CatFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Cat onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereImage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereParentId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereSort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Cat withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Cat withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Cat extends \Eloquent implements \Spatie\MediaLibrary\HasMedia {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Contact
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $full_name
|
||||
* @property string $email
|
||||
* @property string|null $subject
|
||||
* @property string $phone
|
||||
* @property string $body
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereBody($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereFullName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact wherePhone($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Contact extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Credit
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $amount
|
||||
* @property int $customer_id
|
||||
* @property int $invoice_id
|
||||
* @property string|null $data
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Credit onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereData($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Credit withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Credit withoutTrashed()
|
||||
*/
|
||||
class Credit extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Customer
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property \Illuminate\Support\Carbon|null $email_verified_at
|
||||
* @property string $password
|
||||
* @property int|null $state
|
||||
* @property int|null $city
|
||||
* @property string|null $mobile
|
||||
* @property string|null $address
|
||||
* @property string|null $postal_code
|
||||
* @property string|null $remember_token
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
|
||||
* @property-read int|null $notifications_count
|
||||
* @method static \Database\Factories\CustomerFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereEmailVerifiedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereMobile($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer wherePassword($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer wherePostalCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereState($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $code
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCode($value)
|
||||
* @property string|null $address_alt
|
||||
* @property string|null $sms
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Invoice[] $invoices
|
||||
* @property-read int|null $invoices_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ticket[] $main_tickets
|
||||
* @property-read int|null $main_tickets_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ticket[] $tickets
|
||||
* @property-read int|null $tickets_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereAddressAlt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereSms($value)
|
||||
* @property int $colleague
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereColleague($value)
|
||||
* @property string|null $description
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereDescription($value)
|
||||
* @property int $credit
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $products
|
||||
* @property-read int|null $products_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCredit($value)
|
||||
*/
|
||||
class Customer extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Discount
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $product_id
|
||||
* @property int $amount
|
||||
* @property string $type
|
||||
* @property string $code
|
||||
* @property string|null $expire
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\Product $product
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereExpire($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @method static \Illuminate\Database\Query\Builder|Discount onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Discount withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Discount withoutTrashed()
|
||||
*/
|
||||
class Discount extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Invoice
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $customer_id
|
||||
* @property string|null $status
|
||||
* @property int|null $total_price
|
||||
* @property string|null $meta
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Database\Factories\InvoiceFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereMeta($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTotalPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $discount_id
|
||||
* @property-read \App\Models\Discount|null $discount
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereDiscountId($value)
|
||||
* @property string|null $desc
|
||||
* @property int|null $transport_id
|
||||
* @property string|null $hash
|
||||
* @property-read \App\Models\Customer $customer
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Payment[] $payments
|
||||
* @property-read int|null $payments_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $products
|
||||
* @property-read int|null $products_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Payment[] $successPayments
|
||||
* @property-read int|null $success_payments_count
|
||||
* @property-read \App\Models\Transport|null $transport
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereDesc($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereHash($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTransportId($value)
|
||||
* @property int $transport_price
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTransportPrice($value)
|
||||
* @property string|null $address_alt
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereAddressAlt($value)
|
||||
* @property int $reserve
|
||||
* @property int|null $invoice_id
|
||||
* @property string|null $tracking_code
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereReserve($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTrackingCode($value)
|
||||
* @property int $credit_price
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property-read Invoice|null $invoice
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Invoice[] $subInvoices
|
||||
* @property-read int|null $sub_invoices_count
|
||||
* @method static \Illuminate\Database\Query\Builder|Invoice onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereCreditPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Invoice withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Invoice withoutTrashed()
|
||||
*/
|
||||
class Invoice extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Payment
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $invoice_id
|
||||
* @property int|null $amount
|
||||
* @property string|null $type
|
||||
* @property string|null $status
|
||||
* @property string $order_id
|
||||
* @property string|null $reference_id
|
||||
* @property string|null $comment
|
||||
* @property string|null $meta
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereComment($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereMeta($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereReferenceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \App\Models\Invoice $invoice
|
||||
*/
|
||||
class Payment extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Price
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $price
|
||||
* @property int $product_id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\Product $product
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Price extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Product
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $slug
|
||||
* @property string|null $description
|
||||
* @property string|null $excerpt Quick summary for product. This will appear on the product page under the product name and for SEO purpose.
|
||||
* @property string|null $sku SKU refers to a Stock-keeping unit, a unique identifier for each distinct product and service that can be purchased.
|
||||
* @property int|null $virtual If this product is a non-physical item, for example a service, which does not need shipping.
|
||||
* @property int|null $downloadable If purchasing this product gives a customer access to a downloadable file, e.g. software
|
||||
* @property int|null $price
|
||||
* @property int $cat_id main category id
|
||||
* @property int $user_id
|
||||
* @property int|null $on_sale
|
||||
* @property int|null $stock_quantity
|
||||
* @property string|null $stock_status
|
||||
* @property int|null $rating_count
|
||||
* @property string|null $average_rating
|
||||
* @property int|null $total_sales
|
||||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Comment[] $approved_comments
|
||||
* @property-read int|null $approved_comments_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Cat[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read \App\Models\Cat $category
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Comment[] $comments
|
||||
* @property-read int|null $comments_count
|
||||
* @property array $tag_names
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Tagged[] $tags
|
||||
* @property-read mixed $url
|
||||
* @property-read \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection|Media[] $media
|
||||
* @property-read int|null $media_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Plank\Metable\Meta[] $meta
|
||||
* @property-read int|null $meta_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Conner\Tagging\Model\Tagged[] $tagged
|
||||
* @property-read int|null $tagged_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Product onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product orderByMeta(string $key, string $direction = 'asc', bool $strict = false)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product orderByMetaNumeric(string $key, string $direction = 'asc', bool $strict = false)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereAverageRating($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereCatId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereDoesntHaveMeta($key)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereDownloadable($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereExcerpt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereHasMeta($key)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereHasMetaKeys(array $keys)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMeta(string $key, $operator, $value = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMetaIn(string $key, array $values)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMetaNumeric(string $key, string $operator, $value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereOnSale($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereRatingCount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSku($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereStockQuantity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereStockStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereTotalSales($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereVirtual($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withAllTags($tagNames)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withAnyTag($tagNames)
|
||||
* @method static \Illuminate\Database\Query\Builder|Product withTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withoutTags($tagNames)
|
||||
* @method static \Illuminate\Database\Query\Builder|Product withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Quantity[] $quantities
|
||||
* @property-read int|null $quantities_count
|
||||
* @property int $sell_count
|
||||
* @property int $view_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Price[] $prices
|
||||
* @property-read int|null $prices_count
|
||||
* @method static \Database\Factories\ProductFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSellCount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereViewCount($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Discount[] $discounts
|
||||
* @property-read int|null $discounts_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Question[] $quesions
|
||||
* @property-read int|null $quesions_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Question[] $quesions_asnwered
|
||||
* @property-read int|null $quesions_asnwered_count
|
||||
* @property int $fee
|
||||
* @property int $extra_price
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereExtraPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereFee($value)
|
||||
* @property int $image_index
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereImageIndex($value)
|
||||
*/
|
||||
class Product extends \Eloquent implements \Spatie\MediaLibrary\HasMedia {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Prop
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $label
|
||||
* @property string $width
|
||||
* @property int $required
|
||||
* @property int $searchable
|
||||
* @property string $type
|
||||
* @property int $sort
|
||||
* @property string|null $options
|
||||
* @property int $priceable
|
||||
* @property string|null $icon
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Cat[] $category
|
||||
* @property-read int|null $category_count
|
||||
* @method static \Database\Factories\PropFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Prop onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereIcon($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereLabel($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereOptions($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop wherePriceable($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereRequired($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereSearchable($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereSort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereWidth($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Prop withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Prop withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property string $unit
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereUnit($value)
|
||||
*/
|
||||
class Prop extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Quantity
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $product_id
|
||||
* @property int $count
|
||||
* @property int $price
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereCount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $data
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Plank\Metable\Meta[] $meta
|
||||
* @property-read int|null $meta_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity orderByMeta(string $key, string $direction = 'asc', bool $strict = false)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity orderByMetaNumeric(string $key, string $direction = 'asc', bool $strict = false)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereData($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereDoesntHaveMeta($key)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereHasMeta($key)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereHasMetaKeys(array $keys)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereMeta(string $key, $operator, $value = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereMetaIn(string $key, array $values)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereMetaNumeric(string $key, string $operator, $value)
|
||||
* @property int|null $image
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereImage($value)
|
||||
* @property-read \App\Models\Product $product
|
||||
*/
|
||||
class Quantity extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Question
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $body
|
||||
* @property int $customer_id
|
||||
* @property string|null $answer
|
||||
* @property int $product_id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereAnswer($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereBody($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int $status
|
||||
* @property-read \App\Models\Customer $customer
|
||||
* @property-read \App\Models\Product $product
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereStatus($value)
|
||||
*/
|
||||
class Question extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Setting
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $section
|
||||
* @property string $type
|
||||
* @property string $title
|
||||
* @property int $active
|
||||
* @property string $key
|
||||
* @property string|null $value
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereKey($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereSection($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereValue($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Setting extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Sms
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $text
|
||||
* @property string $ip_address
|
||||
* @property string $user
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereIpAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereUser($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $code
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereCode($value)
|
||||
* @property string $ip
|
||||
* @property string|null $mobile
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereIp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereMobile($value)
|
||||
*/
|
||||
class Sms extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Ticket
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $title
|
||||
* @property int $customer_id
|
||||
* @property string $body
|
||||
* @property string|null $answer
|
||||
* @property int|null $parent_id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property string|null $status
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereAnswer($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereBody($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereParentId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \App\Models\Customer $customer
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Ticket[] $subTickets
|
||||
* @property-read int|null $sub_tickets_count
|
||||
*/
|
||||
class Ticket extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\Transport
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property string|null $description
|
||||
* @property int $sort
|
||||
* @property int $is_default
|
||||
* @property int $price
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereIsDefault($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereSort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Transport extends \Eloquent {}
|
||||
}
|
||||
|
||||
namespace App\Models{
|
||||
/**
|
||||
* App\Models\User
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property \Illuminate\Support\Carbon|null $email_verified_at
|
||||
* @property string $password
|
||||
* @property string|null $remember_token
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property string|null $mobile
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Xmen\StarterKit\Models\AdminLog[] $logs
|
||||
* @property-read int|null $logs_count
|
||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
|
||||
* @property-read int|null $notifications_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Permission[] $permissions
|
||||
* @property-read int|null $permissions_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Xmen\StarterKit\Models\Post[] $posts
|
||||
* @property-read int|null $posts_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Role[] $roles
|
||||
* @property-read int|null $roles_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Sanctum\PersonalAccessToken[] $tokens
|
||||
* @property-read int|null $tokens_count
|
||||
* @method static \Database\Factories\UserFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User permission($permissions)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User role($roles, $guard = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereEmailVerifiedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereMobile($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User wherePassword($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends \Eloquent {}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class OrderCancelCron extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'order:cancel';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Cancel orders inactive';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$invs = Invoice::where('status','PENDING')
|
||||
->where('created_at','<' , Carbon::now()->subMinutes(20))->get();
|
||||
foreach ($invs as $inv){
|
||||
$inv->status = Invoice::CANCELED;
|
||||
$inv->save();
|
||||
}
|
||||
// file_put_contents('teest','');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
$schedule->command('order:cancel')->everyFiveMinutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PaymentCleaner extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'payment:clean';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clean Old and Failed Payments';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$date =now()->subDays(7)->endOfDay()->toDateTimeString();
|
||||
Payment::whereType('ONLINE')->whereStatus('PENDING')->where('created_at','<',$date)->delete();
|
||||
Payment::whereType('ONLINE')->whereStatus(Payment::FAIL)->where('created_at','<',$date)->delete();
|
||||
Payment::whereType('ONLINE')->whereStatus(Payment::CANCEL)->where('created_at','<',$date)->delete();
|
||||
Invoice::whereStatus(Invoice::FAILED)->where('created_at','<',$date)->delete();
|
||||
Invoice::whereStatus(Invoice::CANCELED)->where('created_at','<',$date)->delete();
|
||||
Invoice::whereStatus(Invoice::PENDING)->where('created_at','<',now()->subDays(14)->endOfDay()->toDateTimeString())->delete();
|
||||
$this->info('Old Invoice|Payment with Fail Status Cleaned.');
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
interface Payment
|
||||
{
|
||||
|
||||
/**
|
||||
* Register Payment Service Provider
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function registerService();
|
||||
|
||||
/**
|
||||
* Get Payment name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName(): string;
|
||||
|
||||
/**
|
||||
* Get payment type must be one of: ONLINE, CHEQUE, CARD, CASH, CASH_ON_DELIVERY
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getType(): string;
|
||||
|
||||
/**
|
||||
* Is Active To Show user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isActive(): bool;
|
||||
|
||||
/**
|
||||
* Gateway Logo
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getLogo();
|
||||
|
||||
/**
|
||||
* Request online payment
|
||||
*
|
||||
* @param int $amount transaction amount
|
||||
* @param string $callbackUrl a url that callback user after transaction
|
||||
* @param array $additionalData additional data to send back
|
||||
*
|
||||
* @return array request data like token and order id
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function request(int $amount, string $callbackUrl, array $additionalData = []): array;
|
||||
|
||||
/**
|
||||
* Redirect customer to bank payment page
|
||||
*/
|
||||
public function goToBank();
|
||||
|
||||
/**
|
||||
* Verify payment
|
||||
*
|
||||
* @return array successful payment have two keys: reference_id , card_number
|
||||
* @throws \Throwable if payment fail
|
||||
*/
|
||||
public function verify(): array;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
|
||||
interface PaymentStore
|
||||
{
|
||||
/**
|
||||
* Store payment request
|
||||
*
|
||||
* @param int $orderId Payment unique order id
|
||||
* @param null $token
|
||||
* @param string $type One of 'ONLINE', 'CHEQUE', 'CASH', 'CARD', 'CASH_ON_DELIVERY'
|
||||
*
|
||||
* @return \App\Models\Payment
|
||||
*/
|
||||
public function storePaymentRequest($orderId,$amount, $token = null, $type = 'ONLINE',$bank=null): \App\Models\Payment;
|
||||
|
||||
/**
|
||||
* Store success payment and update invoice status
|
||||
*
|
||||
* @param int $paymentId Payment unique order id
|
||||
* @param string|int $referenceId Transaction reference id
|
||||
* @param null $cardNumber
|
||||
*
|
||||
* @return \App\Models\Payment
|
||||
*/
|
||||
public function storeSuccessPayment($paymentId, $referenceId, $cardNumber = null): \App\Models\Payment;
|
||||
|
||||
/**
|
||||
* Store failed payment and update invoice status
|
||||
*
|
||||
* @param int $orderId Payment unique order id
|
||||
* @param null $message Fail reason text to store
|
||||
*
|
||||
* @return \App\Models\Payment
|
||||
*/
|
||||
public function storeFailPayment($orderId, $message = null): \App\Models\Payment;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class InvoiceCompleted
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Invoice
|
||||
*/
|
||||
public $invoice;
|
||||
|
||||
public function __construct(Invoice $invoice)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class InvoiceFailed
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Invoice
|
||||
*/
|
||||
public $invoice;
|
||||
/**
|
||||
* @var Payment
|
||||
*/
|
||||
public $payment;
|
||||
|
||||
public function __construct(Invoice $invoice,Payment $payment)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->payment = $payment;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class InvoiceSucceed
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Invoice
|
||||
*/
|
||||
public $invoice;
|
||||
/**
|
||||
* @var Payment
|
||||
*/
|
||||
public $payment;
|
||||
|
||||
public function __construct(Invoice $invoice,Payment $payment)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->payment = $payment;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,629 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Models\Cat;
|
||||
use App\Models\Product;
|
||||
use App\Models\Prop;
|
||||
use App\Models\Setting;
|
||||
use Xmen\StarterKit\Helpers\TDate;
|
||||
use Xmen\StarterKit\Models\Category;
|
||||
use Xmen\StarterKit\Models\Menu;
|
||||
use Xmen\StarterKit\Models\Post;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
function getSetting($key)
|
||||
{
|
||||
if (!\Schema::hasTable('settings')){
|
||||
return false;
|
||||
}
|
||||
$x = Setting::where('key', $key)->first();
|
||||
if ($x == null) {
|
||||
$a = new \stdClass();
|
||||
return '';
|
||||
}
|
||||
return $x->value;
|
||||
}
|
||||
function getSettingCategory($key)
|
||||
{
|
||||
$x = Setting::where('key', $key)->first();
|
||||
if ($x == null) {
|
||||
$a = new \stdClass();
|
||||
return '';
|
||||
}
|
||||
return Category::where('id',$x->value)->first();
|
||||
}
|
||||
function getSettingCat($key)
|
||||
{
|
||||
$x = Setting::where('key', $key)->first();
|
||||
if ($x == null) {
|
||||
$a = new \stdClass();
|
||||
return '';
|
||||
}
|
||||
return Cat::where('id',$x->value)->first();
|
||||
}
|
||||
|
||||
|
||||
function stockTypes()
|
||||
{
|
||||
return ["IN_STOCK" => __("In stock"), "OUT_STOCK" => __("Out stock"), "BACK_ORDER" => __("Back order")];
|
||||
}
|
||||
|
||||
function metaing($metaz)
|
||||
{
|
||||
$out = [];
|
||||
if ($metaz == null) {
|
||||
return $out;
|
||||
}
|
||||
foreach ($metaz as $k => $meta) {
|
||||
$out[$k] = $meta->value;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
function getPriceableMeta(Product $pro){
|
||||
$metas = $pro->getAllMeta()->toArray();
|
||||
if ( count($metas) == 0 ){
|
||||
return [];
|
||||
}
|
||||
$pricables = $pro->category->props()->where('priceable',1)->pluck('name')->toArray();
|
||||
$result = [];
|
||||
if (is_array($pricables)){
|
||||
foreach ($pricables as $price){
|
||||
if (isset($metas[$price])){
|
||||
$result[$price] = $metas[$price];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function showCats($cats = [], $liClass = '', $ulClass = '')
|
||||
{
|
||||
if ($cats == []) {
|
||||
$cats = Cat::whereNull('parent_id')->get();
|
||||
}
|
||||
$txt = '';
|
||||
foreach ($cats as $cat) {
|
||||
$txt .= '<li class="' . $liClass . '">
|
||||
<a href="' . route('cat', $cat->slug) . '">' . $cat->name . '</a>';
|
||||
if ($cat->children()->count() > 0) {
|
||||
// $txt .='<li> '.$cat->name;
|
||||
$txt .= '<ul class="' . $ulClass . '">';
|
||||
$txt .= showCats($cat->children, $liClass, $ulClass);
|
||||
$txt .= '</ul>';
|
||||
} else {
|
||||
|
||||
}
|
||||
$txt .= '</li>';
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
function showMenuMange($arr)
|
||||
{
|
||||
$back = '';
|
||||
foreach ($arr as $menu) {
|
||||
$ol = '';
|
||||
if ($menu->children()->count() > 0) {
|
||||
$ol = '<ol>' . showMenuMange($menu->children()->orderBy('sort')->get()) . '</ol>';
|
||||
}
|
||||
$back .= <<<LI
|
||||
<li class="list-group-item"
|
||||
data-menuabletype="$menu->menuable_type"
|
||||
data-menuableid="$menu->menuable_id"
|
||||
data-meta="$menu->meta"
|
||||
data-kind="$menu->kind"
|
||||
data-title="$menu->title"
|
||||
>
|
||||
<span>
|
||||
$menu->title
|
||||
</span>
|
||||
$ol
|
||||
</li>
|
||||
LI;
|
||||
}
|
||||
return $back;
|
||||
}
|
||||
|
||||
function showMenu($arr)
|
||||
{
|
||||
$back = '';
|
||||
foreach ($arr as $menu) {
|
||||
$ol = '';
|
||||
if ($menu->children()->count() > 0) {
|
||||
$ol = '<ol>' . showMenu($menu->children()->orderBy('sort')->get()) . '</ol>';
|
||||
}
|
||||
switch ($menu->kind) {
|
||||
case "empty":
|
||||
|
||||
$back .= <<<LI
|
||||
<li class="nav-item">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" >$menu->title</a>
|
||||
</li>
|
||||
$ol
|
||||
</li>
|
||||
LI;
|
||||
break;
|
||||
case "link":
|
||||
$back .= <<<LI
|
||||
<li class="nav-item">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="$menu->meta">$menu->title</a>
|
||||
</li>
|
||||
$ol
|
||||
</li>
|
||||
LI;
|
||||
break;
|
||||
case "news":
|
||||
|
||||
break;
|
||||
case "cat":
|
||||
|
||||
break;
|
||||
case "cat-sub":
|
||||
|
||||
break;
|
||||
case "cat-news":
|
||||
|
||||
break;
|
||||
case "tag":
|
||||
|
||||
break;
|
||||
case "tag-sub":
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
return $back;
|
||||
}
|
||||
|
||||
function showCatNode($arr)
|
||||
{
|
||||
$ret = '';
|
||||
foreach ($arr as $cat) {
|
||||
$ret .= "<li data-id='$cat->id' > $cat->name <ol> ";
|
||||
if ($cat->children()->count() > 0) {
|
||||
$ret .= showCatNode($cat->children);
|
||||
}
|
||||
$ret .= " </ol> </li> ";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function MenuShowItems($items)
|
||||
{
|
||||
$out = '';
|
||||
foreach ($items as $item) {
|
||||
$out .= '<li>';
|
||||
switch ($item->kind) {
|
||||
case "tag":
|
||||
$out .= '<a href="' . route('n.tag', $item->meta) . '" >' . $item->title . '</a>';
|
||||
break;
|
||||
case "link":
|
||||
$out .= '<a href="' . $item->meta . '" >' . $item->title . '</a>';
|
||||
break;
|
||||
case "news":
|
||||
$n = Post::whereId($item->menuable_id)->firstOrFail();
|
||||
$out .= '<a href="' . route('n.show', $n->slug) . '" >' . $item->title . '</a>';
|
||||
break;
|
||||
case "tag-sub":
|
||||
$out .= $item->title;
|
||||
$news = Post::withAnyTag($item->meta)->limit(10)->get(['title', 'slug']);
|
||||
$out .= '<ul>';
|
||||
foreach ($news as $new) {
|
||||
$out .= '<li><a href="' . route('n.show', $new->slug) . '" >' . $new->title . '</a></li>';
|
||||
}
|
||||
$out .= '</ul>';
|
||||
break;
|
||||
case "cat":
|
||||
$cat = Category::whereId($item->menuable_id)->firstOrFail();
|
||||
$out .= '<a href="' . route('n.cat', $cat->slug) . '" >' . $item->title . '</a>';
|
||||
break;
|
||||
case "cat-sub":
|
||||
$out .= $item->title;
|
||||
$cats = Category::where('parent_id', $item->menuable_id)->limit(20)->get(['name', 'slug']);
|
||||
$out .= '<ul>';
|
||||
foreach ($cats as $c) {
|
||||
$out .= '<li><a href="' . route('n.cat', $c->slug) . '" >' . $c->name . '</a></li>';
|
||||
}
|
||||
$out .= '</ul>';
|
||||
break;
|
||||
case "cat-news":
|
||||
$out .= '<a class="menu-link">'.$item->title .'</a>';
|
||||
$cat = Category::whereId($item->menuable_id)->firstOrFail();
|
||||
$news = $cat->posts()->limit(10)->get(['slug', 'title']);
|
||||
$out .= '<ul>';
|
||||
foreach ($news as $new) {
|
||||
$out .= '<li><a href="' . route('n.show', $new->slug) . '" >' . $new->title . '</a></li>';
|
||||
}
|
||||
$out .= '</ul>';
|
||||
break;
|
||||
default:
|
||||
$out .= $item->title;
|
||||
if ($item->children()->count() > 0) {
|
||||
$out .= '<ul>' . MenuShowItems($item->children) . '</ul>';
|
||||
}
|
||||
}
|
||||
$out .= '</li>';
|
||||
}
|
||||
$out .= '';
|
||||
return $out;
|
||||
}
|
||||
|
||||
function MenuShowByName($menu_name)
|
||||
{
|
||||
$menu = Menu::whereName($menu_name)->firstOrFail();
|
||||
return MenuShowItems($menu->menuItems()->whereNull('parent')->get());
|
||||
}
|
||||
|
||||
function lastCrump()
|
||||
{
|
||||
$routes = explode('.', Route::currentRouteName());
|
||||
if (count($routes) != 3) {
|
||||
echo '<li class="step">
|
||||
<a>
|
||||
<i class="fa fa-cube" ></i>
|
||||
' . __(ucfirst($routes[count($routes) - 1])) . '
|
||||
</a>
|
||||
</li>';
|
||||
return;
|
||||
}
|
||||
$route = $routes[count($routes) - 1];
|
||||
if ($route == 'home') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($route == 'all' || $route == 'index' || $route == 'list') {
|
||||
echo '<li class="step">
|
||||
<a>
|
||||
<i class="fa fa-list" ></i>
|
||||
' . __(ucfirst($routes[count($routes) - 2])) . '
|
||||
</a>
|
||||
</li>';
|
||||
} else {
|
||||
$link = '#';
|
||||
$temp = $routes;
|
||||
array_pop($temp);
|
||||
$temp = implode('.', $temp) . '.';
|
||||
if (Route::has($temp . 'index')) {
|
||||
$link = \route($temp . 'index');
|
||||
} elseif (Route::has($temp . 'all')) {
|
||||
$link = \route($temp . 'all');
|
||||
} elseif (Route::has($temp . 'list')) {
|
||||
$link = \route($temp . 'list');
|
||||
}
|
||||
echo '<li class="step">
|
||||
<a href="' . $link . '">
|
||||
<i class="fa fa-list" ></i>
|
||||
' . __(ucfirst($routes[count($routes) - 2])) . '
|
||||
</a>
|
||||
</li>';
|
||||
switch ($route) {
|
||||
case 'create':
|
||||
$title = __('Add') . ' ' . __($routes[count($routes) - 2]);
|
||||
$icon = 'fa fa-add';
|
||||
break;
|
||||
case 'edit':
|
||||
$title = __('Edit') . ' ' . __($routes[count($routes) - 2]);
|
||||
$icon = 'fa fa-edit';
|
||||
break;
|
||||
case 'show':
|
||||
$title = __('Show') . ' ' . __($routes[count($routes) - 2]);
|
||||
$icon = 'fa fa-eye';
|
||||
break;
|
||||
case 'sort':
|
||||
$title = __('Sort') . ' ' . __($routes[count($routes) - 2]);
|
||||
$icon = 'fa fa-sort';
|
||||
break;
|
||||
default:
|
||||
$title = __('') . ' ' . __(ucfirst($routes[count($routes) - 1]));
|
||||
$icon = 'fa fa-cube';
|
||||
break;
|
||||
}
|
||||
echo '<li class="step">
|
||||
<a>
|
||||
<i class="' . $icon . '" ></i>
|
||||
' . $title . '
|
||||
</a>
|
||||
</li>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getMainCats($limit = 10)
|
||||
{
|
||||
return Cat::whereNull('parent_id')->limit($limit)->get();
|
||||
}
|
||||
|
||||
function getProductByCat($id, $order = 'id', $orderMethod = 'desc', $limit = 10)
|
||||
{
|
||||
$cat = Cat::where('id', $id)->first();
|
||||
|
||||
if ($cat == null){
|
||||
return [];
|
||||
}
|
||||
return $cat->products()->where('active',1)
|
||||
->orderBy($order, $orderMethod)->limit($limit)->get();
|
||||
}
|
||||
function getProductByCatQ($id, $order = 'id', $limit = 10)
|
||||
{
|
||||
$cat = Cat::where('id', $id)->first();
|
||||
|
||||
if ($cat == null){
|
||||
return [];
|
||||
}
|
||||
return $cat->products()->where('active',1)->where('stock_quantity','>', 0)
|
||||
->orderByDesc('id')->limit($limit)->get();
|
||||
}
|
||||
|
||||
function getSubCats($id)
|
||||
{
|
||||
return Cat::where('parent_id', $id)->get();
|
||||
}
|
||||
|
||||
function getProducts($order = 'id', $orderMethod = 'desc', $limit = 10)
|
||||
{
|
||||
return Product::orderBy($order, $orderMethod)->limit($limit)->get();
|
||||
}
|
||||
|
||||
|
||||
function getProp($name)
|
||||
{
|
||||
return Prop::where('name', $name)->first();
|
||||
}
|
||||
|
||||
function getPropUnit($name)
|
||||
{
|
||||
if ( Prop::where('name', $name)->count() == 0) {
|
||||
return '';
|
||||
}
|
||||
return Prop::where('name', $name)->first()->unit;
|
||||
}
|
||||
|
||||
function getPropLabel($name)
|
||||
{
|
||||
if (Prop::where('name', $name)->count() == 0){
|
||||
return '';
|
||||
}
|
||||
$n = Prop::where('name', $name)->first();
|
||||
if ($n != null) {
|
||||
return Prop::where('name', $name)->first()->label;
|
||||
} else {
|
||||
if ($name == 'weight') {
|
||||
return __('weight');
|
||||
} else {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isJson($str)
|
||||
{
|
||||
$json = json_decode($str);
|
||||
return $json && $str != $json;
|
||||
}
|
||||
|
||||
function jsonOrder($json)
|
||||
{
|
||||
$data = json_decode( $json ,true);
|
||||
asort($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
function showMetaValue($key, $value){
|
||||
$p = Prop::whereName($key)->first();
|
||||
foreach (json_decode($p->options) as $n){
|
||||
if ($n->value == $value){
|
||||
return $n->title;
|
||||
}
|
||||
}
|
||||
}
|
||||
function showMeta($key, $value)
|
||||
{
|
||||
|
||||
if (Prop::whereName('warranty')->count()== 0 && $key == 'warranty'){
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($key == 'weight') {
|
||||
return $value . ' ' . __('Gram(s)');
|
||||
}
|
||||
if ($key == 'warranty') {
|
||||
$p = Prop::whereName('warranty')->first();
|
||||
foreach (json_decode($p->options) as $n){
|
||||
if ($n->value == $value){
|
||||
return $n->title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($key == 'color') {
|
||||
return '<div style="background: '.$value.';min-width: 15px; height:15px; display: inline-block; margin-right: 4px; margin-left: 4px" ></div><b style="position: relative;top: -3px;padding:2px;display: inline-block">'.getColorName($value).'</b>';
|
||||
}
|
||||
|
||||
$txt = $value;
|
||||
if (isJson($value)) {
|
||||
$txt = '';
|
||||
foreach (json_decode($value, true) as $item) {
|
||||
$txt .= '<div class="badge p-1 ps-2 pe-2 m-1 bg-primary mb-0" > ' . $item['title'] . ' </div>';
|
||||
}
|
||||
}
|
||||
return trim($txt . ' ' . getPropUnit($key));
|
||||
}
|
||||
|
||||
function time2persian($date, $format = 'Y/m/d')
|
||||
{
|
||||
$dt = new TDate();
|
||||
return $dt->PDate($format, $date);
|
||||
}
|
||||
|
||||
function getColors(){
|
||||
$colors = Prop::where('name','color')->first();
|
||||
if ($colors == null){
|
||||
return [];
|
||||
}
|
||||
$data = json_decode($colors->options,true);
|
||||
$result = [];
|
||||
foreach ($data as $color) {
|
||||
$result[$color['value']] = $color['title'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function getColorName($colorVal){
|
||||
$colors = Prop::where('name','color')->first();
|
||||
if ($colors == null){
|
||||
return 'رنگ';
|
||||
}
|
||||
$data = json_decode($colors->options,true);
|
||||
foreach ($data as $color) {
|
||||
if ($colorVal == $color['value']){
|
||||
return $color['title'];
|
||||
}
|
||||
}
|
||||
return 'رنگ';
|
||||
}
|
||||
|
||||
function makeChart($pro)
|
||||
{
|
||||
$times = $pro->prices_history()->pluck('created_at')->toArray();
|
||||
$dates = [];
|
||||
foreach (array_reverse($times) as $time) {
|
||||
$dates[] = \App\Helpers\time2persian($time->timestamp, 'd F Y');
|
||||
}
|
||||
$dts = json_encode($dates);
|
||||
|
||||
$prs = json_encode(array_reverse($pro->prices_history()->pluck('price')->toArray()));
|
||||
$text = <<<TXT
|
||||
<canvas id="canvas" style="display: block; height: 400px;" height="400" class="chartjs-render-monitor"></canvas>
|
||||
<input type="hidden" id="labels" value='$dts'>
|
||||
<input type="hidden" id="prices" value='$prs'>
|
||||
TXT;
|
||||
return $text;
|
||||
}
|
||||
|
||||
function makeProductBreadcrumb($p, $c)
|
||||
{
|
||||
$items = [
|
||||
[
|
||||
'name' => $c->name,
|
||||
'link' => \route('cat', $c->slug)
|
||||
]
|
||||
];
|
||||
while ($c->parent_id != null) {
|
||||
$c = Cat::where('id', $c->parent_id)->first();
|
||||
$items[] = [
|
||||
'name' => $c->name,
|
||||
'link' => \route('cat', $c->slug)
|
||||
];
|
||||
}
|
||||
|
||||
$items = array_reverse($items);
|
||||
$items[] = [
|
||||
'name' => $p->name,
|
||||
'link' => \route('product', $p->slug)
|
||||
];
|
||||
return $items;
|
||||
}
|
||||
|
||||
function showBreadcrumb($itemz = [])
|
||||
{
|
||||
$text = <<<DOC
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org/",
|
||||
"@type": "BreadcrumbList",
|
||||
"itemListElement": [
|
||||
ITEMS
|
||||
]
|
||||
}
|
||||
</script>
|
||||
DOC;
|
||||
$items = '{
|
||||
"@type": "ListItem",
|
||||
"position": 1,
|
||||
"name": "' . config('app.name') . '",
|
||||
"item": "' . route('welcome') . '"
|
||||
},';
|
||||
foreach ($itemz as $k => $item) {
|
||||
$items .= '{
|
||||
"@type": "ListItem",
|
||||
"position": ' . ($k + 2) . ',
|
||||
"name": "' . $item['name'] . '",
|
||||
"item": "' . $item['link'] . '"
|
||||
},';
|
||||
}
|
||||
$items = ltrim($items);
|
||||
echo str_replace('ITEMS', $items, $text);
|
||||
}
|
||||
|
||||
function cardCount(){
|
||||
return count(array_merge(unserialize(session('card', serialize([]))),unserialize(session('qcard', serialize([])))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sendSMSText($number,$content){
|
||||
|
||||
$url = 'http://rest.payamak-panel.com/api/SendSMS/SendSMS';
|
||||
|
||||
$options =array(
|
||||
'content-type' => 'application/x-www-form-urlencoded',
|
||||
'postman-token' => '3e37c158-2c35-75aa-1ae7-f76d90ebbe8f',
|
||||
'cache-control' => 'no-cache'
|
||||
);
|
||||
$fields_string = http_build_query(array(
|
||||
'username' => config('app.sms_user'),
|
||||
'password' => config('app.sms_pass'),
|
||||
'to' => $number,
|
||||
'from' =>config('app.sms_number'),
|
||||
'text' => $content,
|
||||
'isflash' => 'false'
|
||||
));
|
||||
|
||||
//open connection
|
||||
$ch = curl_init();
|
||||
|
||||
//set the url, number of POST vars, POST data
|
||||
curl_setopt($ch,CURLOPT_URL, $url);
|
||||
curl_setopt($ch,CURLOPT_POST, true);
|
||||
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
|
||||
|
||||
//So that curl_exec returns the contents of the cURL; rather than echoing it
|
||||
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
//execute post
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function remTitle($str){
|
||||
$re = '/<title>(.*?)<\/title>/m';
|
||||
return preg_replace($re,'',$str);
|
||||
}
|
||||
function showJsonByKey($json,$key){
|
||||
$x = json_decode($json);
|
||||
$x = json_decode($x->data,true);
|
||||
$items = json_decode(\App\Helpers\getProp('size')->options,true);
|
||||
foreach ($items as $item) {
|
||||
if ($x[$key] == $item['value']){
|
||||
return $item['title'];
|
||||
}
|
||||
}
|
||||
return 'x';
|
||||
}
|
||||
function findLink($html){
|
||||
|
||||
$url = preg_match('/<a href="(.+)">/', $html, $match);
|
||||
|
||||
if (!isset($match[1])){
|
||||
return null;
|
||||
}
|
||||
|
||||
return $match[1];
|
||||
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Models\Product;
|
||||
use Xmen\StarterKit\Models\Post;
|
||||
|
||||
class Seo
|
||||
{
|
||||
public static function post(Post $post)
|
||||
{
|
||||
$image = $post->getMedia()->count() > 0 ? $post->getMedia()->first()->getUrl('posts-image') : false;
|
||||
|
||||
\SEOMeta::setTitle($post->title);
|
||||
\SEOMeta::setDescription($post->subtitle ? $post->subtitle : false);
|
||||
\SEOMeta::setKeywords($post->tags->pluck('name'));
|
||||
|
||||
\OpenGraph::setDescription($post->subtitle);
|
||||
\OpenGraph::setTitle($post->title);
|
||||
// \OpenGraph::setUrl($post->url);
|
||||
\OpenGraph::addProperty('type', 'articles');
|
||||
\OpenGraph::addImage(\Storage::url($image));
|
||||
|
||||
\JsonLd::setType('article');
|
||||
\JsonLd::addValue(
|
||||
'mainEntityOfPage',
|
||||
[
|
||||
'type' => 'WebPage',
|
||||
// 'id' => $post->url,
|
||||
// 'url' => $post->url,
|
||||
'inLanguage' => config('app.locale'),
|
||||
'name' => $post->title,
|
||||
'datePublished' => $post->created_at,
|
||||
'dateModified' => $post->updated_at,
|
||||
'description' => $post->subtitle,
|
||||
]
|
||||
);
|
||||
\JsonLd::setTitle(\SEOMeta::getTitle());
|
||||
\JsonLd::addValue('headline', $post->title);
|
||||
\JsonLd::setDescription($post->subtitle);
|
||||
\JsonLd::addValue('articleSection', $post->categories->pluck('name')->implode('، '));
|
||||
\JsonLd::addValue(
|
||||
'author',
|
||||
[
|
||||
'type' => 'Person',
|
||||
'name' => $post->author->name,
|
||||
]
|
||||
);
|
||||
\JsonLd::addValue(
|
||||
'publisher',
|
||||
[
|
||||
'type' => 'organization',
|
||||
'name' => $post->author->name,
|
||||
'url' => config('app.url'),
|
||||
// 'logo' => [
|
||||
// 'type' => 'ImageObject',
|
||||
// 'url' => setting('site.logo'),
|
||||
// ],
|
||||
]
|
||||
);
|
||||
\JsonLd::addValue('datePublished', $post->created_at);
|
||||
\JsonLd::addValue('dateModified', $post->updated_at);
|
||||
\JsonLd::addImage(\Storage::url($image));
|
||||
}
|
||||
|
||||
public function product(Product $product)
|
||||
{
|
||||
$image = $product->getMedia()->count() > 0 ? $product->getMedia()->first()->getUrl('product-image') : false;
|
||||
|
||||
\SEOMeta::setTitle($product->title);
|
||||
\SEOMeta::setDescription($product->excerpt ? $product->excerpt : false);
|
||||
\SEOMeta::setKeywords($product->tags->pluck('name'));
|
||||
|
||||
\OpenGraph::setDescription($product->excerpt);
|
||||
\OpenGraph::setTitle($product->title);
|
||||
\OpenGraph::setUrl($product->url);
|
||||
\OpenGraph::addProperty('type', 'product');
|
||||
\OpenGraph::setProduct([
|
||||
'price:amount'=>$product->price,
|
||||
'price:currency'=>'IRR'
|
||||
]);
|
||||
\OpenGraph::addImage(\Storage::url($product->image));
|
||||
|
||||
\JsonLd::setType('Product');
|
||||
\JsonLd::addValue(
|
||||
'mainEntityOfPage',
|
||||
[
|
||||
'type' => 'WebPage',
|
||||
'id' => $product->url,
|
||||
'url' => $product->url,
|
||||
'inLanguage' => config('app.locale'),
|
||||
'name' => $product->name,
|
||||
'datePublished' => $product->created_at,
|
||||
'dateModified' => $product->updated_at,
|
||||
'description' => $product->excerpt,
|
||||
]
|
||||
);
|
||||
\JsonLd::addValue('name', $product->name);
|
||||
\JsonLd::setDescription($product->excerpt ? $product->excerpt : false);
|
||||
if ($product->price) {
|
||||
\JsonLd::addValue(
|
||||
'offers',
|
||||
[
|
||||
'type' => 'Offer',
|
||||
'price' => $product->price,
|
||||
'priceCurrency' => 'IRR',
|
||||
]
|
||||
);
|
||||
}
|
||||
\JsonLd::addValue(
|
||||
'provider',
|
||||
[
|
||||
'type' => 'organization',
|
||||
'name' => self::setting('site.name'),
|
||||
'url' => config('app.url'),
|
||||
'logo' => [
|
||||
'type' => 'ImageObject',
|
||||
'url' => self::setting('site.logo'),
|
||||
],
|
||||
]
|
||||
);
|
||||
\JsonLd::addValue('datePublished', $product->created_at);
|
||||
\JsonLd::addValue('dateModified', $product->updated_at);
|
||||
\JsonLd::addImage(\Storage::url($image));
|
||||
|
||||
}
|
||||
|
||||
public static function setting($key)
|
||||
{
|
||||
return $key;
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Attachment;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
|
||||
class AttachmentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$attaches = Attachment::orderBy('id','desc')->paginate(30);
|
||||
return view('admin.attachment',compact('attaches'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
\Validator::make($request->all(),[
|
||||
'title' => ['required','string','min:3'],
|
||||
'file' => ['required','mimes:pdf','max:10000']
|
||||
]);
|
||||
$a = new Attachment();
|
||||
$a->title = $request->title;
|
||||
$f = $request->file('file');
|
||||
$fname = date('Y-m-d').'.pdf';
|
||||
$f->storePubliclyAs('public/pdf/',$fname);
|
||||
$a->file = '/storage/pdf/' . $fname ;
|
||||
$a->save();
|
||||
logAdmin(__METHOD__,Attachment::class,$a->id);
|
||||
return redirect()->back()->with(['message' => __("Attached")]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Attachment $attachment)
|
||||
{
|
||||
//
|
||||
logAdmin(__METHOD__,Attachment::class,$attachment->id);
|
||||
|
||||
$x = explode('/',$attachment->file);
|
||||
\Storage::disk('local')->delete('public/pdf',$x[count($x)-1] );
|
||||
$attachment->delete();
|
||||
return redirect()->back()->with(['message' => __("Attachment removed")]);
|
||||
}
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\CatSaveRequest;
|
||||
use App\Models\Cat;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
use function Xmen\StarterKit\Helpers\logAdminBatch;
|
||||
|
||||
class CatController extends Controller
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
|
||||
public function createOrUpdate(Cat $cat, CatSaveRequest $request) {
|
||||
$cat->name = $request->input('name');
|
||||
$cat->slug = \StarterKit::slug($request->input('name'));
|
||||
$cat->description = $request->input('description');
|
||||
$cat->parent_id = $request->input('parent') == '' ? null : $request->input('parent');
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$cat->media()->delete();
|
||||
$cat->addMedia($request->file('image'))->toMediaCollection();
|
||||
}
|
||||
if ($request->hasFile('image2')) {
|
||||
$name = time().'.'.request()->image2->getClientOriginalExtension();
|
||||
$cat->image = $name;
|
||||
$request->file('image2')->storeAs('public/cats', $name);
|
||||
}
|
||||
$cat->save();
|
||||
return $cat;
|
||||
}
|
||||
|
||||
|
||||
public function bulk(Request $request) {
|
||||
|
||||
switch ($request->input('bulk')) {
|
||||
case 'delete':
|
||||
$msg = __('Categories deleted successfully');
|
||||
logAdminBatch(__METHOD__.'.'.$request->input('bulk'),Cat::class,$request->input('id'));
|
||||
Cat::destroy($request->input('id'));
|
||||
break;
|
||||
default:
|
||||
$msg = __('Unknown bulk action :' . $request->input('bulk'));
|
||||
}
|
||||
return redirect()->route('admin.cat.index')->with(['message' => $msg]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index() {
|
||||
//
|
||||
$cats = Cat::paginate(20);
|
||||
return view('admin.cat.catIndex', compact('cats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create() {
|
||||
//
|
||||
$cats = Cat::all();
|
||||
return view('admin.cat.catForm', compact('cats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(CatSaveRequest $request) {
|
||||
//
|
||||
$cat = new Cat();
|
||||
$cat = $this->createOrUpdate($cat, $request);
|
||||
logAdmin(__METHOD__,Cat::class,$cat->id);
|
||||
return redirect()->route('admin.cat.index')->with(['message' => __('Product category created successfully')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Cat $cat) {
|
||||
//
|
||||
$cats = Cat::where('id', '<>', $cat->id)->get();
|
||||
$ccat = $cat;
|
||||
return view('admin.cat.catForm', compact('ccat', 'cats'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(CatSaveRequest $request, Cat $cat) {
|
||||
//
|
||||
$this->createOrUpdate($cat, $request);
|
||||
logAdmin(__METHOD__,Cat::class,$cat->id);
|
||||
return redirect()->route('admin.cat.index')->with(['message' => __('Product category updated successfully')]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Cat $cat) {
|
||||
//
|
||||
logAdmin(__METHOD__,Cat::class,$cat->id);
|
||||
$cat->delete();
|
||||
return redirect()->route('admin.cat.index')->with(['message' => __('Product category deleted successfully')]);
|
||||
}
|
||||
|
||||
public function sort() {
|
||||
$cats = Cat::orderBy('sort')->whereNull('parent_id')->get();
|
||||
return view('admin.cat.catSort',compact('cats'));
|
||||
}
|
||||
|
||||
public function sortStore(Request $request) {
|
||||
$request->validate([
|
||||
'info' => 'required|json'
|
||||
]);
|
||||
$arr = json_decode($request->input('info'), true);
|
||||
$this->saveSort($arr[0]);
|
||||
logAdmin(__METHOD__, Cat::class, '0');
|
||||
if ($request->ajax()){
|
||||
return ["OK" => true, 'msg' => "Categories sort updated"];
|
||||
}
|
||||
return redirect()->back()
|
||||
->with(['message' => "Categories sort updated"]);
|
||||
}
|
||||
|
||||
public function saveSort($arr,$parent = null){
|
||||
foreach ($arr as $key => $value) {
|
||||
$cat = Cat::whereId($value['id'])->first();
|
||||
$cat->sort = $key;
|
||||
$cat->parent_id = $parent;
|
||||
$cat->save();
|
||||
if(isset($value['children']) && count($value['children'][0]) > 0){
|
||||
$this->saveSort($value['children'][0],$value['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
use function Xmen\StarterKit\Helpers\logAdminBatch;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$cons = Contact::latest()->paginate(20);
|
||||
return view('admin.contact.contacts',compact('cons'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Contact $con)
|
||||
{
|
||||
//
|
||||
return view('admin.contact.contact',compact('con'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Contact $con)
|
||||
{
|
||||
//
|
||||
logAdmin(__METHOD__,Contact::class,$con->id);
|
||||
$con->delete();
|
||||
return redirect()->route('admin.contact.index');
|
||||
}
|
||||
|
||||
public function reply(Contact $con, Request $request){
|
||||
$body = $request->bodya;
|
||||
|
||||
Mail::raw($body, function ($message) use ($con){
|
||||
|
||||
$message->from(\App\Helpers\getSetting('email'),config('app.name'));
|
||||
$message->to($con->email);
|
||||
$message->subject('reply:',config('app.name', 'Laravel') .' پاسخ تماس با ');
|
||||
});
|
||||
logAdmin(__METHOD__,Contact::class,$con->id);
|
||||
|
||||
return redirect()->back()->with(['message' => __('Your Email sent')]);
|
||||
}
|
||||
public function bulk(Request $request) {
|
||||
|
||||
switch ($request->input('bulk')) {
|
||||
case 'delete':
|
||||
$msg = __('Tickets deleted successfully');
|
||||
logAdminBatch(__METHOD__.'.'.$request->input('bulk'),Ticket::class,$request->input('id'));
|
||||
Contact::destroy($request->input('id'));
|
||||
break;
|
||||
default:
|
||||
$msg = __('Unknown bulk action :' . $request->input('bulk'));
|
||||
}
|
||||
return redirect()->route('admin.ticket.index')->with(['message' => $msg]);
|
||||
}
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\customerSaveRequest;
|
||||
use App\Http\Requests\customerUpdateRequest;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
use function Xmen\StarterKit\Helpers\logAdminBatch;
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
|
||||
public function createOrUpdate(Customer $customer, Request $request)
|
||||
{
|
||||
$customer->name = $request->input('name');
|
||||
$customer->address = $request->input('address');
|
||||
// $customer->address_alt = $request->input('address_alt');
|
||||
$customer->state = $request->input('state');
|
||||
$customer->credit = str_replace(',','',$request->input('credit'));
|
||||
$customer->city = $request->input('city');
|
||||
$customer->postal_code = $request->input('postal_code');
|
||||
if ($request->has('email')){
|
||||
$customer->email = $request->input('email');
|
||||
}
|
||||
$customer->mobile = $request->input('mobile');
|
||||
$customer->description = $request->input('description');
|
||||
|
||||
if (trim($request->input('password')) != '') {
|
||||
$customer->password = bcrypt($request->input('password'));
|
||||
}
|
||||
$customer->colleague = $request->has('colleague');
|
||||
$customer->save();
|
||||
return $customer;
|
||||
}
|
||||
|
||||
|
||||
public function bulk(Request $request)
|
||||
{
|
||||
|
||||
switch ($request->input('bulk')) {
|
||||
case 'delete':
|
||||
$msg = __('Customers deleted successfully');
|
||||
logAdminBatch(__METHOD__ . '.' . $request->input('bulk'), Customer::class, $request->input('id'));
|
||||
Customer::destroy($request->input('id'));
|
||||
break;
|
||||
default:
|
||||
$msg = __('Unknown bulk action :' . $request->input('bulk'));
|
||||
}
|
||||
return redirect()->route('admin.customer.index')->with(['message' => $msg]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
//
|
||||
$q = Customer::orderByDesc('id');
|
||||
if ($request->has('name') && strlen($request->input('name')) > 1 ){
|
||||
$q->where('name','LIKE', '%'.$request->name.'%');
|
||||
}
|
||||
if ($request->has('mobile') && strlen($request->input('mobile')) > 1 ){
|
||||
$q->where('mobile','LIKE', '%'.$request->mobile.'%');
|
||||
}
|
||||
|
||||
if ($request->has('colleague') ){
|
||||
$q->where('colleague',true);
|
||||
}
|
||||
|
||||
$customers = $q->paginate(20);
|
||||
return view('admin.customer.customerIndex', compact('customers'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
$customers = Customer::all();
|
||||
return view('admin.customer.customerForm', compact('customers'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(customerSaveRequest $request)
|
||||
{
|
||||
//
|
||||
$customer = new Customer();
|
||||
$customer = $this->createOrUpdate($customer, $request);
|
||||
logAdmin(__METHOD__, Customer::class, $customer->id);
|
||||
return redirect()->route('admin.customer.index')->with(['message' => __('Customer created successfully')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Customer $customer)
|
||||
{
|
||||
//
|
||||
return view('admin.customer.customerForm', compact('customer'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(customerUpdateRequest $request, Customer $customer)
|
||||
{
|
||||
//
|
||||
$this->createOrUpdate($customer, $request);
|
||||
logAdmin(__METHOD__, Customer::class, $customer->id);
|
||||
return redirect()->route('admin.customer.index')->with(['message' => __('Customer updated successfully')]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Customer $customer)
|
||||
{
|
||||
//
|
||||
logAdmin(__METHOD__, Customer::class, $customer->id);
|
||||
$customer->delete();
|
||||
return redirect()->route('admin.customer.index')->with(['message' => __('Customer deleted successfully')]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\DiscountRequest;
|
||||
use App\Models\Discount;
|
||||
use App\Models\Product;
|
||||
use App\Models\Question;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
use function Xmen\StarterKit\Helpers\logAdminBatch;
|
||||
|
||||
class DiscountController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function createOrUpdate(Discount $discount,DiscountRequest $request){
|
||||
if ($request->product_id != ''){
|
||||
$discount->product_id = $request->product_id;
|
||||
}
|
||||
$discount->amount = $request->amount;
|
||||
$discount->expire = date('Y-m-d',floor($request->expire/1000));
|
||||
$discount->code = $request->code;
|
||||
$discount->type = $request->type;
|
||||
$discount->save();
|
||||
return $discount;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$discounts = Discount::paginate(10);
|
||||
return view('admin.discount.discountIndex',compact('discounts'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
$products = Product::get(['id','name']);
|
||||
return view('admin.discount.discountForm',compact('products'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(DiscountRequest $request)
|
||||
{
|
||||
//
|
||||
$discount = new Discount();
|
||||
$discount = $this->createOrUpdate($discount, $request);
|
||||
logAdmin(__METHOD__, Discount::class, $discount->id);
|
||||
return redirect()->route('admin.discount.index')->with(['message' => __('Discount') . ' ' . __('created successfully')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Discount $discount)
|
||||
{
|
||||
//
|
||||
$products = Product::get(['id','name']);
|
||||
return view('admin.discount.discountForm',compact('products','discount'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(DiscountRequest $request, Discount $discount)
|
||||
{
|
||||
$discount = $this->createOrUpdate($discount, $request);
|
||||
logAdmin(__METHOD__, Discount::class, $discount->id);
|
||||
return redirect()->route('admin.discount.index')->with(['message' => __('Discount') . ' ' . __('updated successfully')]);
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Discount $discount)
|
||||
{
|
||||
//
|
||||
logAdmin(__METHOD__, Discount::class, $discount->id);
|
||||
$discount->delete();
|
||||
return redirect()->route('admin.discount.index')->with(['message' => __('Discount') . ' ' . __('deleted successfully')]);
|
||||
}
|
||||
|
||||
|
||||
public function bulk(Request $request)
|
||||
{
|
||||
|
||||
switch ($request->input('bulk')) {
|
||||
case 'delete':
|
||||
$msg = __('Product deleted successfully');
|
||||
logAdminBatch(__METHOD__ . '.' . $request->input('bulk'), Discount::class, $request->input('id'));
|
||||
Discount::destroy($request->input('id'));
|
||||
break;
|
||||
default:
|
||||
$msg = __('Unknown bulk action :' . $request->input('bulk'));
|
||||
}
|
||||
return redirect()->route('admin.discount.index')->with(['message' => $msg]);
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\WebsiteController;
|
||||
use App\Http\Requests\InvoiceSaveRequest;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Quantity;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
use function Xmen\StarterKit\Helpers\logAdminBatch;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function createOrUpdate(Invoice $invoice, InvoiceSaveRequest $request)
|
||||
{
|
||||
$invoice->customer_id = $request->input('customer_id');
|
||||
$invoice->status = $request->input('status');
|
||||
$invoice->tracking_code = $request->input('tracking_code');
|
||||
if ($invoice->status == Invoice::CANCELED) {
|
||||
// $this->remQ([$invoice->id]);
|
||||
}
|
||||
$invoice->save();
|
||||
foreach ($request->products_ids as $k => $products_id) {
|
||||
$invoice->products[$k]->pivot->update(['count' => $request->products_counts[$k]]);
|
||||
}
|
||||
|
||||
WebsiteController::resetStockStatus();
|
||||
WebsiteController::resetQuantity();
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
public function remQ($invoices)
|
||||
{
|
||||
foreach ($invoices as $id) {
|
||||
$inv = Invoice::whereId($id)->first();
|
||||
if ($inv->status != Invoice::CANCELED) {
|
||||
$pros = $inv->products()->withPivot(['quantity_id', 'count'])->get();
|
||||
foreach ($pros as $pr) {
|
||||
$q = Quantity::whereId($pr->pivot->quantity_id)->first();
|
||||
$q->count += $pr->pivot->count;
|
||||
$q->save();
|
||||
$q->product->stock_quantity += $pr->pivot->count;
|
||||
$q->product->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function bulk(Request $request)
|
||||
{
|
||||
|
||||
switch ($request->input('bulk')) {
|
||||
case 'delete':
|
||||
$msg = __('Invoices deleted successfully');
|
||||
logAdminBatch(__METHOD__ . '.' . $request->input('bulk'), Invoice::class, $request->input('id'));
|
||||
Invoice::destroy($request->input('id'));
|
||||
break;
|
||||
case 'PENDING':
|
||||
case 'PROCESSING':
|
||||
case 'COMPLETED':
|
||||
case 'CANCELED':
|
||||
case 'FAILED':
|
||||
$msg = __('Invoices status changed successfully');
|
||||
logAdminBatch(__METHOD__ . '.' . $request->input('bulk'), Invoice::class, $request->input('id'));
|
||||
Invoice::whereIn('id', $request->input('id'))->update(['status' => $request->input('bulk')]);
|
||||
// if ($request->input('bulk') == Invoice::CANCELED) {
|
||||
// $this->remQ($request->input('id'));
|
||||
// }
|
||||
break;
|
||||
default:
|
||||
$msg = __('Unknown bulk action :' . $request->input('bulk'));
|
||||
}
|
||||
return redirect()->route('admin.invoice.index')->with(['message' => $msg]);
|
||||
}
|
||||
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$n = Invoice::latest();
|
||||
if ($request->has('filter')) {
|
||||
$n = $n->where('status', $request->filter);
|
||||
}
|
||||
$invoices = $n->with('successPayments', 'payments')->paginate(20);
|
||||
return view('admin.invoice.invoiceIndex', compact('invoices'));
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('admin.invoice.invoiceForm');
|
||||
}
|
||||
|
||||
|
||||
public function store(InvoiceSaveRequest $request)
|
||||
{
|
||||
$invoice = new Invoice();
|
||||
$invoice = $this->createOrUpdate($invoice, $request);
|
||||
logAdmin(__METHOD__, Invoice::class, $invoice->id);
|
||||
return redirect()->route('admin.invoice.index')->with(['message' => __('invoice created successfully')]);
|
||||
}
|
||||
|
||||
|
||||
public function show(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
return view('admin.invoice.invoiceShow', compact('invoice'));
|
||||
}
|
||||
|
||||
|
||||
public function edit(Invoice $invoice)
|
||||
{
|
||||
$invoice = $invoice->load('customer', 'products')->refresh();
|
||||
return view('admin.invoice.invoiceForm', compact('invoice'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function update(InvoiceSaveRequest $request, Invoice $invoice)
|
||||
{
|
||||
$this->createOrUpdate($invoice, $request);
|
||||
logAdmin(__METHOD__, Invoice::class, $invoice->id);
|
||||
return redirect()->route('admin.invoice.index')->with(['message' => __('Product invoice updated successfully')]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function destroy(Invoice $invoice)
|
||||
{
|
||||
logAdmin(__METHOD__, Invoice::class, $invoice->id);
|
||||
$invoice->delete();
|
||||
return redirect()->route('admin.invoice.index')->with(['message' => __('Product invoice deleted successfully')]);
|
||||
}
|
||||
}
|
@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ProductSaveRequest;
|
||||
use App\Models\Cat;
|
||||
use App\Models\Discount;
|
||||
use App\Models\Product;
|
||||
use App\Models\Quantity;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Http\Request;
|
||||
use Xmen\StarterKit\Helpers\TDate;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
use function Xmen\StarterKit\Helpers\logAdminBatch;
|
||||
use const http\Client\Curl\VERSIONS;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
public function createOrUpdate(Product $product, ProductSaveRequest $request)
|
||||
{
|
||||
|
||||
|
||||
// $dt = new TDate();
|
||||
|
||||
$product->name = $request->input('name');
|
||||
$product->slug = \StarterKit::slug($request->input('name'));
|
||||
$product->description = $request->input('desc');
|
||||
$product->excerpt = $request->input('excerpt');
|
||||
$product->stock_status = $request->input('stock_status');
|
||||
if (!$request->has('quantity')) {
|
||||
$product->price = $request->input('price',0);
|
||||
$product->stock_quantity = $request->input('stock_quantity');
|
||||
}
|
||||
$product->virtual = $request->input('virtual', false);
|
||||
$product->average_rating = $request->input('average_rating', 0);
|
||||
$product->average_rating = $request->input('average_rating', 0);
|
||||
$product->rating_count = $request->input('rating_count', 0);
|
||||
$product->on_sale = $request->input('on_sale', 1);
|
||||
$product->sku = $request->input('sku', null);
|
||||
$product->downloadable = $request->input('downloadable', false);
|
||||
$product->cat_id = $request->input('cat_id');
|
||||
$product->image_index = $request->input('index_image',0);
|
||||
$product->user_id = auth()->id();
|
||||
$product->active = $request->has('active');
|
||||
|
||||
$product->save();
|
||||
|
||||
// $product->
|
||||
|
||||
|
||||
$product->retag(explode(',', $request->input('tags')));
|
||||
|
||||
$product->categories()->sync($request->input('cat'));
|
||||
|
||||
|
||||
if ($request->has('meta')) {
|
||||
// dd($request->input('meta'));
|
||||
$product->syncMeta($request->get('meta'));
|
||||
}
|
||||
|
||||
|
||||
// if ($request->hasFile('image')) {
|
||||
// $product->media()->delete();
|
||||
// $product->addMedia($request->file('image'))->toMediaCollection();
|
||||
// }
|
||||
|
||||
|
||||
foreach ($product->getMedia() as $media) {
|
||||
in_array($media->id, request('medias', [])) ?: $media->delete();
|
||||
}
|
||||
foreach ($request->file('image', []) as $image) {
|
||||
try {
|
||||
$product->addMedia($image)->toMediaCollection();
|
||||
} catch (FileDoesNotExist $e) {
|
||||
} catch (FileIsTooBig $e) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->has('quantity')) {
|
||||
|
||||
$qs = json_decode($request->input('quantity'), true);
|
||||
|
||||
|
||||
$product->quantities()->forceDelete();
|
||||
$counts = 0;
|
||||
foreach ($qs as $q) {
|
||||
$t = $q;
|
||||
$qn = new Quantity();
|
||||
$qn->product_id = $product->id;
|
||||
$qn->count = (int) $t['count'];
|
||||
$qn->price = (int) $t['price'];
|
||||
$qn->image = $t['image'];
|
||||
$qn->data = json_encode($t);
|
||||
$qn->save();
|
||||
$counts += $qn->count;
|
||||
// unset($t['count']);
|
||||
// unset($t['price']);
|
||||
// $qn->syncMeta($t);
|
||||
|
||||
}
|
||||
|
||||
$product->stock_quantity = $counts;
|
||||
$product->price =$product->quantities()->min('price');
|
||||
$product->save();
|
||||
}
|
||||
|
||||
if (trim($request->discount['amount']) != '' ){
|
||||
$discount = new Discount();
|
||||
$discount->product_id = $product->id;
|
||||
$discount->amount = $request->discount['amount'];
|
||||
$discount->expire = date('Y-m-d',floor($request->discount['expire']/1000));
|
||||
// $discount->code = $request->discount['code'];
|
||||
$discount->type = $request->discount['type'];
|
||||
$discount->save();
|
||||
}
|
||||
if (trim($request->discount['remove']) != '' ){
|
||||
Discount::whereIn('id',json_decode($request->discount['remove'],true))->delete();
|
||||
// Discount::destroy(json_encode($request->discount['remove'],true));
|
||||
}
|
||||
|
||||
|
||||
return $product;
|
||||
}
|
||||
|
||||
public function bulk(Request $request)
|
||||
{
|
||||
|
||||
switch ($request->input('bulk')) {
|
||||
case 'delete':
|
||||
$msg = __('Product deleted successfully');
|
||||
logAdminBatch(__METHOD__ . '.' . $request->input('bulk'), Product::class, $request->input('id'));
|
||||
Product::destroy($request->input('id'));
|
||||
break;
|
||||
case 'IN_STOCK':
|
||||
$msg = __('Product stock changed successfully');
|
||||
logAdminBatch(__METHOD__ . '.' . $request->input('bulk'), Product::class, $request->input('id'));
|
||||
Product::whereIn('id', $request->input('id'))->update(['stock_status' => 'IN_STOCK']);
|
||||
break;
|
||||
case 'OUT_STOCK':
|
||||
$msg = __('Product stock changed successfully');
|
||||
logAdminBatch(__METHOD__ . '.' . $request->input('bulk'), Product::class, $request->input('id'));
|
||||
Product::whereIn('id', $request->input('id'))->update(['stock_status' => 'OUT_STOCK']);
|
||||
break;
|
||||
case 'OUT_STOCK':
|
||||
$msg = __('Product stock changed successfully');
|
||||
logAdminBatch(__METHOD__ . '.' . $request->input('bulk'), Product::class, $request->input('id'));
|
||||
Product::whereIn('id', $request->input('id'))->update(['stock_status' => 'OUT_STOCK']);
|
||||
break;
|
||||
|
||||
default:
|
||||
$msg = __('Unknown bulk action :' . $request->input('bulk'));
|
||||
}
|
||||
return redirect()->route('admin.product.index')->with(['message' => $msg]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
//
|
||||
$n = Product::orderByDesc('id');
|
||||
if ($request->has('filter')) {
|
||||
if ($request->filter == 'TRASH'){
|
||||
$n = $n->onlyTrashed();
|
||||
}else{
|
||||
|
||||
$n = $n->where('stock_status', $request->filter);
|
||||
}
|
||||
}
|
||||
$products = $n->paginate(20);
|
||||
return view('admin.product.productIndex', compact('products'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
$cats = Cat::all();
|
||||
return view('admin.product.productForm', compact('cats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(ProductSaveRequest $request)
|
||||
{
|
||||
//
|
||||
|
||||
$product = new Product();
|
||||
$product = $this->createOrUpdate($product, $request);
|
||||
logAdmin(__METHOD__, Product::class, $product->id);
|
||||
if ($request->ajax()) {
|
||||
return ['OK' => true, 'url' => route('admin.product.index')];
|
||||
} else {
|
||||
return redirect()->route('admin.product.index')->with(['message' => $product->name . ' ' . __('created successfully')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Product $product)
|
||||
{
|
||||
//
|
||||
$cats = Cat::all();
|
||||
return view('admin.product.productForm', compact('cats', 'product'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(ProductSaveRequest $request, Product $product)
|
||||
{
|
||||
//
|
||||
|
||||
// return $request->all();
|
||||
// return $product;
|
||||
$this->createOrUpdate($product, $request);
|
||||
logAdmin(__METHOD__, Product::class, $product->id);
|
||||
if ($request->ajax()) {
|
||||
return ['OK' => true, 'msg' => $product->name . ' ' . __('updated successfully')];
|
||||
} else {
|
||||
return redirect()->route('admin.product.index')->with(['message' => $product->name . ' ' . __('updated successfully')]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Product $product)
|
||||
{
|
||||
//
|
||||
logAdmin(__METHOD__, Product::class, $product->id);
|
||||
$product->delete();
|
||||
return redirect()->route('admin.product.index')->with(['message' => __('Product deleted successfully')]);
|
||||
|
||||
}
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function restore($slug)
|
||||
{
|
||||
//
|
||||
$product = Product::withTrashed()->where('slug',$slug)->first();
|
||||
logAdmin(__METHOD__, Product::class, $product->id);
|
||||
$product->restore();
|
||||
return redirect()->back()->with(['message' => __('Product restore successfully')]);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\PropSaveRequest;
|
||||
use App\Models\Cat;
|
||||
use App\Models\Product;
|
||||
use App\Models\Prop;
|
||||
use http\Client\Curl\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PropController extends Controller
|
||||
{
|
||||
//
|
||||
public function __construct()
|
||||
{
|
||||
// \Auth::login(User::role('admin')->first());
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$props = Prop::orderBy('sort')->paginate(15);
|
||||
return view('admin.props.propIndex', compact('props'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$allCategories = Cat::all();
|
||||
return view('admin.props.propForm', compact('allCategories'));
|
||||
}
|
||||
|
||||
public function store(PropSaveRequest $req)
|
||||
{
|
||||
$item = new Prop();
|
||||
$id = $this->updateOrCreate($item, $req);
|
||||
return redirect()->route('admin.props.index', $id)->with('message', 'prop inserted');
|
||||
}
|
||||
|
||||
public function updateOrCreate(Prop $item, $req)
|
||||
{
|
||||
|
||||
// if ($req->file('file') != null && $req->input('type') == 'multilevel') {
|
||||
// $exl = $req->file('file')->getPathName();
|
||||
// $brands = [];
|
||||
// Excel::load($exl, function ($reader) use (&$item) {
|
||||
// $results = $reader->get();
|
||||
// $last = '';
|
||||
// foreach ($reader->all() as $index => $itemz) {
|
||||
// if ($last != $itemz['brand']) {
|
||||
// $last = $itemz['brand'];
|
||||
// $tmp['title'] = $last;
|
||||
// $tmp['children'] = [];
|
||||
// $brands[] = $tmp;
|
||||
// }
|
||||
// if ($itemz['model'] == null) {
|
||||
// continue;
|
||||
// }
|
||||
// $brands[count($brands)-1]['children'][] = $itemz['model'];
|
||||
// }
|
||||
// $item->options = json_encode($brands);
|
||||
// });
|
||||
// }
|
||||
$item->name = $req->input('name');
|
||||
$item->type = $req->input('type');
|
||||
$item->required = $req->input('required');
|
||||
$item->searchable = $req->input('searchable');
|
||||
$item->width = $req->input('width');
|
||||
$item->label = $req->input('label');
|
||||
$item->unit = $req->input('unit');
|
||||
$item->priceable = $req->has('priceable');
|
||||
$item->icon = $req->input('icon');
|
||||
|
||||
|
||||
$data = [];
|
||||
if (($req->has('options'))){
|
||||
|
||||
$tit = $req->input('options')['title'];
|
||||
$val = $req->input('options')['value'];
|
||||
foreach ($tit as $k => $v) {
|
||||
$data[] = ['title' => $v,'value' => $val[$k] ];
|
||||
}
|
||||
}
|
||||
$item->options = json_encode($data);
|
||||
$item->save();
|
||||
$item->category()->sync($req->input('category'));
|
||||
return $item->id;
|
||||
// $item->options = ;
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$p = Prop::whereId($id)->firstOrFail();
|
||||
$allCategories = Cat::all();
|
||||
$cats = $p->category()->pluck('id')->toArray();
|
||||
return view('admin.props.propForm', compact('p', 'allCategories','cats'));
|
||||
}
|
||||
|
||||
public function update($id, PropSaveRequest $req)
|
||||
{
|
||||
$item = Prop::whereId($id)->firstOrFail();
|
||||
$this->updateOrCreate($item, $req);
|
||||
return back()->with('message', 'prop update success');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Prop::whereId($id)->firstOrFail()->delete();
|
||||
return back();
|
||||
}
|
||||
|
||||
public function sort($catId)
|
||||
{
|
||||
$cat = Cat::findOrFail($catId);
|
||||
$props = $cat->props()->orderBy('sort')->select('type', 'label', 'name', 'id', 'sort')->get();
|
||||
return view('admin.props.propSort', compact('props', 'cat'));
|
||||
}
|
||||
|
||||
public function sortStore(Request $req)
|
||||
{
|
||||
if ($req->input('sort') == null || $req->input('sort') == '[]') {
|
||||
return back()->withErrors(['with no change']);
|
||||
}
|
||||
foreach (json_decode($req->input('sort'), true) as $i => $item) {
|
||||
Prop::findOrFail($item['id'])->update(['sort' => $i]);
|
||||
}
|
||||
return back()->with('success', ['update success']);
|
||||
}
|
||||
|
||||
public function list($id)
|
||||
{
|
||||
$cat = Cat::whereId($id)->firstOrFail();
|
||||
return [$cat,$cat->props()
|
||||
->orderBy('sort')->select('name', 'type', 'options', 'label', 'width', 'required', 'searchable','priceable')->get()];
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Question;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
|
||||
class QuestionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$qs = Question::orderBy('status')->orderBy('id','desc')->paginate(15);
|
||||
return view('admin.question',compact('qs'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Question $question)
|
||||
{
|
||||
//
|
||||
$question->answer = $request->answer;
|
||||
if (strlen($request->answer) > 2){
|
||||
$question->status = 1;
|
||||
}
|
||||
$question->save();
|
||||
logAdmin(__METHOD__, Question::class, $question->id);
|
||||
return redirect()->route('admin.question.index')->with(['message' => __('Question') . ' ' . __('updated successfully')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Question $question)
|
||||
{
|
||||
//
|
||||
logAdmin(__METHOD__,Question::class,$question->id);
|
||||
$question->delete();
|
||||
return redirect()->route('admin.question.index')->with(['message' => __('Question') . ' ' . __('deleted successfully')]);
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\SettingSaveRequest;
|
||||
use App\Models\Cat;
|
||||
use App\Models\Setting;
|
||||
use Conner\Tagging\Model\Tag;
|
||||
use Illuminate\Http\Request;
|
||||
use Xmen\StarterKit\Models\Category;
|
||||
use Xmen\StarterKit\Models\Post;
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index() {
|
||||
//
|
||||
// $settings = Setting::orderBy('section')->get();
|
||||
$settings = Setting::where('active', 1)->orderBy('section')->get(); //ESH// just active setting`s show
|
||||
$cats = Category::all();
|
||||
$pcats = Cat::all();
|
||||
return view('admin.setting', compact('settings', 'cats','pcats'));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Show the form for creating a new resource.
|
||||
// *
|
||||
// * @return \Illuminate\Http\Response
|
||||
// */
|
||||
// public function create()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(SettingSaveRequest $request) {
|
||||
//
|
||||
|
||||
$set = new Setting();
|
||||
$set->title = $request->title;
|
||||
$set->key = $request->key;
|
||||
$set->section = $request->section;
|
||||
$set->type = $request->type;
|
||||
$set->save();
|
||||
return redirect()->back()->with(['message' => __('Setting added to website')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id) {
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request) {
|
||||
//
|
||||
$all = $request->all();
|
||||
foreach ($all as $key => $val) {
|
||||
$set = Setting::where('key', $key)->first();
|
||||
if ($set != null && !$request->hasFile($key)) {
|
||||
$set->value = $val;
|
||||
$set->save();
|
||||
}
|
||||
}
|
||||
$files = $request->allFiles();
|
||||
if (isset($files['pic'])) {
|
||||
foreach ($files['pic'] as $index => $file) {
|
||||
// $name = time() . '.' . $file->getClientOriginalExtension();
|
||||
// Setting::where('key',$key)->update(['value' => $name]);
|
||||
// $request->file($index)->storeAs('public/setting', $name);
|
||||
$file->move(public_path('/images/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']);
|
||||
}
|
||||
}
|
||||
return redirect()->back()->with(['message' => __('Setting of website updated')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id) {
|
||||
//
|
||||
}
|
||||
|
||||
public function tagsearch($query) {
|
||||
$query = trim($query);
|
||||
return Tag::where('name', 'LIKE', "%$query%")->limit(5)->pluck('name')->toArray();
|
||||
}
|
||||
|
||||
public function postsearch($query) {
|
||||
$query = trim($query);
|
||||
return Post::where('title', 'LIKE', "%$query%")->limit(5)->get(['id', 'title'])->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Ticket;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
use function Xmen\StarterKit\Helpers\logAdminBatch;
|
||||
|
||||
class TicketController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
//
|
||||
$n = Ticket::latest()->whereNull('parent_id');
|
||||
if ($request->has('filter')) {
|
||||
$n = $n->where('status', $request->filter);
|
||||
}
|
||||
$tickets = $n->paginate(10);
|
||||
return view('admin.ticket.ticketIndex', compact('tickets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$t = new Ticket();
|
||||
if ($request->has('title')){
|
||||
$t->title = $request->title;
|
||||
}
|
||||
$t->body = $request->body;
|
||||
|
||||
$t->customer_id = $request->customer_id;
|
||||
$t->save();
|
||||
return redirect()->back()->with(['message' => __('Ticket has been sent')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Ticket $ticket)
|
||||
{
|
||||
//
|
||||
$subTickets = $ticket->subTickets;
|
||||
return view('admin.ticket.ticketForm',compact('ticket','subTickets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Ticket $ticket)
|
||||
{
|
||||
//
|
||||
$ticket->answer = $request->answer;
|
||||
$ticket->status = $request->status;
|
||||
$ticket->save();
|
||||
if ($request->has('answers')){
|
||||
foreach ($request->answers as $id => $answer) {
|
||||
Ticket::whereId($id)->update(['answer' => $answer]);
|
||||
}
|
||||
}
|
||||
logAdmin(__METHOD__,Ticket::class,$ticket->id);
|
||||
return redirect()->route('admin.ticket.index')->with(['message' => __('Ticket answered successfully')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function bulk(Request $request) {
|
||||
|
||||
switch ($request->input('bulk')) {
|
||||
case 'delete':
|
||||
$msg = __('Tickets deleted successfully');
|
||||
logAdminBatch(__METHOD__.'.'.$request->input('bulk'),Ticket::class,$request->input('id'));
|
||||
Ticket::destroy($request->input('id'));
|
||||
break;
|
||||
case 'PENDING':
|
||||
case 'CLOSED':
|
||||
case 'ANSWERED':
|
||||
$msg = __('Tickets status changed successfully');
|
||||
logAdminBatch(__METHOD__.'.'.$request->input('bulk'),Ticket::class,$request->input('id'));
|
||||
Ticket::whereIn('id', $request->input('id'))->update(['status' => $request->input('bulk')]);
|
||||
break;
|
||||
default:
|
||||
$msg = __('Unknown bulk action :' . $request->input('bulk'));
|
||||
}
|
||||
return redirect()->route('admin.ticket.index')->with(['message' => $msg]);
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\TransportSaveRequest;
|
||||
use App\Models\Transport;
|
||||
use Illuminate\Http\Request;
|
||||
use function Xmen\StarterKit\Helpers\logAdmin;
|
||||
use function Xmen\StarterKit\Helpers\logAdminBatch;
|
||||
class TransportController extends Controller
|
||||
{
|
||||
|
||||
function createOrUpdate(Transport $transport,TransportSaveRequest $request){
|
||||
$transport->price = $request->price;
|
||||
$transport->title = $request->title;
|
||||
$transport->description = $request->description;
|
||||
if ($request->has('is_default')){
|
||||
Transport::where('is_default')->update([
|
||||
'is_default' => 0,
|
||||
]);
|
||||
$transport->is_default = 1;
|
||||
}
|
||||
$transport->save();
|
||||
return $transport;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*z
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$transports = Transport::paginate(10);
|
||||
return view('admin.transport.transportIndex',compact('transports'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return view('admin.transport.transportForm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(TransportSaveRequest $request)
|
||||
{
|
||||
$transport = new Transport();
|
||||
$transport = $this->createOrUpdate($transport, $request);
|
||||
logAdmin(__METHOD__, Transport::class, $transport->id);
|
||||
return redirect()->route('admin.transport.index')->with(['message' => __('Transport') . ' ' . __('created successfully')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Transport $transport)
|
||||
{
|
||||
//
|
||||
return $transport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Transport $transport)
|
||||
{
|
||||
//
|
||||
return view('admin.transport.transportForm',compact('transport'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(TransportSaveRequest $request, Transport $transport)
|
||||
{
|
||||
//
|
||||
$transport = $this->createOrUpdate($transport, $request);
|
||||
logAdmin(__METHOD__, Transport::class, $transport->id);
|
||||
return redirect()->route('admin.transport.index')->with(['message' => __('Transport') . ' ' . __('updated successfully')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Transport $transport)
|
||||
{
|
||||
//
|
||||
logAdmin(__METHOD__, Transport::class, $transport->id);
|
||||
$transport->delete();
|
||||
return redirect()->route('admin.transport.index')->with(['message' => __('Transport') . ' ' . __('deleted successfully')]);
|
||||
}
|
||||
|
||||
public function bulk(Request $request) {
|
||||
|
||||
switch ($request->input('bulk')) {
|
||||
case 'delete':
|
||||
$msg = __('transports deleted successfully');
|
||||
logAdminBatch(__METHOD__.'.'.$request->input('bulk'),TransportController::class,$request->input('id'));
|
||||
TransportController::destroy($request->input('id'));
|
||||
break;
|
||||
default:
|
||||
$msg = __('Unknown bulk action :' . $request->input('bulk'));
|
||||
}
|
||||
return redirect()->route('admin.customer.index')->with(['message' => $msg]);
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AdminQuantityController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Attachment;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AttachmentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Attachment $attachment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Attachment $attachment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Attachment $attachment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Attachment $attachment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Attachment $attachment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Attachment $attachment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Attachment $attachment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Attachment $attachment)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
|
||||
class ConfirmPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confirm Password Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password confirmations and
|
||||
| uses a simple trait to include the behavior. You're free to explore
|
||||
| this trait and override any functions that require customization.
|
||||
|
|
||||
*/
|
||||
|
||||
use ConfirmsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users when the intended url fails.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
public function customerLogin(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:6'
|
||||
]);
|
||||
|
||||
if (Auth::guard('customer')
|
||||
->attempt(['email' => $request->email, 'password' => $request->password],
|
||||
$request->get('remember'))) {
|
||||
$redirect = (count(unserialize(session('card',serialize([])))) > 0) ? '/card':'/customer';
|
||||
return redirect()->intended($redirect);
|
||||
}
|
||||
return back()->withInput($request->only('email', 'remember'));
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\customerSaveRequest;
|
||||
use App\Models\Customer;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use function React\Promise\all;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
protected function createCustomer(customerSaveRequest $request)
|
||||
{
|
||||
|
||||
$customer = Customer::create([
|
||||
'name' => $request['name'],
|
||||
'email' => $request['email'],
|
||||
'mobile' => $request['mobile'],
|
||||
'address' => $request['address'],
|
||||
'postal_code' => $request['postal_code'],
|
||||
'state' => $request['state'],
|
||||
'city' => $request['city'],
|
||||
'password' => Hash::make($request['password']),
|
||||
]);
|
||||
Auth::guard('customer')
|
||||
->attempt(['email' => $request->email, 'password' => $request->password],
|
||||
$request->get('remember'));
|
||||
return redirect()->route('card.show');
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be re-sent if the user didn't receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Cat;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CatController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Cat $cat
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Cat $cat)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Cat $cat
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Cat $cat)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Cat $cat
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Cat $cat)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Cat $cat
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Cat $cat)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\AddressSaveRequest;
|
||||
use App\Http\Requests\TicketSaveRequest;
|
||||
use App\Models\Address;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Ticket;
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use chillerlan\Settings\SettingsContainerAbstract;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use PHPUnit\Util\Color;
|
||||
use PDF;
|
||||
|
||||
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
if(!\Auth::guard('customer')->check()){
|
||||
return redirect()->route('sign');
|
||||
}
|
||||
$customer = Customer::whereId(\Auth::guard('customer')->id())->firstOrFail();
|
||||
return view('website.customer',compact('customer'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Customer $customer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function invoice(Invoice $invoice){
|
||||
$options = new QROptions([
|
||||
'version' => 5,
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
// 'imageTransparent' => true,
|
||||
]);
|
||||
$qr = new QRCode($options);
|
||||
return view('website.invoice',compact('invoice','qr'));
|
||||
}
|
||||
|
||||
|
||||
public function qr($hash){
|
||||
$invoice = Invoice::where('hash',$hash)->firstOrFail();
|
||||
$options = new QROptions([
|
||||
'version' => 5,
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
// 'imageTransparent' => true,
|
||||
]);
|
||||
$qr = new QRCode($options);
|
||||
return view('website.qr',compact('invoice','qr'));
|
||||
}
|
||||
public function pdf($hash){
|
||||
$invoice = Invoice::where('hash',$hash)->firstOrFail();
|
||||
$options = new QROptions([
|
||||
'version' => 5,
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
// 'imageTransparent' => true,
|
||||
]);
|
||||
$qr = new QRCode($options);
|
||||
|
||||
$data = [
|
||||
'invoice' => $invoice,
|
||||
'qr' => $qr,
|
||||
];
|
||||
$pdf = PDF::loadView('website.pdf', $data);
|
||||
return $pdf->stream('website.pdf');
|
||||
|
||||
// $p = view('website.pdf',compact('invoice','qr'))->render();
|
||||
}
|
||||
|
||||
public function SendTicket(TicketSaveRequest $request){
|
||||
$t = new Ticket();
|
||||
if ($request->has('title')){
|
||||
$t->title = $request->title;
|
||||
}else{
|
||||
if (Ticket::whereId($request->parent_id)->firstOrFail()->customer_id != auth('customer')->id()){
|
||||
return abort(403);
|
||||
}else{
|
||||
$t->parent_id = $request->parent_id;
|
||||
}
|
||||
}
|
||||
$t->body = $request->body;
|
||||
$t->customer_id = auth('customer')->id();
|
||||
$t->save();
|
||||
return redirect()->back()->with(['message' => __('Ticket has been sent')]);
|
||||
}
|
||||
|
||||
public function ticket(Ticket $ticket){
|
||||
if ($ticket->customer_id != auth('customer')->id()){
|
||||
return abort(403);
|
||||
}
|
||||
return view('website.ticket',compact('ticket'));
|
||||
}
|
||||
|
||||
public function credit(Invoice $invoice){
|
||||
$c = Customer::whereId(auth('customer')->id())->first();
|
||||
if($c->credit == 0){
|
||||
return redirect()->back()->with(['error' => __("You don't have any credit")]);
|
||||
}
|
||||
if ($c->credit > $invoice->total_price){
|
||||
$invoice->credit_price = $invoice->total_price;
|
||||
$invoice->status = Invoice::COMPLETED;
|
||||
$c->credit = $c->credit - $invoice->total_price;
|
||||
}else{
|
||||
$invoice->credit_price = $c->credit ;
|
||||
$c->credit = 0;
|
||||
}
|
||||
$invoice->save();
|
||||
$c->save();
|
||||
$cr = new Credit();
|
||||
$cr->invoice_id = $invoice->id;
|
||||
$cr->customer_id = $c->id;
|
||||
$cr->amount = $invoice->credit_price;
|
||||
$cr->save();
|
||||
return redirect()->route('customer')->with(['message' => __('Credit applied')]);
|
||||
}
|
||||
|
||||
public function saveAddress(AddressSaveRequest $request){
|
||||
$ad = new Address();
|
||||
$ad->address = $request->address;
|
||||
$ad->customer_id = auth('customer')->id();
|
||||
$ad->state = $request->state;
|
||||
$ad->city = $request->city;
|
||||
$ad->data = '{}';
|
||||
$ad->save();
|
||||
return redirect()->route('customer')->with(['message' => __('Address saved')]);
|
||||
}
|
||||
|
||||
public function remAddress(Address $address){
|
||||
if ($address->customer_id == auth('customer')->id()){
|
||||
$address->delete();
|
||||
}
|
||||
return redirect()->route('customer')->with(['message' => __('Address removed')]);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Payment;
|
||||
|
||||
use App\Http\Controllers\WebsiteController;
|
||||
use App\Models\Discount;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Quantity;
|
||||
use App\Models\Product;
|
||||
use App\Models\Transport;
|
||||
use Illuminate\Http\Request;
|
||||
use function Ramsey\Collection\remove;
|
||||
|
||||
class GatewayRedirectController
|
||||
{
|
||||
public function __invoke(Invoice $invoice, $gateway)
|
||||
{
|
||||
if ($invoice->isCompleted()) {
|
||||
return redirect()->back()->with('message', __('Invoice payed.'));
|
||||
}
|
||||
|
||||
$callbackUrl = route('pay.check', ['invoice_hash' => $invoice->hash, 'gateway' => $gateway->getName()]);
|
||||
$payment = null;
|
||||
try {
|
||||
$response = $gateway->request( ($invoice->total_price - $invoice->credit_price), $callbackUrl);
|
||||
$payment = $invoice->storePaymentRequest($response['order_id'], ($invoice->total_price - $invoice->credit_price), $response['token'] ?? null, null, $gateway->getName());
|
||||
session(["payment_id" => $payment->id]);
|
||||
\Session::save();
|
||||
|
||||
return $gateway->goToBank();
|
||||
} catch (\Throwable $exception) {
|
||||
$invoice->status = 'FAILED';
|
||||
$invoice->save();
|
||||
\Log::error("Payment REQUEST exception: " . $exception->getMessage());
|
||||
\Log::warning($exception->getTraceAsString());
|
||||
$result = false;
|
||||
$message = __(' لطفا درگاه بانک را تعویض نمایید.');
|
||||
return view("payment.result", compact('invoice', 'payment', 'result', 'message'));
|
||||
}
|
||||
}
|
||||
|
||||
public function createInvoice(Request $request)
|
||||
{
|
||||
|
||||
if (\Session::has('shoping_card')){
|
||||
\Session::remove('shoping_card');
|
||||
\Session::save();
|
||||
}else{
|
||||
return redirect()->route('customer')->with(['message' => __('The order is duplicate please check invoices list')]);
|
||||
}
|
||||
$dis = Discount::where('code',\request('discount') );
|
||||
if ($dis->count() > 0){
|
||||
$invData['discount_id']= $dis->firstOrFail()->id;
|
||||
$discountAmount = $dis->firstOrFail()->amount;
|
||||
}
|
||||
$invoice = new Invoice();
|
||||
$invoice->total_price = 0;
|
||||
$invoice->reserve = $request->has('reserve');
|
||||
$invoice->desc = $request->desc ;
|
||||
$invoice->customer_id = auth('customer')->id();
|
||||
$invoice->hash = md5(time().config('app.name'));
|
||||
|
||||
if ($request->has('transport_id')){
|
||||
$invoice->transport_id = $request->transport_id ;
|
||||
}
|
||||
if ($request->has('address_id') && $request->address_id != '0'){
|
||||
$invoice->address_id = $request->address_id ;
|
||||
}else{
|
||||
|
||||
$invoice->address_id = null ;
|
||||
}
|
||||
if ($request->has('invoice_id')){
|
||||
$invoice->invoice_id = $request->invoice_id ;
|
||||
}
|
||||
|
||||
|
||||
// add by quantity
|
||||
foreach ($request->input('qcount',[]) as $id => $buyCount) {
|
||||
$q = Quantity::whereId($id)->first();
|
||||
|
||||
$product = $q->product;
|
||||
$product->sell_count += $buyCount;
|
||||
$product->stock_quantity -= $buyCount;
|
||||
$product->save();
|
||||
$proData = [
|
||||
'count' => $buyCount,
|
||||
'quantity_id' => $id,
|
||||
'price_total' => ($q->price * ($buyCount)),
|
||||
'data'=>json_encode($q),
|
||||
];
|
||||
$invoice->total_price += $proData['price_total'];
|
||||
$invoice->save();
|
||||
$invoice->products()->save(
|
||||
$product,
|
||||
$proData
|
||||
);
|
||||
$q->count -= $buyCount;
|
||||
$q->save();
|
||||
|
||||
}
|
||||
// add by product
|
||||
|
||||
foreach ($request->input('products',[]) as $item) {
|
||||
$product = Product::find($item);
|
||||
$product->sell_count += \request('count')[$item];
|
||||
$product->stock_quantity -= \request('count')[$item];
|
||||
$product->save();
|
||||
$proData = [
|
||||
'count' => \request('count')[$item],
|
||||
'price_total' => ($product->price * (\request('count')[$item]))
|
||||
];
|
||||
if (isset(\request('data')[$item])){
|
||||
$temp = json_decode(\request('data')[$item]);
|
||||
$qd = Quantity::find($temp->id);
|
||||
$qd->count -= \request('count')[$item];
|
||||
$proData['data'] = \request('data')[$item];
|
||||
$proData['price_total'] = $qd->price * \request('count')[$item];
|
||||
$proData['quantity_id'] = $qd->id;
|
||||
$product->price = $qd->price;
|
||||
$qd->save();
|
||||
}
|
||||
$invoice->save();
|
||||
$invoice->products()->save(
|
||||
$product,
|
||||
$proData
|
||||
);
|
||||
$invoice->total_price = $invoice->total_price + ($product->price * (\request('count')[$item]));
|
||||
$invoice->save();
|
||||
}
|
||||
// alternative address
|
||||
if ($request->has('address_alt')){
|
||||
$invoice->address_alt = $request->address_alt;
|
||||
}
|
||||
// fix problem
|
||||
if (!isset($discountAmount)){
|
||||
$discountAmount = 0;
|
||||
}
|
||||
$invoice->total_price = $invoice->total_price - $discountAmount;
|
||||
if ($request->has('transport_id')){
|
||||
$t = Transport::whereId($request->transport_id)->first();
|
||||
$invoice->total_price += $t->price;
|
||||
}
|
||||
// dd($invoice);
|
||||
// $invoice->update(['total_price' =>, 'hash' => ]);
|
||||
\Session::remove('card');
|
||||
\Session::remove('qcard');
|
||||
\Session::remove('qcounts');
|
||||
\Session::save();
|
||||
WebsiteController::resetQuantity();
|
||||
if ($request->has('nopay')){
|
||||
return redirect()->route('customer')->with(['message' => __('You order reserved for a few hours, please pay to complete process')]);
|
||||
}else{
|
||||
return $this->__invoke($invoice, app(config('app.pay_gate').'-gateway'));
|
||||
}
|
||||
}
|
||||
|
||||
function check($invoice,$gatway, Request $request){
|
||||
return [$invoice,$gatway,$request->all()];
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Payment;
|
||||
|
||||
use App\Contracts\Payment;
|
||||
use App\Models\Invoice;
|
||||
|
||||
class GatewayVerifyController
|
||||
{
|
||||
/**
|
||||
* @param Invoice $invoice
|
||||
* @param Payment $gateway
|
||||
*/
|
||||
public function __invoke($invoice_hash, $gateway)
|
||||
{
|
||||
try {
|
||||
$invoice = Invoice::whereHash($invoice_hash)->firstOrFail();
|
||||
$payment = null;
|
||||
$message = null;
|
||||
$result = true;
|
||||
$paymentId = self::getPayment($invoice);
|
||||
$response = $gateway->verify();
|
||||
$payment = $invoice->storeSuccessPayment($paymentId, $response['reference_id'], $response['card_number']);
|
||||
session(['card'=>serialize([])]);
|
||||
} catch (\Throwable $exception) {
|
||||
$result = false;
|
||||
$invoice->storeFailPayment($paymentId, $exception->getMessage());
|
||||
$message = $exception->getMessage();
|
||||
\Log::debug("Payment RESPONSE Fail For Gateway {$gateway->getName()} :" . $exception->getMessage() . " On Line {$exception->getLine()} Of File {$exception->getFile()}", ['request' => request()->all(), 'session' => request()->session()->all(), 'user' => request()->user(), 'payment_id' => $paymentId]);
|
||||
\Log::warning($exception->getTraceAsString());
|
||||
}
|
||||
|
||||
return view("payment.result",compact('invoice','payment','result','message'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Invoice $invoice
|
||||
* @return integer
|
||||
*/
|
||||
public static function getPayment($invoice)
|
||||
{
|
||||
$paymentId = session('payment_id');
|
||||
if (empty($paymentId)) {
|
||||
$paymentId = $invoice->payments->last()->id;
|
||||
}
|
||||
return $paymentId;
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Payment $payment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Payment $payment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Payment $payment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Payment $payment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Payment $payment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Payment $payment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Payment $payment
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Payment $payment)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Prop;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PropController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\Prop $prop
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Prop $prop)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Prop $prop
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Prop $prop)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\Prop $prop
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Prop $prop)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Prop $prop
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Prop $prop)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Cat;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Http\Request;
|
||||
use Xmen\StarterKit\Models\Post;
|
||||
|
||||
class SitemapController extends Controller
|
||||
{
|
||||
//
|
||||
public function index(){
|
||||
return response()->view('sitemap.main')->header('Content-Type', 'text/xml');
|
||||
}
|
||||
|
||||
public function products(){
|
||||
$items = Product::where('active',1)->orderByDesc('updated_at')->get();
|
||||
return view('sitemap.products',compact('items'));
|
||||
}
|
||||
public function cats(){
|
||||
$items = Cat::orderByDesc('updated_at')->get();
|
||||
return view('sitemap.cats',compact('items'));
|
||||
}
|
||||
public function posts(){
|
||||
$items = Post::where('status',1)->orderByDesc('updated_at')->get();
|
||||
return view('sitemap.posts',compact('items'));
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TransportController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
@ -0,0 +1,673 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\CommentClientRequest;
|
||||
use App\Http\Requests\ContactSaveRequest;
|
||||
use App\Http\Requests\customerUpdateRequest;
|
||||
use App\Http\Requests\ProfileCustomerRequest;
|
||||
use App\Http\Requests\QuestionClientRequest;
|
||||
use App\Models\Attachment;
|
||||
use App\Models\Cat;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Discount;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Product;
|
||||
use App\Models\Quantity;
|
||||
use App\Models\Question;
|
||||
use App\Models\Sms;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mpdf\Tag\P;
|
||||
use Spatie\MediaLibrary\Conversions\ImageGenerators\Video;
|
||||
use Xmen\StarterKit\Controllers\Admin\LogController;
|
||||
use Xmen\StarterKit\Models\Adv;
|
||||
use Xmen\StarterKit\Models\Category;
|
||||
use Xmen\StarterKit\Models\Clip;
|
||||
use Xmen\StarterKit\Models\Comment;
|
||||
use Xmen\StarterKit\Models\Gallery;
|
||||
use Xmen\StarterKit\Models\Poll;
|
||||
use Xmen\StarterKit\Models\Post;
|
||||
use Xmen\StarterKit\Models\Slider;
|
||||
use Xmen\StarterKit\Requests\CommentSaveRequest;
|
||||
use function App\Helpers\getColors;
|
||||
use function App\Helpers\getSetting;
|
||||
use function App\Helpers\sendSMSText;
|
||||
use function Xmen\StarterKit\Helpers\gLog;
|
||||
|
||||
|
||||
class WebsiteController extends Controller
|
||||
{
|
||||
|
||||
private $sort = 'id';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (getSetting('sort') == 'yes') {
|
||||
$this->sort = 'stock_quantity';
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
|
||||
if (!auth()->check() && \App\Helpers\getSetting('under') == 1) {
|
||||
return redirect('/under/index.php');
|
||||
}
|
||||
$cats = Cat::whereNull('parent_id')->limit(6)->get();
|
||||
$sliders = Slider::whereActive(true)->limit(5)->get();
|
||||
$vid = Clip::latest()->where('active', 1)->first();
|
||||
|
||||
return view('website.index', compact('cats', 'sliders', 'vid'));
|
||||
}
|
||||
|
||||
public function cat(Cat $cat, Request $request)
|
||||
{
|
||||
|
||||
$q = $cat->products()->where('active', 1)
|
||||
->orderByRaw("FIELD(stock_status, \"IN_STOCK\", \"BACK_ORDER\", \"OUT_STOCK\")")
|
||||
->orderByDesc($this->sort)->orderByDesc('id');
|
||||
if ($request->has('ext')) {
|
||||
$q = $q->where('stock_status', 'IN_STOCK')
|
||||
->where('stock_quantity','>',0);
|
||||
}
|
||||
if ($request->has('from')) {
|
||||
$q = $q->where('price', '>=', $request->input('from'));
|
||||
}
|
||||
if ($request->has('to')) {
|
||||
$q = $q->where('price', '<=', $request->input('to'));
|
||||
}
|
||||
if ($request->has('sort')) {
|
||||
switch ($request->input('sort')) {
|
||||
case "fav":
|
||||
$q = $q->orderByDesc('average_rating');
|
||||
break;
|
||||
case "cheap":
|
||||
$q = $q->orderBy('price');
|
||||
break;
|
||||
case "new":
|
||||
$q = $q->orderByDesc('id');
|
||||
break;
|
||||
case "expensive":
|
||||
$q = $q->orderByDesc('price');
|
||||
break;
|
||||
default:
|
||||
$q = $q->orderByDesc('sell_count');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$q = $q->orderByDesc('sell_count');
|
||||
}
|
||||
if (isset($request->meta) && isset($request->meta['material'])){
|
||||
// dd(array_column(json_decode($request->meta['material'],true),'value'));
|
||||
if (count(json_decode($request->meta['material'],true) ) > 0){
|
||||
$q->whereMetaIn('material',array_column(json_decode($request->meta['material'],true),'value'));
|
||||
}
|
||||
}
|
||||
if (isset($request->meta) && isset($request->meta['size'])) {
|
||||
$id = Quantity::where('count','>',0)
|
||||
->where('data','LIKE','%"size":"'.$request->meta['size'].'"%')
|
||||
->pluck('product_id')->toArray();
|
||||
$q->whereIn('id',$id);
|
||||
}
|
||||
if (isset($request->meta) && isset($request->meta['color'])) {
|
||||
$id = Quantity::where('count','>',0)
|
||||
->where('data','LIKE','%"color":"'.$request->meta['color'].'"%')
|
||||
->pluck('product_id')->toArray();
|
||||
$q->whereIn('id',$id);
|
||||
}
|
||||
|
||||
$products = $q->paginate(16);
|
||||
return view('website.cat', compact('cat', 'products'));
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
$sld = Slider::inRandomOrder()->first();
|
||||
$products = Product::orderByDesc($this->sort)
|
||||
->orderByDesc('id')->paginate(16);
|
||||
return view('website.products', compact('products', 'sld'));
|
||||
}
|
||||
|
||||
public function product($pro)
|
||||
{
|
||||
|
||||
if (is_numeric($pro)){
|
||||
$pro = Product::whereId($pro)->first();
|
||||
if ($pro == null){
|
||||
$pro = Product::inRandomOrder()->limit(1)->first();
|
||||
}
|
||||
|
||||
return redirect()->route('product',$pro->slug);
|
||||
|
||||
}else{
|
||||
$pro = Product::whereSlug($pro)->first();
|
||||
}
|
||||
|
||||
$cat = $pro->category;
|
||||
// $p = Product::first()->;
|
||||
$pro->increment('view_count');
|
||||
|
||||
$comments = $pro->approved_comments()->paginate(10);
|
||||
return view('website.product', compact('pro', 'cat', 'comments'));
|
||||
}
|
||||
|
||||
public function searchAjax(Request $request)
|
||||
{
|
||||
if (!$request->has('q') || mb_strlen(trim($request->q)) < 3) {
|
||||
$msg = __('Invalid search');
|
||||
return ['OK' => false, 'err' => $msg];
|
||||
}
|
||||
$q = trim($request->q);
|
||||
|
||||
$products = Product::where(function ($query) use ($q) {
|
||||
$query->where('name', 'LIKE', '%' . $q . '%')
|
||||
->orWhere('description', 'LIKE', '%' . $q . '%');
|
||||
})->where('active', 1)
|
||||
->orderByDesc('stock_quantity')->limit(3)->get();
|
||||
|
||||
$pros = [];
|
||||
foreach ($products as $product) {
|
||||
$pros[] = [
|
||||
'name' => $product->name,
|
||||
'link' => route('product', $product->slug),
|
||||
'image' => $product->thumbUrl(),
|
||||
'price' => $product->stock_quantity == 0 ? 'ناموجود' : $product->getPrice(),
|
||||
];
|
||||
}
|
||||
return ['OK' => true, 'data' => $pros];
|
||||
}
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
if (!$request->has('q') || mb_strlen(trim($request->q)) < 3) {
|
||||
|
||||
$msg = __('Invalid search');
|
||||
$title = __('Search for') . ' :';
|
||||
return view('website.products', compact('msg', 'title'));
|
||||
}
|
||||
$q = trim($request->q);
|
||||
$title = __('Search for') . ' :' . $q;
|
||||
|
||||
$products = Product::where(function ($query) use ($q) {
|
||||
$query->where('name', 'LIKE', '%' . $q . '%')
|
||||
->orWhere('description', 'LIKE', '%' . $q . '%');
|
||||
})->orderByDesc('stock_quantity')->where('active', 1)
|
||||
->paginate(16);
|
||||
|
||||
$posts = Post::where(function ($query) use ($q) {
|
||||
$query->where('title', 'LIKE', '%' . $q . '%')
|
||||
->orWhere('body', 'LIKE', '%' . $q . '%');
|
||||
})->where('status', 1)->paginate(16);
|
||||
|
||||
|
||||
return view('website.products', compact('products', 'title', 'posts'));
|
||||
}
|
||||
|
||||
public function post(Post $post)
|
||||
{
|
||||
$comments = $post->comments()->paginate(15);
|
||||
$sld = Slider::inRandomOrder()->first();
|
||||
return view('website.post', compact('post', 'comments', 'sld'));
|
||||
}
|
||||
|
||||
public function gallery(Gallery $gallery)
|
||||
{
|
||||
$title = $gallery->title;
|
||||
$subtitle = __('Gallery');
|
||||
return view('website.gallery', compact('gallery', 'title', 'subtitle'));
|
||||
}
|
||||
|
||||
|
||||
public function galleries()
|
||||
{
|
||||
$title = __('Galleries list');
|
||||
$subtitle = __('Galleries');
|
||||
$galleries = Gallery::where('status', 1)->paginate(16);
|
||||
return view('website.galleries', compact('galleries', 'title', 'subtitle'));
|
||||
}
|
||||
|
||||
public function clips()
|
||||
{
|
||||
$title = __('Pediatric dental clips');
|
||||
$subtitle = __('Clips');
|
||||
$clips = Clip::where('active', 1)->paginate(16);
|
||||
return view('website.clips', compact('clips', 'title', 'subtitle'));
|
||||
}
|
||||
|
||||
|
||||
public function tag($tag)
|
||||
{
|
||||
$title = __('Tag') . ' ' . $tag;
|
||||
$subtitle = __('Tagged by') . ' ' . $tag;
|
||||
$posts = Post::withAnyTag($tag)->paginate();
|
||||
return view('website.posts', compact('posts', 'tag', 'title', 'subtitle'));
|
||||
}
|
||||
|
||||
public function category(Category $category)
|
||||
{
|
||||
$title = __('Category') . ' ' . $category->name;
|
||||
$subtitle = __('Category') . ' ' . $category->name;
|
||||
$posts = $category->posts()->where('status', 1)->paginate(10);
|
||||
return view('website.posts', compact('posts', 'title', 'subtitle'));
|
||||
}
|
||||
|
||||
public function posts()
|
||||
{
|
||||
$title = __('All posts');
|
||||
$subtitle = '';
|
||||
$posts = Post::where('status', 1)
|
||||
->orderByDesc('id')->paginate(10);
|
||||
return view('website.posts', compact('posts', 'title', 'subtitle'));
|
||||
}
|
||||
|
||||
|
||||
public function like(Post $news, Request $request)
|
||||
{
|
||||
|
||||
if (!gLog(Post::class, $news->id, 'like', $request)) {
|
||||
return ['OK' => false, 'msg' => __("You liked ago ") . $news->title];
|
||||
}
|
||||
|
||||
if ($request->input('action') == 1) {
|
||||
$news->increment('like');
|
||||
return ['OK' => true, 'msg' => __("You liked ") . $news->title];
|
||||
} else {
|
||||
$news->increment('dislike');
|
||||
return ['OK' => true, 'msg' => __("You disliked ") . $news->title];
|
||||
}
|
||||
}
|
||||
|
||||
public function vote(Poll $poll, Request $request)
|
||||
{
|
||||
|
||||
if (!gLog(Poll::class, $poll->id, 'vote', $request)) {
|
||||
return redirect()->back()->with(['message' => __("You voted ago ") . $poll->title]);
|
||||
}
|
||||
|
||||
|
||||
$poll->opinions()->where('id', $request->input('poll' . $poll->id))
|
||||
->increment('vote');
|
||||
return redirect()->route('n.poll', $poll->slug)
|
||||
->with(['message' => __("You voted right now ") . $poll->title]);
|
||||
|
||||
}
|
||||
|
||||
public function poll(Poll $poll, Request $request)
|
||||
{
|
||||
$count = $poll->opinions()->sum('vote');
|
||||
$canVote = gLog(Poll::class, $poll->id, 'vote', $request, false);
|
||||
return view('website.poll', compact('poll', 'count', 'canVote'));
|
||||
}
|
||||
|
||||
|
||||
public function commentPost(Post $post, CommentClientRequest $request)
|
||||
{
|
||||
|
||||
// return $news;
|
||||
// return $request->all();
|
||||
$data = [
|
||||
'email' => $request->email,
|
||||
'body' => $request->body,
|
||||
'name' => $request->name,
|
||||
'ip' => $request->ip()
|
||||
];
|
||||
// if ($request->has('parent') && $request->parent != null) {
|
||||
// $data['sub_comment_id'] = $request->parent;
|
||||
// }
|
||||
// $news->comments()->create(
|
||||
// $data
|
||||
// );
|
||||
|
||||
|
||||
// return $news;
|
||||
$comment = new Comment();
|
||||
$comment->commentable_id = $post->id;
|
||||
$comment->commentable_type = 'Xmen\StarterKit\Models\Post';
|
||||
$comment->email = $request->email;
|
||||
$comment->body = $request->body;
|
||||
$comment->name = $request->name;
|
||||
$comment->ip = $request->ip();
|
||||
|
||||
if ($request->has('parent') && $request->parent != null) {
|
||||
// $data['sub_comment_id'] = $request->parent;
|
||||
$comment->sub_comment_id = $request->parent;
|
||||
}
|
||||
|
||||
$comment->save();
|
||||
|
||||
return redirect()->route('post', $post->slug . '#comment-form')->with(['message' => __('Your comment submited successfully, After approve will be visbile.')]);
|
||||
|
||||
}
|
||||
|
||||
public function commentProduct(Product $product, CommentClientRequest $request)
|
||||
{
|
||||
|
||||
// return $news;
|
||||
// return $request->all();
|
||||
$data = [
|
||||
'email' => $request->email,
|
||||
'body' => $request->body,
|
||||
'name' => $request->name,
|
||||
'ip' => $request->ip()
|
||||
];
|
||||
// if ($request->has('parent') && $request->parent != null) {
|
||||
// $data['sub_comment_id'] = $request->parent;
|
||||
// }
|
||||
// $news->comments()->create(
|
||||
// $data
|
||||
// );
|
||||
|
||||
|
||||
// return $news;
|
||||
$comment = new Comment();
|
||||
$comment->commentable_id = $product->id;
|
||||
$comment->commentable_type = 'App\Models\Product';
|
||||
$comment->email = $request->email;
|
||||
$comment->body = $request->body;
|
||||
$comment->name = $request->name;
|
||||
$comment->ip = $request->ip();
|
||||
|
||||
if ($request->has('parent') && $request->parent != null) {
|
||||
// $data['sub_comment_id'] = $request->parent;
|
||||
$comment->sub_comment_id = $request->parent;
|
||||
}
|
||||
|
||||
$comment->save();
|
||||
|
||||
return redirect()->route('product', $product->slug . '#comment-form')->with(['message' => __('Your comment submited successfully, After approve will be visbile.')]);
|
||||
|
||||
}
|
||||
|
||||
public function goadv(Adv $adv)
|
||||
{
|
||||
$adv->increment('click');
|
||||
if ($adv->max_click != 0 && $adv->max_click < $adv->click) {
|
||||
$adv->update(['active' => false]);
|
||||
}
|
||||
return redirect($adv->link);
|
||||
}
|
||||
|
||||
public function compare()
|
||||
{
|
||||
$arr = unserialize(session('to_compare', serialize([])));
|
||||
$pros = Product::whereIn('id', $arr)->get();
|
||||
return view('website.compare', compact('pros'));
|
||||
}
|
||||
|
||||
public function compareAdd(Product $pro)
|
||||
{
|
||||
$arr = unserialize(session('to_compare', serialize([])));
|
||||
if (!in_array($pro->id, $arr)) {
|
||||
$arr[] = $pro->id;
|
||||
session(['to_compare' => serialize($arr)]);
|
||||
}
|
||||
$pros = Product::whereIn('id', $arr)->get();
|
||||
return view('website.compare', compact('pros'));
|
||||
}
|
||||
|
||||
public function compareRem(Product $pro)
|
||||
{
|
||||
$arr = unserialize(session('to_compare', serialize([])));
|
||||
if (in_array($pro->id, $arr)) {
|
||||
unset($arr[array_search($pro->id, $arr)]);
|
||||
session(['to_compare' => serialize($arr)]);
|
||||
}
|
||||
return redirect()->route('compare');
|
||||
}
|
||||
|
||||
public function cardAdd($id)
|
||||
{
|
||||
$arr = unserialize(session('card', serialize([])));
|
||||
$arr2 = unserialize(session('qcard', serialize([])));
|
||||
if (!in_array($id, $arr)) {
|
||||
$arr[] = $id;
|
||||
session(['card' => serialize($arr)]);
|
||||
}
|
||||
return ['OK' => true, 'msg' => __('Added to card'), 'data' => count(array_merge($arr, $arr2))];
|
||||
}
|
||||
|
||||
public function cardAddQ($id, $count)
|
||||
{
|
||||
$arr = unserialize(session('qcard', serialize([])));
|
||||
$counts = unserialize(session('qcounts', serialize([])));
|
||||
$arr2 = unserialize(session('card', serialize([])));
|
||||
if (!in_array($id, $arr)) {
|
||||
$arr[] = $id;
|
||||
$counts[] = $count;
|
||||
session(['qcard' => serialize($arr)]);
|
||||
session(['qcounts' => serialize($counts)]);
|
||||
}
|
||||
return ['OK' => true, 'msg' => __('Added to card'), 'data' => count(array_merge($arr, $arr2))];
|
||||
}
|
||||
|
||||
public function cardRem($id)
|
||||
{
|
||||
$arr = unserialize(session('card', serialize([])));
|
||||
if (($key = array_search($id, $arr)) !== false) {
|
||||
unset($arr[$key]);
|
||||
}
|
||||
session(['card' => serialize($arr)]);
|
||||
return redirect()->route('card.show')->with(['message' => __('Product removed form card')]);
|
||||
}
|
||||
|
||||
public function cardRemQ($id)
|
||||
{
|
||||
$arr = unserialize(session('qcard', serialize([])));
|
||||
$counts = unserialize(session('qcounts', serialize([])));
|
||||
|
||||
if (($key = array_search($id, $arr)) !== false) {
|
||||
unset($arr[$key]);
|
||||
unset($counts[$key]);
|
||||
}
|
||||
session(['qcard' => serialize($arr)]);
|
||||
return redirect()->route('card.show')->with(['message' => __('Product removed form card')]);
|
||||
}
|
||||
|
||||
public function card()
|
||||
{
|
||||
|
||||
$arr = unserialize(session('card', serialize([])));
|
||||
$pros = Product::whereIn('slug', $arr)->get();
|
||||
$arr = unserialize(session('qcard', serialize([])));
|
||||
$counts = unserialize(session('qcounts', serialize([])));
|
||||
$qpros = Quantity::whereIn('id', $arr)->get();
|
||||
$transports = Transport::orderBy('sort')->orderBy('price')->get();
|
||||
$resevers = Invoice::where('reserve',1)->where('customer_id', \auth('customer')->id())
|
||||
->whereBetween('created_at',
|
||||
[
|
||||
Carbon::now()->subHour((int)getSetting('reserve')),
|
||||
Carbon::now(),
|
||||
])->get();
|
||||
\Session::put('shoping_card','1');
|
||||
\Session::save();
|
||||
return view('website.card', compact('pros', 'transports', 'qpros', 'counts', 'resevers'));
|
||||
}
|
||||
|
||||
public function sign()
|
||||
{
|
||||
if (\Auth::guard('customer')->check()) {
|
||||
return redirect()->route('customer');
|
||||
}
|
||||
|
||||
if (config('app.sms_signup')) {
|
||||
return view('website.signsms');
|
||||
} else {
|
||||
return view('website.sign');
|
||||
}
|
||||
}
|
||||
|
||||
public function questionSend(QuestionClientRequest $request)
|
||||
{
|
||||
$q = new Question();
|
||||
$q->product_id = $request->product_id;
|
||||
$q->body = $request->body;
|
||||
$q->customer_id = Auth::guard('customer')->id();
|
||||
$q->save();
|
||||
return json_encode(['OK' => true, 'msg' => __('Your question has been sent, We answer it soon.')]);
|
||||
}
|
||||
|
||||
public function mag()
|
||||
{
|
||||
$posts = Post::where('status', 1)->paginate(10);
|
||||
$title = __('Magazine');
|
||||
return view('website.posts', compact('posts', 'title'));
|
||||
}
|
||||
|
||||
public function sendSMS(Request $request)
|
||||
{
|
||||
// $this->sendSMS($request->mobile,)
|
||||
$code = rand(10000, 99999);
|
||||
$mobile = $request->mobile;
|
||||
$text = config('app.name') . PHP_EOL . __("Your authentication code") . ': ' . $code;
|
||||
$sms = new Sms();
|
||||
$sms->ip = $request->ip();
|
||||
$sms->text = $text;
|
||||
$sms->code = $code;
|
||||
$sms->mobile = $mobile;
|
||||
$sms->save();
|
||||
if (Customer::where('mobile', $mobile)->count() > 0) {
|
||||
$c = Customer::where('mobile', $mobile)->first();
|
||||
$c->code = $code;
|
||||
$c->save();
|
||||
}
|
||||
sendSMSText($mobile, $text);
|
||||
return ['OK' => true, 'msg' => __('SMS send, Please login with you Auth code')];
|
||||
}
|
||||
|
||||
public function checkSMS(Request $request)
|
||||
{
|
||||
$code = $request->pass;
|
||||
$mobile = $request->mobile;
|
||||
if (Customer::where('mobile', $mobile)->count() > 0) {
|
||||
|
||||
if (Customer::where('mobile', $mobile)->where('code', $code)->count() > 0){
|
||||
Auth::guard('customer')->loginUsingId(Customer::where('mobile', $mobile)
|
||||
->where('code', $code)->first()->id);
|
||||
return ['OK' => true, 'msg' => __('Welcome')];
|
||||
}else{
|
||||
return ['OK' => false, 'err' => __('Auth code error')];
|
||||
}
|
||||
// login
|
||||
} else {
|
||||
// register
|
||||
if (Sms::where([['ip', $request->ip()], ['code', $code], ['created_at', '>=', Carbon::now()->subHours(1)->toDateTimeString()]])->count() == 0) {
|
||||
return ['OK' => false, 'err' => __('Auth code error')];
|
||||
} else {
|
||||
$c = new Customer();
|
||||
$c->mobile = $mobile;
|
||||
$c->save();
|
||||
Auth::guard('customer')->loginUsingId($c->id);
|
||||
return ['OK' => true, 'msg' => __('Welcome')];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function profile(ProfileCustomerRequest $request)
|
||||
{
|
||||
$customer = Customer::whereId(Auth::guard('customer')->id())->firstOrFail();
|
||||
$customer->name = $request->input('name');
|
||||
$customer->address = $request->input('address');
|
||||
$customer->state = $request->input('state');
|
||||
$customer->city = $request->input('city');
|
||||
$customer->description = $request->input('description');
|
||||
$customer->postal_code = $request->input('postal_code');
|
||||
$customer->email = $request->input('email');
|
||||
// $customer->mobile = $request->input('mobile');
|
||||
if (trim($request->input('password')) != '') {
|
||||
$customer->password = bcrypt($request->input('password'));
|
||||
}
|
||||
$customer->save();
|
||||
return redirect()->route('customer')->with(['message' => __("Profile updated")]);
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
Auth::guard('customer')->logout();
|
||||
return redirect()->route('sign');
|
||||
}
|
||||
|
||||
public function discount(Request $request)
|
||||
{
|
||||
if ($request->code == '') {
|
||||
return abort(404);
|
||||
}
|
||||
return Discount::where('code', $request->code)->firstOrFail();
|
||||
}
|
||||
|
||||
public function track()
|
||||
{
|
||||
$attaches = Attachment::orderBy('id', 'desc')->paginate(20);
|
||||
return view('website.track', compact('attaches'));
|
||||
}
|
||||
|
||||
public function favToggle(Product $product)
|
||||
{
|
||||
if (\auth('customer')->check()) {
|
||||
if (\auth('customer')->user()->products()->where('product_id', $product->id)->exists()) {
|
||||
\auth('customer')->user()->products()->where('product_id', $product->id)->detach();
|
||||
return ['OK' => true, 'msg' => __('Product removed from favorite'), 'liked' => false];
|
||||
} else {
|
||||
\auth('customer')->user()->products()->attach($product->id);
|
||||
return ['OK' => true, 'msg' => __('Product added to favorite'), 'liked' => true];
|
||||
}
|
||||
} else {
|
||||
return ['OK' => false, 'msg' => 'You must login to do this action'];
|
||||
}
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
$title = __('ContactUs');
|
||||
return view('website.contact', compact('title'));
|
||||
// return view('website.contact');
|
||||
}
|
||||
|
||||
public function sendContact(ContactSaveRequest $request)
|
||||
{
|
||||
$con = new Contact();
|
||||
$con->full_name = $request->full_name;
|
||||
$con->email = $request->email;
|
||||
$con->Phone = $request->Phone;
|
||||
$con->subject = $request->subject;
|
||||
$con->body = $request->bodya;
|
||||
$con->save();
|
||||
return redirect()->back()->with(['message' => __('Your message has been successfully sent.')]);
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
\Session::remove('card');
|
||||
\Session::remove('qcard');
|
||||
\Session::remove('qcounts');
|
||||
\Session::save();
|
||||
return __('Card cleared') . '...';
|
||||
|
||||
}
|
||||
|
||||
static public function resetStockStatus(){
|
||||
Product::whereStockQuantity('0')->update(['stock_status' => 'OUT_STOCK']);
|
||||
return 'Done!';
|
||||
}
|
||||
|
||||
static public function resetQuantity(){
|
||||
|
||||
$qs = Quantity::groupBy('product_id')
|
||||
->select('product_id', DB::raw('sum(`count`) as count'))
|
||||
->get();
|
||||
foreach ($qs as $q){
|
||||
$p = Product::whereId($q->product_id)->first();
|
||||
$p->stock_quantity = $q->count;
|
||||
$p->save();
|
||||
}
|
||||
return 'Done!';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\Seo::class
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||
'under' => \App\Http\Middleware\UnderConstruction::class,
|
||||
];
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @param string|null ...$guards
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Seo
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$seoSettings = Setting::whereSection('seo')->pluck('value', 'key');
|
||||
$image = asset('images/' . str_replace('_', '.', 'site_image'));
|
||||
|
||||
SEOTools::setTitle($seoSettings->get('site_name', config('app.name')));
|
||||
SEOTools::setDescription($seoSettings->get('site_description'));
|
||||
|
||||
\SEOMeta::setKeywords(explode('،', $seoSettings->get('site_keywords')));
|
||||
|
||||
\OpenGraph::addImage($image);
|
||||
|
||||
\Twitter::setImage($image);
|
||||
|
||||
\JsonLd::setImage($image);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use phpDocumentor\Reflection\Types\False_;
|
||||
|
||||
class UnderConstruction
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (\App\Helpers\getSetting('under') == 'yes' & (!auth()->check()) ){
|
||||
return response()->view('website.under');
|
||||
}else{
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AddressSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth('customer')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'address'=> ['required', 'string', 'min:10'],
|
||||
'state'=> ['required', 'numeric'],
|
||||
'city'=> ['required', 'numeric'],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CatSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check() && auth()->user()->hasRole('super-admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'name' => ['required', 'string', 'min:2', 'max:128'],
|
||||
'description' => ['nullable', 'string', 'min:5'],
|
||||
'parent_id' => ['nullable', 'exists:cats,id'],
|
||||
'image' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||
'image2' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CommentClientRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return \Auth::guard('customer')->check() || auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'name' => ['required', 'string','min:2', 'max:60'],
|
||||
'email' => ['required', 'string', 'email', 'max:100'],
|
||||
'body' => ['required', 'string','max:10000','min:10'],
|
||||
'parent' => ['nullable'],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ContactSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'full_name' => ['required', 'string', 'max:255', 'min:3'],
|
||||
'Phone' => ['required', 'string', 'max:15', 'min:8'],
|
||||
'subject' => ['nullable', 'string', 'max:255', 'min:4'],
|
||||
'email' => ['required', 'email', 'max:255', 'min:4'],
|
||||
'bodya' => ['required', 'string', 'max:4048', 'min:15'],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DiscountRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'type'=>['required'],
|
||||
'amount'=>['required','string','min:1'],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class InvoiceSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return \Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
|
||||
|
||||
class ProductSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check() && auth()->user()->hasRole('super-admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
// 'name' => ['required', 'string', 'min:5', 'max:128','unique:products,name,'.$this->name],
|
||||
'name' => ['required', 'string', 'min:5', 'max:128',Rule::unique('products')->ignore($this->id)],
|
||||
'body' => ['nullable', 'string', 'min:5'],
|
||||
'excerpt' => ['required', 'string', 'min:5'],
|
||||
'active'=>['nullable','boolean'],
|
||||
'meta' => ['nullable'],
|
||||
'cat_id' => ['required', 'exists:cats,id'],
|
||||
'image.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ProfileCustomerRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Auth::guard('customer')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('customers')->ignore(Auth::guard('customer')->id())],
|
||||
'password' => ['nullable', 'string', 'min:6', 'confirmed'],
|
||||
'mobile' => ['required', 'string', 'min:10',Rule::unique('customers')->ignore(Auth::guard('customer')->id())],
|
||||
'postal_code' => ['required', 'string', 'min:10'],
|
||||
'address' => ['required', 'string', 'min:10'],
|
||||
'state' => ['required', 'numeric'],
|
||||
'city' => ['required', 'numeric'],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PropSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check() && auth()->user()->hasRole('super-admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'string|required|min:2|max:90',
|
||||
'label' => 'string|required|min:2|max:90',
|
||||
'category' => 'required|exists:cats,id',
|
||||
'icon'=> 'nullable|string',
|
||||
'type' => 'string|min:4'
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class QuestionClientRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return \Auth::guard('customer')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'body' => ['required','min:10'],
|
||||
'product_id' => ['required', 'exists:products,id']
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SettingSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check() and auth()->user()->hasRole('super-admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'title' => ['required', 'string','min:3', 'max:255'],
|
||||
'key' => ['required', 'string', 'alpha_dash', 'max:255', "unique:settings,key,".$this->id],
|
||||
'type' => ['required', 'string'],
|
||||
'section' => ['required', 'string', 'max:255', 'min:2'],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class TicketSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth('customer')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'title' => ['nullable','string'],
|
||||
'body'=>['required','string','min:5']
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class TransportSaveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
'title' => ['required','string','min:4'],
|
||||
'price' => ['required','integer'],
|
||||
'description' => ['nullable','string']
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class customerSaveRequest extends FormRequest
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->redirect = URL::previous() . '#register';
|
||||
}
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:customers,email'],
|
||||
'password' => ['required', 'string', 'min:6', 'confirmed'],
|
||||
'mobile'=> ['required', 'string', 'min:10'],
|
||||
'postal_code'=> ['required', 'string', 'min:10'],
|
||||
'address'=> ['required', 'string', 'min:10'],
|
||||
'state'=> ['required', 'numeric'],
|
||||
'city'=> ['required', 'numeric'],
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class customerUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['nullable', 'string', 'email', 'max:255', Rule::unique('customers')->ignore($this->route()->customer->id)],
|
||||
'password' => ['nullable', 'string', 'min:6', 'confirmed'],
|
||||
'mobile' => ['required', 'string', 'min:10',Rule::unique('customers')->ignore($this->route()->customer->id)],
|
||||
'postal_code' => ['required', 'string', 'min:10'],
|
||||
'address' => ['required', 'string', 'min:10'],
|
||||
'state' => ['required', 'numeric'],
|
||||
'city' => ['required', 'numeric'],
|
||||
];
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Attachment
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property string $file
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereFile($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Attachment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
/**
|
||||
* App\Models\Cat
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $slug
|
||||
* @property string|null $description
|
||||
* @property int $sort
|
||||
* @property string|null $image
|
||||
* @property int|null $parent_id
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $active_products
|
||||
* @property-read int|null $active_products_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Cat[] $children
|
||||
* @property-read int|null $children_count
|
||||
* @property-read \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection|Media[] $media
|
||||
* @property-read int|null $media_count
|
||||
* @property-read Cat|null $parent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $products
|
||||
* @property-read int|null $products_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Prop[] $props
|
||||
* @property-read int|null $props_count
|
||||
* @method static \Database\Factories\CatFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Cat onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereImage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereParentId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereSort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Cat whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Cat withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Cat withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Cat extends Model implements HasMedia
|
||||
{
|
||||
use HasFactory,SoftDeletes, InteractsWithMedia;
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
{
|
||||
|
||||
|
||||
$this->addMediaConversion('cat-thumb')
|
||||
->width(600)
|
||||
->height(600)
|
||||
->crop(Manipulations::CROP_CENTER, 600, 600)
|
||||
->optimize()
|
||||
->sharpen(10);
|
||||
|
||||
if (isset($_FILES['image'])) {
|
||||
$this->addMediaFromRequest('image')->preservingOriginal();
|
||||
}
|
||||
}
|
||||
|
||||
public function thumbUrl() {
|
||||
if ($this->getMedia()->count() > 0) {
|
||||
return $this->getMedia()->first()->getUrl('cat-thumb');
|
||||
} else {
|
||||
return asset('/images/logo.png');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function imgurl() {
|
||||
if ($this->getMedia()->count() > 0) {
|
||||
return $this->getMedia()->last()->getUrl();
|
||||
} else {
|
||||
return asset('/images/logo.png');
|
||||
}
|
||||
}
|
||||
|
||||
public function products(){
|
||||
return$this->belongsToMany(Product::class);
|
||||
}
|
||||
public function active_products(){
|
||||
return$this->belongsToMany(Product::class)->where('');
|
||||
}
|
||||
|
||||
public function backUrl()
|
||||
{
|
||||
if ($this->image == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return \Storage::url('cats/' . $this->image);
|
||||
}
|
||||
|
||||
//
|
||||
public function parent() {
|
||||
return $this->belongsTo(Cat::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children() {
|
||||
return $this->hasMany(Cat::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function getRouteKeyName() {
|
||||
return 'slug';
|
||||
}
|
||||
|
||||
public function props(){
|
||||
return $this->belongsToMany(Prop::class);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Contact
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $full_name
|
||||
* @property string $email
|
||||
* @property string|null $subject
|
||||
* @property string $phone
|
||||
* @property string $body
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereBody($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereFullName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact wherePhone($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Contact whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Contact extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* App\Models\Credit
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $amount
|
||||
* @property int $customer_id
|
||||
* @property int $invoice_id
|
||||
* @property string|null $data
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Credit onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereData($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Credit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Credit withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Credit withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property-read \App\Models\Customer $customer
|
||||
* @property-read \App\Models\Invoice $invoice
|
||||
*/
|
||||
class Credit extends Model
|
||||
{
|
||||
use HasFactory,SoftDeletes;
|
||||
|
||||
public function invoice(){
|
||||
return $this->belongsTo(Invoice::class);
|
||||
|
||||
}
|
||||
public function customer(){
|
||||
return $this->belongsTo(Customer::class);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
/**
|
||||
* App\Models\Customer
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property \Illuminate\Support\Carbon|null $email_verified_at
|
||||
* @property string $password
|
||||
* @property int|null $state
|
||||
* @property int|null $city
|
||||
* @property string|null $mobile
|
||||
* @property string|null $address
|
||||
* @property string|null $postal_code
|
||||
* @property string|null $remember_token
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
|
||||
* @property-read int|null $notifications_count
|
||||
* @method static \Database\Factories\CustomerFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereEmailVerifiedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereMobile($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer wherePassword($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer wherePostalCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereState($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $code
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCode($value)
|
||||
* @property string|null $address_alt
|
||||
* @property string|null $sms
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Invoice[] $invoices
|
||||
* @property-read int|null $invoices_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ticket[] $main_tickets
|
||||
* @property-read int|null $main_tickets_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ticket[] $tickets
|
||||
* @property-read int|null $tickets_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereAddressAlt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereSms($value)
|
||||
* @property int $colleague
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereColleague($value)
|
||||
* @property string|null $description
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereDescription($value)
|
||||
* @property int $credit
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $products
|
||||
* @property-read int|null $products_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCredit($value)
|
||||
* @property int $cerdit
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Address[] $addresses
|
||||
* @property-read int|null $addresses_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Credit[] $credits
|
||||
* @property-read int|null $credits_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Customer whereCerdit($value)
|
||||
*/
|
||||
class Customer extends Authenticatable
|
||||
{
|
||||
use HasFactory,Notifiable;
|
||||
//
|
||||
|
||||
protected $guard = 'customer';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password','mobile','address','state','city','postal_code'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function invoices(){
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
public function tickets(){
|
||||
return $this->hasMany(Ticket::class);
|
||||
}
|
||||
|
||||
public function main_tickets(){
|
||||
return $this->hasMany(Ticket::class)->whereNull('parent_id');
|
||||
}
|
||||
|
||||
public function products(){
|
||||
return $this->belongsToMany(Product::class,'customer_product');
|
||||
}
|
||||
public function credits(){
|
||||
return $this->hasMany(Credit::class);
|
||||
}
|
||||
|
||||
public function addresses(){
|
||||
return $this->hasMany(Address::class);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* App\Models\Discount
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $product_id
|
||||
* @property int $amount
|
||||
* @property string $type
|
||||
* @property string $code
|
||||
* @property string|null $expire
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\Product $product
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereExpire($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @method static \Illuminate\Database\Query\Builder|Discount onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Discount whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Discount withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Discount withoutTrashed()
|
||||
*/
|
||||
class Discount extends Model
|
||||
{
|
||||
use HasFactory,SoftDeletes;
|
||||
protected $dates = ['created_at','updated_at','expire'];
|
||||
|
||||
public function product(){
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\PaymentStore;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* App\Models\Invoice
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $customer_id
|
||||
* @property string|null $status
|
||||
* @property int|null $total_price
|
||||
* @property string|null $meta
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Database\Factories\InvoiceFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereMeta($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTotalPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $discount_id
|
||||
* @property-read \App\Models\Discount|null $discount
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereDiscountId($value)
|
||||
* @property string|null $desc
|
||||
* @property int|null $transport_id
|
||||
* @property string|null $hash
|
||||
* @property-read \App\Models\Customer $customer
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Payment[] $payments
|
||||
* @property-read int|null $payments_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Product[] $products
|
||||
* @property-read int|null $products_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Payment[] $successPayments
|
||||
* @property-read int|null $success_payments_count
|
||||
* @property-read \App\Models\Transport|null $transport
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereDesc($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereHash($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTransportId($value)
|
||||
* @property int $transport_price
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTransportPrice($value)
|
||||
* @property string|null $address_alt
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereAddressAlt($value)
|
||||
* @property int $reserve
|
||||
* @property int|null $invoice_id
|
||||
* @property string|null $tracking_code
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereReserve($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTrackingCode($value)
|
||||
* @property int $credit_price
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property-read Invoice|null $invoice
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Invoice[] $subInvoices
|
||||
* @property-read int|null $sub_invoices_count
|
||||
* @method static \Illuminate\Database\Query\Builder|Invoice onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereCreditPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Invoice withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Invoice withoutTrashed()
|
||||
* @property int|null $address_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Invoice whereAddressId($value)
|
||||
*/
|
||||
class Invoice extends Model
|
||||
{
|
||||
use HasFactory,PaymentStore,SoftDeletes;
|
||||
protected $fillable = ['total_price','customer_id','transport_id'];
|
||||
|
||||
public function discount(){
|
||||
return $this->belongsTo(Discount::class);
|
||||
}
|
||||
//
|
||||
// public function products(){
|
||||
// return $this->belongsToMany(Product::class);
|
||||
// }
|
||||
|
||||
|
||||
const PENDING = 'PENDING';
|
||||
const PROCESSING = 'PROCESSING';
|
||||
const COMPLETED = 'COMPLETED';
|
||||
const CANCELED = 'CANCELED';
|
||||
const FAILED = 'FAILED';
|
||||
|
||||
protected $casts = [
|
||||
'meta' => 'array',
|
||||
];
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function invoice(){
|
||||
return $this->belongsTo(Invoice::class,'invoice_id','id');
|
||||
}
|
||||
public function subInvoices(){
|
||||
return $this->hasMany(Invoice::class,'invoice_id','id');
|
||||
}
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function successPayments()
|
||||
{
|
||||
return $this->hasMany(Payment::class)->where('status', 'COMPLETED');
|
||||
}
|
||||
|
||||
public function payByBankUrl($gateway)
|
||||
{
|
||||
return route('redirect.bank', ['invoice' => $this->id, 'gateway' => $gateway]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'invoice_product')
|
||||
->withPivot(
|
||||
'count',
|
||||
'price_total',
|
||||
'data',
|
||||
'quantity_id'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function isCompleted()
|
||||
{
|
||||
return $this->status == 'COMPLETED' or $this->status == 'PROCESSING';
|
||||
}
|
||||
|
||||
public function transport(){
|
||||
return $this->belongsTo(Transport::class);
|
||||
}
|
||||
|
||||
public function getRouteKeyName()
|
||||
{
|
||||
return 'hash';
|
||||
}
|
||||
|
||||
public function address(){
|
||||
return $this->belongsTo(Address::class);
|
||||
}
|
||||
|
||||
public function getAddress(){
|
||||
if ($this->address_id == null){
|
||||
return Address::$states[$this->customer->state].','.Address::$cities[$this->customer->state][$this->customer->city].','.
|
||||
$this->customer->address;
|
||||
}else{
|
||||
return Address::$states[$this->address->state].','.Address::$cities[$this->address->state][$this->address->city].','.
|
||||
Address::where('id',$this->address_id)->first()->address;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Payment
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $invoice_id
|
||||
* @property int|null $amount
|
||||
* @property string|null $type
|
||||
* @property string|null $status
|
||||
* @property string $order_id
|
||||
* @property string|null $reference_id
|
||||
* @property string|null $comment
|
||||
* @property string|null $meta
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereComment($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereMeta($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereReferenceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Payment whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \App\Models\Invoice $invoice
|
||||
*/
|
||||
class Payment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
//'PENDING','SUCCESS', 'FAIL','CANCEL'
|
||||
const PENDING = 'PENDING';
|
||||
const SUCCESS = 'SUCCESS';
|
||||
const FAIL = 'FAIL';
|
||||
const CANCEL = 'CANCEL';
|
||||
|
||||
protected $casts = [
|
||||
'meta' => 'array',
|
||||
];
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Price
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $price
|
||||
* @property int $product_id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\Product $product
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Price whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Price extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function product(){
|
||||
return $this->belongsTo(Product::class,'product_id');
|
||||
}
|
||||
}
|
@ -0,0 +1,303 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Conner\Tagging\Taggable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Plank\Metable\Metable;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Xmen\StarterKit\Models\Category;
|
||||
use Xmen\StarterKit\Models\Comment;
|
||||
use function App\Helpers\getSetting;
|
||||
|
||||
/**
|
||||
* App\Models\Product
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $slug
|
||||
* @property string|null $description
|
||||
* @property string|null $excerpt Quick summary for product. This will appear on the product page under the product name and for SEO purpose.
|
||||
* @property string|null $sku SKU refers to a Stock-keeping unit, a unique identifier for each distinct product and service that can be purchased.
|
||||
* @property int|null $virtual If this product is a non-physical item, for example a service, which does not need shipping.
|
||||
* @property int|null $downloadable If purchasing this product gives a customer access to a downloadable file, e.g. software
|
||||
* @property int|null $price
|
||||
* @property int $cat_id main category id
|
||||
* @property int $user_id
|
||||
* @property int|null $on_sale
|
||||
* @property int|null $stock_quantity
|
||||
* @property string|null $stock_status
|
||||
* @property int|null $rating_count
|
||||
* @property string|null $average_rating
|
||||
* @property int|null $total_sales
|
||||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Comment[] $approved_comments
|
||||
* @property-read int|null $approved_comments_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Cat[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read \App\Models\Cat $category
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Comment[] $comments
|
||||
* @property-read int|null $comments_count
|
||||
* @property array $tag_names
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Tagged[] $tags
|
||||
* @property-read mixed $url
|
||||
* @property-read \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection|Media[] $media
|
||||
* @property-read int|null $media_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Plank\Metable\Meta[] $meta
|
||||
* @property-read int|null $meta_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Conner\Tagging\Model\Tagged[] $tagged
|
||||
* @property-read int|null $tagged_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Product onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product orderByMeta(string $key, string $direction = 'asc', bool $strict = false)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product orderByMetaNumeric(string $key, string $direction = 'asc', bool $strict = false)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereAverageRating($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereCatId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereDoesntHaveMeta($key)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereDownloadable($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereExcerpt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereHasMeta($key)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereHasMetaKeys(array $keys)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMeta(string $key, $operator, $value = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMetaIn(string $key, array $values)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMetaNumeric(string $key, string $operator, $value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereOnSale($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereRatingCount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSku($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereStockQuantity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereStockStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereTotalSales($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereVirtual($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withAllTags($tagNames)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withAnyTag($tagNames)
|
||||
* @method static \Illuminate\Database\Query\Builder|Product withTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withoutTags($tagNames)
|
||||
* @method static \Illuminate\Database\Query\Builder|Product withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Quantity[] $quantities
|
||||
* @property-read int|null $quantities_count
|
||||
* @property int $sell_count
|
||||
* @property int $view_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Price[] $prices
|
||||
* @property-read int|null $prices_count
|
||||
* @method static \Database\Factories\ProductFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSellCount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereViewCount($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Discount[] $discounts
|
||||
* @property-read int|null $discounts_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Question[] $quesions
|
||||
* @property-read int|null $quesions_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Question[] $quesions_asnwered
|
||||
* @property-read int|null $quesions_asnwered_count
|
||||
* @property int $fee
|
||||
* @property int $extra_price
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereExtraPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereFee($value)
|
||||
* @property int $image_index
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereImageIndex($value)
|
||||
*/
|
||||
class Product extends Model implements HasMedia
|
||||
{
|
||||
use SoftDeletes, InteractsWithMedia, Taggable, Metable, HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
protected $appends = ['url'];
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->name . getSetting('prefix') . $this->id;
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
|
||||
public function approved_comments()
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable')->where('status', 1)->whereNull('sub_comment_id');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return $this->belongsToMany(Cat::class);
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Cat::class, 'cat_id', 'id');
|
||||
}
|
||||
|
||||
public function getRouteKeyName()
|
||||
{
|
||||
return 'slug';
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
if ($this->sku != '')
|
||||
return $this->sku;
|
||||
else
|
||||
return $this->id;
|
||||
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
{
|
||||
|
||||
$this->addMediaConversion('product-image')
|
||||
->width(1200)
|
||||
// ->height(600)
|
||||
// ->crop(Manipulations::CROP_CENTER, 1200, 600)
|
||||
->optimize()
|
||||
->sharpen(10);
|
||||
$this->addMediaConversion('product-thumb')
|
||||
->width(600)
|
||||
->height(600)
|
||||
->crop(Manipulations::CROP_CENTER, 600, 600)
|
||||
->optimize()
|
||||
->sharpen(10);
|
||||
}
|
||||
|
||||
public function thumbUrl()
|
||||
{
|
||||
if ($this->getMedia()->count() > 0) {
|
||||
return $this->getMedia()[$this->image_index]->getUrl('product-thumb');
|
||||
} else {
|
||||
return asset('/images/logo.png');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function thumbUrl2()
|
||||
{
|
||||
if ($this->getMedia()->count() > 0 && isset($this->getMedia()[1])) {
|
||||
return $this->getMedia()[1]->getUrl('product-thumb');
|
||||
} else {
|
||||
return asset('/images/logo.png');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function imgurl()
|
||||
{
|
||||
if ($this->getMedia()->count() > 0) {
|
||||
return $this->getMedia()[$this->image_index]->getUrl();
|
||||
} else {
|
||||
return asset('/images/logo.png');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return route('product', ['pro' => $this->slug]);
|
||||
}
|
||||
|
||||
public function quantities()
|
||||
{
|
||||
return $this->hasMany(Quantity::class, 'product_id');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasMany(Price::class, 'product_id', 'id');
|
||||
}
|
||||
|
||||
public function prices_history()
|
||||
{
|
||||
return $this->prices()->orderByDesc('id')->limit(20);
|
||||
}
|
||||
|
||||
public function discounts()
|
||||
{
|
||||
return $this->hasMany(Discount::class, 'product_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function getPurePrice()
|
||||
{
|
||||
if ($this->discounts()->whereNull('code')->count() > 0) {
|
||||
$d = $this->discounts()->whereNull('code')->orderBy('id', 'desc')->first();
|
||||
if ($d->type == 'percent') {
|
||||
$price = $this->price - ($this->price * ($d->amount / 100));
|
||||
return $price;
|
||||
} else {
|
||||
return $this->price - $d->amount;
|
||||
}
|
||||
}
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* with default
|
||||
* @param $def
|
||||
* @return float|\Illuminate\Database\Eloquent\HigherOrderBuilderProxy|int|mixed|null
|
||||
*/
|
||||
public function getPurePriceDef($def)
|
||||
{
|
||||
if ($this->discounts()->whereNull('code')->count() > 0) {
|
||||
$d = $this->discounts()->whereNull('code')->orderBy('id', 'desc')->first();
|
||||
if ($d->type == 'percent') {
|
||||
$price = $def - ($def * ($d->amount / 100));
|
||||
return $price;
|
||||
} else {
|
||||
return $def - $d->amount;
|
||||
}
|
||||
}
|
||||
return $def;
|
||||
}
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
if ($this->getPurePrice() == 0) {
|
||||
return __('Call us!');
|
||||
}
|
||||
return number_format($this->getPurePrice()) . ' ' . config('app.currency_type');
|
||||
}
|
||||
|
||||
public function quesions()
|
||||
{
|
||||
return $this->hasMany(Question::class);
|
||||
}
|
||||
|
||||
public function quesions_asnwered()
|
||||
{
|
||||
return $this->hasMany(Question::class)->where('status', 1);
|
||||
}
|
||||
|
||||
function hasDiscount()
|
||||
{
|
||||
return $this->discounts()->where('expire', '>', \DB::raw('NOW()'))->count() > 1;
|
||||
}
|
||||
|
||||
public function isFav()
|
||||
{
|
||||
if (auth('customer')->check()) {
|
||||
return \auth('customer')->user()->products()->where('product_id', $this->id)->exists();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* App\Models\Prop
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $label
|
||||
* @property string $width
|
||||
* @property int $required
|
||||
* @property int $searchable
|
||||
* @property string $type
|
||||
* @property int $sort
|
||||
* @property string|null $options
|
||||
* @property int $priceable
|
||||
* @property string|null $icon
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Cat[] $category
|
||||
* @property-read int|null $category_count
|
||||
* @method static \Database\Factories\PropFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Prop onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereIcon($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereLabel($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereOptions($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop wherePriceable($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereRequired($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereSearchable($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereSort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereWidth($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Prop withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Prop withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property string $unit
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Prop whereUnit($value)
|
||||
*/
|
||||
class Prop extends Model
|
||||
{
|
||||
use HasFactory,SoftDeletes;
|
||||
protected $guarded = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsToMany(Cat::class);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Plank\Metable\Metable;
|
||||
|
||||
/**
|
||||
* App\Models\Quantity
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $product_id
|
||||
* @property int $count
|
||||
* @property int $price
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereCount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $data
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Plank\Metable\Meta[] $meta
|
||||
* @property-read int|null $meta_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity orderByMeta(string $key, string $direction = 'asc', bool $strict = false)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity orderByMetaNumeric(string $key, string $direction = 'asc', bool $strict = false)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereData($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereDoesntHaveMeta($key)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereHasMeta($key)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereHasMetaKeys(array $keys)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereMeta(string $key, $operator, $value = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereMetaIn(string $key, array $values)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereMetaNumeric(string $key, string $operator, $value)
|
||||
* @property int|null $image
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Quantity whereImage($value)
|
||||
* @property-read \App\Models\Product $product
|
||||
*/
|
||||
class Quantity extends Model
|
||||
{
|
||||
use HasFactory, Metable, SoftDeletes;
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class, 'product_id', 'id');
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Question
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $body
|
||||
* @property int $customer_id
|
||||
* @property string|null $answer
|
||||
* @property int $product_id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereAnswer($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereBody($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int $status
|
||||
* @property-read \App\Models\Customer $customer
|
||||
* @property-read \App\Models\Product $product
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Question whereStatus($value)
|
||||
*/
|
||||
class Question extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function product(){
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
public function customer(){
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Setting
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $section
|
||||
* @property string $type
|
||||
* @property string $title
|
||||
* @property int $active
|
||||
* @property string $key
|
||||
* @property string|null $value
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereKey($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereSection($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereValue($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Setting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Sms
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $text
|
||||
* @property string $ip_address
|
||||
* @property string $user
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereIpAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereUser($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $code
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereCode($value)
|
||||
* @property string $ip
|
||||
* @property string|null $mobile
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereIp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Sms whereMobile($value)
|
||||
*/
|
||||
class Sms extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Ticket
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $title
|
||||
* @property int $customer_id
|
||||
* @property string $body
|
||||
* @property string|null $answer
|
||||
* @property int|null $parent_id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property string|null $status
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereAnswer($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereBody($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereParentId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Ticket whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \App\Models\Customer $customer
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|Ticket[] $subTickets
|
||||
* @property-read int|null $sub_tickets_count
|
||||
*/
|
||||
class Ticket extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function customer(){
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function subTickets(){
|
||||
return $this->hasMany(Ticket::class,'parent_id','id')->orderBy('id');
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* App\Models\Transport
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property string|null $description
|
||||
* @property int $sort
|
||||
* @property int $is_default
|
||||
* @property int $price
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereIsDefault($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport wherePrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereSort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Transport whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Transport extends Model
|
||||
{
|
||||
use HasFactory,SoftDeletes;
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Xmen\StarterKit\Models\StarterKit;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\User
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property \Illuminate\Support\Carbon|null $email_verified_at
|
||||
* @property string $password
|
||||
* @property string|null $remember_token
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property string|null $mobile
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Xmen\StarterKit\Models\AdminLog[] $logs
|
||||
* @property-read int|null $logs_count
|
||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
|
||||
* @property-read int|null $notifications_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Permission[] $permissions
|
||||
* @property-read int|null $permissions_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Xmen\StarterKit\Models\Post[] $posts
|
||||
* @property-read int|null $posts_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Role[] $roles
|
||||
* @property-read int|null $roles_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Sanctum\PersonalAccessToken[] $tokens
|
||||
* @property-read int|null $tokens_count
|
||||
* @method static \Database\Factories\UserFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User permission($permissions)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User role($roles, $guard = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereEmailVerifiedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereMobile($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User wherePassword($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable,StarterKit;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Quantity;
|
||||
use function App\Helpers\sendSMSText;
|
||||
|
||||
class InvoiceObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Invoice "created" event.
|
||||
*
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return void
|
||||
*/
|
||||
public function created(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Invoice "updated" event.
|
||||
*
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return void
|
||||
*/
|
||||
public function updated(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
if ($invoice->wasChanged('tracking_code') && strlen($invoice->tracking_code) == 24){
|
||||
sendSMSText($invoice->customer->mobile, config('app.name').PHP_EOL.'کد رهگیری سفارش شما:'.$invoice->tracking_code);
|
||||
}
|
||||
if ($invoice->wasChanged('status') && $invoice->status == Invoice::CANCELED){
|
||||
$pros = $invoice->products()->withPivot(['quantity_id', 'count'])->get();
|
||||
foreach ($pros as $pr) {
|
||||
$q = Quantity::whereId($pr->pivot->quantity_id)->first();
|
||||
if ($q == null || $pr->pivot->count == null){
|
||||
continue;
|
||||
}
|
||||
$q->count += $pr->pivot->count;
|
||||
$q->save();
|
||||
$q->product->stock_quantity += $pr->pivot->count;
|
||||
$q->product->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Invoice "deleted" event.
|
||||
*
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Invoice "restored" event.
|
||||
*
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return void
|
||||
*/
|
||||
public function restored(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Invoice "force deleted" event.
|
||||
*
|
||||
* @param \App\Models\Invoice $invoice
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue