restore composer.json, add mysqli extension
This commit is contained in:
47
app/Jobs/Api/Address/Store.php
Executable file
47
app/Jobs/Api/Address/Store.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api\Address;
|
||||
|
||||
use App\Models\Address;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Api\Order\Request as OrderRequest;
|
||||
|
||||
class Store
|
||||
{
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['user_id', 'city', 'region', 'first_name', 'street', 'phone', 'apartment', 'floor', 'entrance']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param OrderRequest $request
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest($user_id, OrderRequest $request)
|
||||
{
|
||||
return new static([
|
||||
'user_id' => $user_id,
|
||||
'city' => $request->getCity(),
|
||||
'region' => $request->getRegion(),
|
||||
'first_name' => $request->getFirstName(),
|
||||
'street' => $request->getStreet(),
|
||||
'phone' => $request->getPhone(),
|
||||
'apartment' => $request->getApartment(),
|
||||
'floor' => $request->getFloor(),
|
||||
'entrance' => $request->getEntrance()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
return Address::create($this->attr);
|
||||
}
|
||||
}
|
||||
43
app/Jobs/Api/Auth/Register.php
Executable file
43
app/Jobs/Api/Auth/Register.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api\Auth;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Api\Auth\Register as RegisterRequest;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class Register
|
||||
{
|
||||
|
||||
protected $user;
|
||||
protected $attr;
|
||||
|
||||
public function __construct(User $user, array $attr = [])
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->attr = Arr::only($attr, ['first_name', 'last_name', 'step', 'gender', 'avatar', 'birth_day']);
|
||||
}
|
||||
|
||||
public static function fromRequest(RegisterRequest $request, User $user)
|
||||
{
|
||||
return new static($user, [
|
||||
'first_name' => $request->getFirstName(),
|
||||
'last_name' => $request->getLastName(),
|
||||
'step' => 3,
|
||||
'gender' => $request->getGender(),
|
||||
'avatar' => $request->getAvatar(),
|
||||
'birth_day' => $request->getBirthDay()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return $this->user->update($this->attr);
|
||||
}
|
||||
}
|
||||
46
app/Jobs/Api/Auth/Store.php
Executable file
46
app/Jobs/Api/Auth/Store.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Api\Auth\Login as LoginRequest;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['phone', 'verify_code', 'step']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoginRequest $request
|
||||
* @param int $code
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(LoginRequest $request, int $code)
|
||||
{
|
||||
return new static([
|
||||
'phone' => $request->getPhone(),
|
||||
//'verify_code' => $code,
|
||||
'step' => 2,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return User::create($this->attr);
|
||||
}
|
||||
}
|
||||
34
app/Jobs/Api/Favorite/Delete.php
Executable file
34
app/Jobs/Api/Favorite/Delete.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api\Favorite;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Delete implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
34
app/Jobs/Api/Favorite/Store.php
Executable file
34
app/Jobs/Api/Favorite/Store.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api\Favorite;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Store implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
50
app/Jobs/Api/Order/Product.php
Executable file
50
app/Jobs/Api/Order/Product.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api\Order;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Http\Requests\Api\Order\Request as OrderRequest;
|
||||
use App\Models\OrderProducts;
|
||||
use App\Models\Product as Model;
|
||||
|
||||
|
||||
class Product
|
||||
{
|
||||
protected $request;
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Product constructor.
|
||||
* @param Order $order
|
||||
* @param OrderRequest $request
|
||||
*/
|
||||
public function __construct(Order $order, OrderRequest $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
foreach ($this->request->getProducts() as $product) {
|
||||
$row = Model::find($product['id']);
|
||||
|
||||
$discount = $row->price_discount ? 100 - $row->price_discount * 100 / $row->price : null;
|
||||
|
||||
OrderProducts::create([
|
||||
'order_id' => $this->order->id,
|
||||
'product_id' => $product['id'],
|
||||
'discount' => $discount,
|
||||
'count' => $product['count'],
|
||||
'size' => $product['size'],
|
||||
'color_id' => $product['color_id']
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
64
app/Jobs/Api/Order/Store.php
Executable file
64
app/Jobs/Api/Order/Store.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api\Order;
|
||||
|
||||
use App\Models\Currency;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Api\Order\Request as OrderRequest;
|
||||
|
||||
|
||||
class Store
|
||||
{
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['user_id', 'address_id', 'price_total', 'price_delivery', 'shipment_date', 'type_delivery', 'payment_type', 'comment', 'status', 'branch_id', 'price_product', 'payment_status', 'currency']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $address_id
|
||||
* @param OrderRequest $request
|
||||
* @param $total
|
||||
* @param $delivery
|
||||
* @param $status
|
||||
* @param $product_total
|
||||
* @param Currency $currency
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest($user_id, $address_id, OrderRequest $request, $total, $delivery, $status, $product_total, Currency $currency)
|
||||
{
|
||||
return new static([
|
||||
'user_id' => $user_id,
|
||||
'address_id' => $address_id,
|
||||
'price_total' => $total,
|
||||
'price_delivery' => $delivery,
|
||||
'shipment_date' => $request->getShipmentDate(),
|
||||
'type_delivery' => $request->getTypeDelivery(),
|
||||
'payment_type' => $request->getPaymentType(),
|
||||
'comment' => $request->getComment(),
|
||||
'status' => 0,
|
||||
'branch_id' => $request->getBranchID(),
|
||||
'price_product' => $product_total,
|
||||
'payment_status' => $status,
|
||||
'currency' => [
|
||||
'dollar' => $currency->dollar,
|
||||
'euro' => $currency->euro
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return Order::create($this->attr);
|
||||
}
|
||||
}
|
||||
48
app/Jobs/Api/User/Update.php
Executable file
48
app/Jobs/Api/User/Update.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Api\User;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Api\User\Update as UpdateRequest;
|
||||
|
||||
class Update
|
||||
{
|
||||
protected $attr;
|
||||
protected $user;
|
||||
|
||||
public function __construct(User $user, array $attr = [])
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->attr = Arr::only($attr, ['last_name', 'first_name', 'avatar', 'category_id', 'language', 'notification', 'gender', 'ip', 'birth_day']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UpdateRequest $request
|
||||
* @param User $user
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(UpdateRequest $request, User $user, $path)
|
||||
{
|
||||
return new static($user, [
|
||||
'first_name' => $request->getFirstName(),
|
||||
'last_name' => $request->getLastName(),
|
||||
'avatar' => $path,
|
||||
'category_id' => $request->getCategory(),
|
||||
'birth_day' => $request->getBirthDay(),
|
||||
'language' => $request->getLanguages(),
|
||||
'notification' => $request->getNotification(),
|
||||
'gender' => $request->getGender(),
|
||||
'ip' => $request->ip()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return $this->user->update($this->attr);
|
||||
}
|
||||
}
|
||||
52
app/Jobs/Cron/BackProductJob.php
Executable file
52
app/Jobs/Cron/BackProductJob.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Cron;
|
||||
|
||||
use App\Models\Product;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Order;
|
||||
|
||||
class BackProductJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$now = Carbon::parse(time() - 3600)->format('Y-m-d H:i:s');
|
||||
$back = Carbon::parse(time() - 315360000)->format('Y-m-d H:i:s');
|
||||
|
||||
$orders = Order::where('payment_status', 'waiting')->where('status', 'processing')->with('products')->whereBetween('created_at', [$back, $now])->get();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$order->status = 'cancelled';
|
||||
$order->save();
|
||||
|
||||
foreach ($order->products as $row) {
|
||||
$product = Product::find($row->product_id);
|
||||
$product->count = $product->count + $row->count;
|
||||
$product->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
app/Jobs/Cron/CloseOrderJob.php
Executable file
43
app/Jobs/Cron/CloseOrderJob.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Cron;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use App\Models\Order;
|
||||
|
||||
class CloseOrderJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$from = '2020-01-01 00:00:01';
|
||||
$to = Carbon::parse(time() - 7200)->format('Y-m-d H:i:s');
|
||||
|
||||
$orders = Order::where('payment_type', 'credit')->where('payment_status', 'waiting')->whereBetween('created_at', [$from, $to])->get();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$order->update([
|
||||
'payment_status' => 'cancelled',
|
||||
'archived' => true,
|
||||
'status' => 'cancelled'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
app/Jobs/Cron/SendSmsJob.php
Executable file
46
app/Jobs/Cron/SendSmsJob.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Cron;
|
||||
|
||||
use App\Api\Sms;
|
||||
use App\Models\NotificationAvailable;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SendSmsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$notifications = NotificationAvailable::where('sms', 0)->get();
|
||||
|
||||
$sms = new Sms();
|
||||
|
||||
foreach ($notifications as $notification) {
|
||||
$message = "Quyoshli: Tovar {$notification->product->getName()} teper dostupen dlya pokupki";
|
||||
$sms->send($notification->phone, $message);
|
||||
|
||||
$notification->delete();
|
||||
sleep(0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
app/Jobs/Dashboard/Branch/Store.php
Executable file
35
app/Jobs/Dashboard/Branch/Store.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Branch;
|
||||
|
||||
use App\Http\Requests\Dashboard\Branch\Request;
|
||||
use App\Models\Branch;
|
||||
|
||||
class Store
|
||||
{
|
||||
/**
|
||||
* @var $request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$request = $this->request;
|
||||
|
||||
$branch = new Branch;
|
||||
|
||||
$branch->name = $request->getName();
|
||||
$branch->address = $request->getAddress();
|
||||
$branch->schedule = $request->getSchedule();
|
||||
$branch->map = $request->getMap();
|
||||
$branch->phone = $request->getPhone();
|
||||
$branch->orientation = $request->getOrientation();
|
||||
|
||||
$branch->save();
|
||||
}
|
||||
}
|
||||
45
app/Jobs/Dashboard/Branch/Update.php
Executable file
45
app/Jobs/Dashboard/Branch/Update.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Branch;
|
||||
|
||||
use App\Http\Requests\Dashboard\Branch\Request;
|
||||
use App\Models\Branch;
|
||||
|
||||
class Update
|
||||
{
|
||||
/**
|
||||
* @var $request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var $branch
|
||||
*/
|
||||
protected $branch;
|
||||
|
||||
public function __construct(Request $request, Branch $branch)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->branch = $branch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$request = $this->request;
|
||||
$branch = $this->branch;
|
||||
|
||||
$branch->name = $request->getName();
|
||||
$branch->address = $request->getAddress();
|
||||
$branch->schedule = $request->getSchedule();
|
||||
$branch->map = $request->getMap();
|
||||
$branch->phone = $request->getPhone();
|
||||
$branch->orientation = $request->getOrientation();
|
||||
|
||||
$branch->save();
|
||||
}
|
||||
}
|
||||
45
app/Jobs/Dashboard/Brand/Store.php
Executable file
45
app/Jobs/Dashboard/Brand/Store.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Brand;
|
||||
|
||||
use App\Models\Brand;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Brand\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'image',"position" ,'slug']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $path)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'image' => $path,
|
||||
'position' => $request->position,
|
||||
'slug' => str_slug($request->name['ru'])
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Brand::create($this->attr);
|
||||
}
|
||||
}
|
||||
50
app/Jobs/Dashboard/Brand/Update.php
Executable file
50
app/Jobs/Dashboard/Brand/Update.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Brand;
|
||||
|
||||
use App\Models\Brand;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Brand\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $brand;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Brand $brand
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Brand $brand, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'image', "position",'slug']);
|
||||
$this->brand = $brand;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Brand $brand
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Brand $brand, Request $request, $path)
|
||||
{
|
||||
return new static($brand, [
|
||||
'name' => $request->getName(),
|
||||
'image' => $path,
|
||||
'position' => $request->position,
|
||||
'slug' => str_slug($request->name['ru'])
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->brand->update($this->attr);
|
||||
}
|
||||
}
|
||||
50
app/Jobs/Dashboard/Category/Store.php
Executable file
50
app/Jobs/Dashboard/Category/Store.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Category;
|
||||
|
||||
use App\Http\Requests\Dashboard\Category\Request;
|
||||
use App\Models\Category;
|
||||
|
||||
class Store
|
||||
{
|
||||
/**
|
||||
* @var $request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$request = $this->request;
|
||||
|
||||
$category = new Category;
|
||||
|
||||
$category->name = $request->getName();
|
||||
$category->slug = $request->getSlug();
|
||||
$category->position = $request->getPosition();
|
||||
$category->image = $request->getImage();
|
||||
$category->parent_id = $request->getParentId();
|
||||
$category->published = $request->getPublished();
|
||||
$category->is_filter_power = $request->getFilterPower();
|
||||
$category->credit = $request->getCredit();
|
||||
$category->keywords = $request->keywords;
|
||||
$category->title_seo = $request->title_seo;
|
||||
|
||||
$category->save();
|
||||
|
||||
$category->brands()->sync($request->brands, false);
|
||||
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
58
app/Jobs/Dashboard/Category/Update.php
Executable file
58
app/Jobs/Dashboard/Category/Update.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Category;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Category\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $request;
|
||||
protected $category;
|
||||
protected $image;
|
||||
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Category $category
|
||||
* @param Request $request
|
||||
* @param $image
|
||||
*/
|
||||
public function __construct(Category $category, Request $request, $image)
|
||||
{
|
||||
$this->category = $category;
|
||||
$this->request = $request;
|
||||
$this->image = $image;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$request = $this->request;
|
||||
$category = $this->category;
|
||||
|
||||
$category->name = $request->getName();
|
||||
$category->slug = $request->getSlug();
|
||||
$category->position = $request->getPosition();
|
||||
$category->image = $request->getImage($category);
|
||||
// $category->parent_id = $request->getParentId();
|
||||
// $category->popular = $request->getPopular();
|
||||
$category->published = $request->getPublished();
|
||||
$category->is_filter_power = $request->getFilterPower();
|
||||
// $category->credit = $request->getCredit();
|
||||
$category->descriptions = $request->descriptions;
|
||||
$category->keywords = $request->keywords;
|
||||
$category->title_seo = $request->title_seo;
|
||||
|
||||
$category->image = $this->image;
|
||||
|
||||
$category->save();
|
||||
|
||||
if (isset($request->brands)) {
|
||||
$category->brands()->syncWithoutDetaching($request->brands);
|
||||
} else {
|
||||
$category->brands()->sync(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
43
app/Jobs/Dashboard/City/Store.php
Executable file
43
app/Jobs/Dashboard/City/Store.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\City;
|
||||
|
||||
use App\Models\City;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\City\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'region_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'region_id' => $request->getRegion()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
City::create($this->attr);
|
||||
}
|
||||
}
|
||||
48
app/Jobs/Dashboard/City/Update.php
Executable file
48
app/Jobs/Dashboard/City/Update.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\City;
|
||||
|
||||
use App\Models\City;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\City\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $city;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param City $city
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(City $city, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'region_id']);
|
||||
$this->city = $city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param City $city
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(City $city, Request $request)
|
||||
{
|
||||
return new static($city, [
|
||||
'name' => $request->getName(),
|
||||
'region_id' => $request->getRegion()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->city->update($this->attr);
|
||||
}
|
||||
}
|
||||
38
app/Jobs/Dashboard/Color/Store.php
Executable file
38
app/Jobs/Dashboard/Color/Store.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Color;
|
||||
|
||||
use App\Http\Requests\Dashboard\Color\Request;
|
||||
use App\Models\Color;
|
||||
|
||||
class Store
|
||||
{
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$request = $this->request;
|
||||
|
||||
$color = new Color;
|
||||
|
||||
$color->name = $request->getName();
|
||||
$color->color = $request->getColor();
|
||||
|
||||
$color->save();
|
||||
}
|
||||
}
|
||||
40
app/Jobs/Dashboard/Color/Update.php
Executable file
40
app/Jobs/Dashboard/Color/Update.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Color;
|
||||
|
||||
use App\Http\Requests\Dashboard\Color\Request;
|
||||
use App\Models\Color;
|
||||
|
||||
class Update
|
||||
{
|
||||
protected $request;
|
||||
protected $color;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Color $color
|
||||
*/
|
||||
public function __construct(Request $request, Color $color)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$request = $this->request;
|
||||
$color = $this->color;
|
||||
|
||||
$color->name = $request->getName();
|
||||
$color->color = $request->getColor();
|
||||
|
||||
$color->save();
|
||||
}
|
||||
}
|
||||
48
app/Jobs/Dashboard/Comment/Update.php
Executable file
48
app/Jobs/Dashboard/Comment/Update.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Comment;
|
||||
|
||||
use App\Models\Comment;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Comment\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $comment;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Comment $comment
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Comment $comment, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['publish']);
|
||||
$this->comment = $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Comment $comment
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Comment $comment, Request $request)
|
||||
{
|
||||
return new static($comment, [
|
||||
'publish' => $request->getPublish(),
|
||||
'user_id' => auth()->user()->id
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment->update($this->attr);
|
||||
}
|
||||
}
|
||||
43
app/Jobs/Dashboard/Compilation/Store.php
Executable file
43
app/Jobs/Dashboard/Compilation/Store.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Compilation;
|
||||
|
||||
use App\Http\Requests\Dashboard\Compilation\Store as StoreRequest;
|
||||
use App\Models\Compilation;
|
||||
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param StoreRequest $request
|
||||
*/
|
||||
public function __construct(StoreRequest $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$compilation = Compilation::create([
|
||||
'title' => $this->request->getTitle(),
|
||||
'published' => $this->request->getPublished(),
|
||||
'position' => 1,
|
||||
'category_id' => $this->request->getCategory()
|
||||
]);
|
||||
|
||||
$map = array_map(function ($product) {
|
||||
return $product['id'];
|
||||
}, $this->request->products);
|
||||
|
||||
$compilation->products()->attach($map);
|
||||
}
|
||||
}
|
||||
54
app/Jobs/Dashboard/Compilation/Update.php
Executable file
54
app/Jobs/Dashboard/Compilation/Update.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Compilation;
|
||||
|
||||
use App\Http\Requests\Dashboard\Compilation\Update as UpdateRequest;
|
||||
use App\Models\Compilation;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $request;
|
||||
protected $compilation;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param UpdateRequest $request
|
||||
* @param Compilation $compilation
|
||||
*/
|
||||
public function __construct(UpdateRequest $request, Compilation $compilation)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->compilation = $compilation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Compilation::find($this->compilation->id)->update([
|
||||
'title' => $this->request->getTitle(),
|
||||
'published' => $this->request->getPublished(),
|
||||
'category_id' => $this->request->getCategory()
|
||||
]);
|
||||
|
||||
$detach = Compilation::find($this->compilation->id);
|
||||
$detach->loadMissing(['products:id']);
|
||||
|
||||
$compilation = Compilation::find($this->compilation->id);
|
||||
|
||||
$map = array_map(function ($product) {
|
||||
return $product['id'];
|
||||
}, $this->request->products);
|
||||
|
||||
$detach = array_map(function ($product) {
|
||||
return $product['id'];
|
||||
}, $detach->products->toArray());
|
||||
|
||||
$compilation->products()->detach($detach);
|
||||
$compilation->products()->attach($map);
|
||||
}
|
||||
}
|
||||
42
app/Jobs/Dashboard/Currency/Store.php
Executable file
42
app/Jobs/Dashboard/Currency/Store.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Currency;
|
||||
|
||||
use App\Models\Currency;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Currency\Store as StoreRequest;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['dollar', 'euro']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param StoreRequest $request
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(StoreRequest $request)
|
||||
{
|
||||
return new static([
|
||||
'dollar' => $request->getDollar(),
|
||||
'euro' => $request->getEuro()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Currency::create($this->attr);
|
||||
}
|
||||
}
|
||||
45
app/Jobs/Dashboard/File/Store.php
Executable file
45
app/Jobs/Dashboard/File/Store.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\File;
|
||||
|
||||
use App\Models\File;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\File\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'path', 'size']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $size
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $path, $size)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->file('file')->getClientOriginalName(),
|
||||
'size' => $size,
|
||||
'path' => $path
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
File::create($this->attr);
|
||||
}
|
||||
}
|
||||
56
app/Jobs/Dashboard/Order/Address.php
Executable file
56
app/Jobs/Dashboard/Order/Address.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Order;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Models\Address as Model;
|
||||
use App\Http\Requests\Dashboard\Order\Update as UpdateRequest;
|
||||
|
||||
|
||||
class Address
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
protected $address;
|
||||
|
||||
/**
|
||||
* Address constructor.
|
||||
* @param Model $address
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Model $address, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['city', 'first_name', 'phone', 'region', 'street', 'apartment', 'floor', 'entrance']);
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $address
|
||||
* @param UpdateRequest $request
|
||||
* @return Address
|
||||
*/
|
||||
public static function fromRequest(Model $address, UpdateRequest $request)
|
||||
{
|
||||
return new static($address, [
|
||||
'city' => $request->getCity(),
|
||||
'region' => $request->getRegion(),
|
||||
'street' => $request->getStreet(),
|
||||
'apartment' => $request->getApartment(),
|
||||
'floor' => $request->getFloor(),
|
||||
'entrance' => $request->getEntrance(),
|
||||
|
||||
'first_name' => $request->getFirstName(),
|
||||
'phone' => $request->getPhone()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->address->update($this->attr);
|
||||
}
|
||||
}
|
||||
42
app/Jobs/Dashboard/Order/Products.php
Executable file
42
app/Jobs/Dashboard/Order/Products.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Order;
|
||||
|
||||
use App\Http\Requests\Dashboard\Order\Update as UpdateRequest;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderProducts;
|
||||
|
||||
|
||||
class Products
|
||||
{
|
||||
protected $order;
|
||||
protected $request;
|
||||
|
||||
public function __construct(Order $order, UpdateRequest $request)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
OrderProducts::where('order_id', $this->order->id)->delete();
|
||||
|
||||
foreach ($this->request->getProducts() as $product) {
|
||||
OrderProducts::create([
|
||||
'color_id' => $product['color_id'],
|
||||
'order_id' => $this->order->id,
|
||||
'size' => $product['size'],
|
||||
'product_id' => $product['product_id'],
|
||||
'count' => $product['count'],
|
||||
'price' => $product['product']['price_discount'] ? $product['product']['price_discount'] : $product['product']['price'],
|
||||
'discount' => $product['discount']
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
app/Jobs/Dashboard/Order/Update.php
Executable file
55
app/Jobs/Dashboard/Order/Update.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Order;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Http\Requests\Dashboard\Order\Update as UpdateRequest;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Order $order
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Order $order, array $attr = [])
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->attr = Arr::only($attr, ['price_product']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
* @param UpdateRequest $request
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Order $order, UpdateRequest $request)
|
||||
{
|
||||
return new static($order, [
|
||||
//'price_total' => $request->getTotal(),
|
||||
'price_product' => $request->getProductTotal(),
|
||||
//'price_delivery' => $request->getDeliveryPrice(),
|
||||
|
||||
//'shipment_date' => $request->shipment_date(),
|
||||
//'type_delivery' => $request->getTypeDelivery(),
|
||||
//'payment_type' => $request->getPaymentType(),
|
||||
//'branch_id' => $request->getBranchID(),
|
||||
|
||||
//'discount' => $request->getDiscount(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return $this->order->update($this->attr);
|
||||
}
|
||||
}
|
||||
53
app/Jobs/Dashboard/Page/Store.php
Executable file
53
app/Jobs/Dashboard/Page/Store.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Page;
|
||||
|
||||
use App\Models\Page;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Page\Store as Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'body', 'slug', 'keywords', 'descriptions']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'slug' => Str::slug($request->name['ru']),
|
||||
'body' => $request->getBody(),
|
||||
'keywords' => $request->keywords,
|
||||
'descriptions' => $request->descriptions
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$page = Page::create($this->attr);
|
||||
|
||||
$lastPage = Page::latest('id')->first();
|
||||
|
||||
$page->update([
|
||||
'type' => $lastPage->type + 1
|
||||
]);
|
||||
}
|
||||
}
|
||||
52
app/Jobs/Dashboard/Page/Update.php
Executable file
52
app/Jobs/Dashboard/Page/Update.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Page;
|
||||
|
||||
use App\Models\Page;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Page\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $page;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Page $page
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Page $page, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'body', 'keywords', 'descriptions']);
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Page $page, Request $request)
|
||||
{
|
||||
return new static($page, [
|
||||
'name' => $request->getName(),
|
||||
//'slug' => $request->name['ru'],
|
||||
'body' => $request->getBody(),
|
||||
|
||||
'keywords' => $request->keywords,
|
||||
'descriptions' => $request->descriptions
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->page->update($this->attr);
|
||||
}
|
||||
}
|
||||
48
app/Jobs/Dashboard/Partner/Store.php
Executable file
48
app/Jobs/Dashboard/Partner/Store.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Partner;
|
||||
|
||||
use App\Models\Partner;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Partner\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'image', 'status', 'video_url', 'description', "position", 'is_price']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $path)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'image' => $path,
|
||||
'status' => $request->status,
|
||||
'video_url' => $request->video_url,
|
||||
'description' => $request->getDescription(),
|
||||
'position' => $request->position,
|
||||
'is_price' => $request->is_price == null ? false : true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Partner::create($this->attr);
|
||||
}
|
||||
}
|
||||
53
app/Jobs/Dashboard/Partner/Update.php
Executable file
53
app/Jobs/Dashboard/Partner/Update.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Partner;
|
||||
|
||||
use App\Models\Partner;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Partner\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $partner;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Partner $partner
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Partner $partner, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'image', 'status', 'video_url', 'description', "position", 'is_price']);
|
||||
$this->partner = $partner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Partner $partner
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Partner $partner, Request $request, $path)
|
||||
{
|
||||
return new static($partner, [
|
||||
'name' => $request->getName(),
|
||||
'image' => $path,
|
||||
'status' => $request->status,
|
||||
'video_url' => $request->video_url,
|
||||
'description' => $request->getDescription(),
|
||||
'position' => $request->position,
|
||||
'is_price' => $request->is_price == null ? false : true,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->partner->update($this->attr);
|
||||
}
|
||||
}
|
||||
60
app/Jobs/Dashboard/Post/Store.php
Executable file
60
app/Jobs/Dashboard/Post/Store.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Post;
|
||||
|
||||
use App\Models\Post;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Post\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, [
|
||||
'name',
|
||||
'content',
|
||||
'topped',
|
||||
'language',
|
||||
'image',
|
||||
'type',
|
||||
'keywords',
|
||||
'descriptions',
|
||||
'position'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $path)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'content' => $request->getBody(),
|
||||
'topped' => $request->getTopped(),
|
||||
'language' => $request->getLanguage(),
|
||||
'image' => $path,
|
||||
'type' => $request->getType(),
|
||||
'keywords' => $request->keywords,
|
||||
'descriptions' => $request->descriptions,
|
||||
'position' => $request->getPosition()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Post::create($this->attr);
|
||||
}
|
||||
}
|
||||
65
app/Jobs/Dashboard/Post/Update.php
Executable file
65
app/Jobs/Dashboard/Post/Update.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Post;
|
||||
|
||||
use App\Models\Post;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Post\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $post;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Post $post
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Post $post, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, [
|
||||
'name',
|
||||
'content',
|
||||
'topped',
|
||||
'language',
|
||||
'image',
|
||||
'type',
|
||||
'keywords',
|
||||
'descriptions',
|
||||
'position'
|
||||
]);
|
||||
$this->post = $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Post $post
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Post $post, Request $request, $path)
|
||||
{
|
||||
return new static($post, [
|
||||
'name' => $request->getName(),
|
||||
'content' => $request->getBody(),
|
||||
'topped' => $request->getTopped(),
|
||||
'language' => $request->getLanguage(),
|
||||
'image' => $path,
|
||||
'type' => $request->getType(),
|
||||
'keywords' => $request->keywords,
|
||||
'descriptions' => $request->descriptions,
|
||||
'position' => $request->getPosition()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->post->update($this->attr);
|
||||
}
|
||||
}
|
||||
95
app/Jobs/Dashboard/Product/Child.php
Executable file
95
app/Jobs/Dashboard/Product/Child.php
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Product;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\Screen;
|
||||
use Carbon\Carbon;
|
||||
use App\Api\ImageResize;
|
||||
use App\Http\Requests\Dashboard\Product\Store as StoreRequest;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class Child
|
||||
{
|
||||
protected $request;
|
||||
protected $image;
|
||||
protected $product;
|
||||
protected $size;
|
||||
|
||||
/**
|
||||
* Child constructor.
|
||||
* @param StoreRequest $request
|
||||
* @param Product $product
|
||||
*/
|
||||
public function __construct(StoreRequest $request, Product $product)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->product = $product;
|
||||
$this->image = new ImageResize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
foreach ($this->request->colors as $color) {
|
||||
$color_id = $color['color_id'] == "null" ? null : $color['color_id'];
|
||||
$sizes = !empty($color['sizes']) ? $color['sizes'] : null;
|
||||
|
||||
$child = Product::create([
|
||||
'color_id' => $color_id,
|
||||
'sizes' => $sizes,
|
||||
'article_number' => $color['article_number'],
|
||||
'child_id' => $this->product->id,
|
||||
'published' => $this->product->published,
|
||||
'available' => true
|
||||
]);
|
||||
|
||||
if (!empty($color['screens'])) {
|
||||
foreach ($color['screens'] as $screen) {
|
||||
$folder = Carbon::now()->format('Y/m/d');
|
||||
|
||||
$path = $screen['image']->store($screen['image']);
|
||||
|
||||
$thumbPath = $this->storeImageToS3($screen['image']);
|
||||
|
||||
Screen::create([
|
||||
'path' => $path,
|
||||
'path_thumb' => $thumbPath,
|
||||
'name' => basename($path),
|
||||
'product_id' => $child->id,
|
||||
'size' => $this->size
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function storeImageToS3($image): string
|
||||
{
|
||||
$path = '';
|
||||
// first store temp file and resize it, then upload to s3
|
||||
// 1 - store temp file
|
||||
$tempPath = $image->store('temp', 'public');
|
||||
if ($tempPath) {
|
||||
$tempFilePath = storage_path('app/public/' . $tempPath);
|
||||
$image = new ImageResize();
|
||||
$path = $image->resize($tempPath, 322, 'screens');
|
||||
|
||||
$this->size = filesize(public_path($path));
|
||||
|
||||
// 2 - upload local $path to s3
|
||||
// Store the image on S3
|
||||
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
|
||||
Storage::disk('s3')->put($path, file_get_contents(public_path($path)));
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
100
app/Jobs/Dashboard/Product/ChildUpdate.php
Executable file
100
app/Jobs/Dashboard/Product/ChildUpdate.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Product;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\Screen;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Api\ImageResize;
|
||||
use App\Http\Requests\Dashboard\Product\Update as UpdateRequest;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ChildUpdate
|
||||
{
|
||||
|
||||
protected $product;
|
||||
protected $request;
|
||||
protected $image;
|
||||
|
||||
/**
|
||||
* ChildUpdate constructor.
|
||||
* @param UpdateRequest $request
|
||||
* @param Product $product
|
||||
*/
|
||||
public function __construct(UpdateRequest $request, Product $product)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->product = $product;
|
||||
$this->image = new ImageResize();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if ($this->request->colors)
|
||||
foreach ($this->request->colors as $color) {
|
||||
|
||||
$id = $color['id'] == "null" ? null : $color['id'];
|
||||
$color_id = $color['color_id'] == "null" ? null : $color['color_id'];
|
||||
$sizes = !empty($color['sizes']) ? $color['sizes'] : null;
|
||||
|
||||
if ($id == null) {
|
||||
$child = Product::create([
|
||||
'color_id' => $color_id,
|
||||
'sizes' => $sizes,
|
||||
'article_number' => $color['article_number'],
|
||||
'child_id' => $this->product->id,
|
||||
//'published' => $this->product->published,
|
||||
//'available' => true
|
||||
]);
|
||||
|
||||
if (!empty($color['screens'])) {
|
||||
$this->uploadScreen($color['screens'], $child->id);
|
||||
}
|
||||
} else {
|
||||
$child = Product::find($id)->update([
|
||||
'color_id' => $color_id,
|
||||
'sizes' => $sizes,
|
||||
'article_number' => $color['article_number'],
|
||||
'child_id' => $this->product->id,
|
||||
//'published' => $this->product->published,
|
||||
//'available' => true
|
||||
]);
|
||||
|
||||
if (!empty($color['screens'])) {
|
||||
$this->uploadScreen($color['screens'], $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $screens
|
||||
* @param $child_id
|
||||
*/
|
||||
private function uploadScreen($screens, $child_id)
|
||||
{
|
||||
if (!empty($screens)) {
|
||||
foreach ($screens as $screen) {
|
||||
if ($screen['id'] == 'undefined' || $screen['id'] == 'null' || $screen['id'] = null) {
|
||||
$folder = Carbon::now()->format('Y/m/d');
|
||||
if ($screen['image']) {
|
||||
$path = $screen['image']->store("uploads/screens/{$folder}");
|
||||
$image = Screen::create([
|
||||
'path' => $path,
|
||||
'path_thumb' => "uploads/screens/thumbs/{$folder}/" . basename($path),
|
||||
'name' => basename($path),
|
||||
'product_id' => $child_id,
|
||||
'size' => Storage::size($path)
|
||||
]);
|
||||
|
||||
$this->image->resize($image->path, 322, 'screens');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
app/Jobs/Dashboard/Product/Deletes.php
Executable file
56
app/Jobs/Dashboard/Product/Deletes.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Product;
|
||||
|
||||
use App\Http\Requests\Dashboard\Product\Update as Request;
|
||||
use App\Models\Screen;
|
||||
use App\Models\Product;
|
||||
|
||||
class Deletes
|
||||
{
|
||||
|
||||
protected $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if ($this->request->deletes) {
|
||||
|
||||
if (!empty($this->request->deletes['screens'])) {
|
||||
foreach ($this->request->deletes['screens'] as $screen) {
|
||||
$sc = Screen::where('id', $screen)->first();
|
||||
if (!empty($sc)) {
|
||||
if (is_file($sc->path)) {
|
||||
unlink($sc->path);
|
||||
}
|
||||
|
||||
if (is_file($sc->path_thumb)) {
|
||||
unlink($sc->path_thumb);
|
||||
}
|
||||
|
||||
$sc->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->request->deletes['childrens'])) {
|
||||
foreach ($this->request->deletes['childrens'] as $children) {
|
||||
$child = Product::find($children);
|
||||
if (!empty($child)) {
|
||||
$child->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
52
app/Jobs/Dashboard/Product/Screen.php
Executable file
52
app/Jobs/Dashboard/Product/Screen.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Product;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Models\Screen as Screens;
|
||||
use App\Api\ImageResize;
|
||||
|
||||
|
||||
class Screen
|
||||
{
|
||||
protected $request;
|
||||
protected $id;
|
||||
protected $img;
|
||||
|
||||
/**
|
||||
* Screen constructor.
|
||||
* @param $request
|
||||
* @param $id
|
||||
*/
|
||||
public function __construct($request, $id)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->id = $id;
|
||||
$this->img = new ImageResize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$folder = Carbon::now()->format('Y/m/d');
|
||||
//$folder = 'uploads/screens/'.date('Y', time()).'/'.Carbon::now()->format('m').'/'.Carbon::now()->format('d');
|
||||
|
||||
foreach ($this->request as $screen) {
|
||||
$path = $screen->store("uploads/screens/original/{$folder}");
|
||||
$thumb = $this->img->resize($path, 350, 'screens');
|
||||
|
||||
$screens = new Screens();
|
||||
$screens->name = basename($path);
|
||||
$screens->path = $path;
|
||||
$screens->path_thumb = $thumb;
|
||||
$screens->size = filesize($path);
|
||||
$screens->product_id = $this->id;
|
||||
$screens->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
76
app/Jobs/Dashboard/Product/Store.php
Executable file
76
app/Jobs/Dashboard/Product/Store.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Product;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Http\Requests\Dashboard\Product\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['measurement_id', 'power', 'name', 'poster', 'poster_thumb', 'body', 'price', 'price_discount', 'price_credit', 'currency', 'slug', 'published', 'brand_id', 'short_body', 'article_number', 'leader_of_sales', 'popular', 'count', 'available', 'descriptions', 'keywords', 'title_seo', 'is_ready_solution', 'data_sheet']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
//'category_id' => $request->getCategoryID(),
|
||||
'brand_id' => $request->getBrandID(),
|
||||
'measurement_id' => $request->getMeasurementId(),
|
||||
|
||||
'currency' => $request->currency,
|
||||
|
||||
'price' => $request->getPrice(),
|
||||
'price_discount' => $request->getPriceDiscount(),
|
||||
// 'price_credit' => $request->getPriceCredit(),
|
||||
|
||||
'poster' => $request->getPoster(),
|
||||
'calc' => $request->getCalc(),
|
||||
'poster_thumb' => $request->getPosterThumb(),
|
||||
'is_ready_solution' => $request->is_ready_solution == false ? 0 : 1,
|
||||
'power' => $request->power,
|
||||
|
||||
'data_sheet' => $request->getDataSheet(),
|
||||
|
||||
'body' => $request->getBody(),
|
||||
'short_body' => $request->short_body,
|
||||
|
||||
'slug' => $request->getSlug(),
|
||||
'published' => $request->getPublished(),
|
||||
// 'popular' => $request->getPopular(),
|
||||
'leader_of_sales' => $request->getLeaderOfSales(),
|
||||
|
||||
'article_number' => $request->article_number,
|
||||
'count' => $request->count,
|
||||
'available' => $request->getAvailable(),
|
||||
'keywords' => $request->keywords,
|
||||
'descriptions' => $request->descriptions,
|
||||
'title_seo' => $request->title_seo,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$product = Product::create($this->attr);
|
||||
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
70
app/Jobs/Dashboard/Product/Update.php
Executable file
70
app/Jobs/Dashboard/Product/Update.php
Executable file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Product;
|
||||
|
||||
use App\Http\Requests\Dashboard\Product\Update as Request;
|
||||
use App\Models\Product;
|
||||
|
||||
class Update
|
||||
{
|
||||
protected $attr;
|
||||
protected $request;
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Product $product, Request $request)
|
||||
{
|
||||
$this->product = $product;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Product
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->product->update([
|
||||
'name' => $this->request->getName(),
|
||||
'brand_id' => $this->request->getBrandID(),
|
||||
'measurement_id' => $this->request->getMeasurementId(),
|
||||
'currency' => $this->request->currency,
|
||||
'is_ready_solution' => $this->request->is_ready_solution == 'false' ? 0 : 1,
|
||||
'price' => $this->request->getPrice(),
|
||||
'price_discount' => $this->request->getPriceDiscount(),
|
||||
'poster' => $this->request->getPoster($this->product),
|
||||
'calc' => $this->request->getCalc($this->product),
|
||||
'poster_thumb' => $this->request->getPosterThumb($this->product),
|
||||
'data_sheet' => $this->request->getDataSheet($this->product),
|
||||
'body' => $this->request->getBody(),
|
||||
'short_body' => $this->request->short_body,
|
||||
'power' => !in_array($this->request->power, [null, 'null', 'NULL']) ? $this->request->power : null,
|
||||
'slug' => $this->request->getSlug(),
|
||||
'published' => $this->request->getPublished(),
|
||||
// 'popular' => $this->request->getPopular(),
|
||||
'leader_of_sales' => $this->request->getLeaderOfSales(),
|
||||
'article_number' => $this->request->article_number,
|
||||
'count' => $this->request->count,
|
||||
'available' => $this->request->getAvailable(),
|
||||
'keywords' => $this->request->keywords,
|
||||
'descriptions' => $this->request->descriptions,
|
||||
'title_seo' => $this->request->title_seo,
|
||||
]);
|
||||
|
||||
$this->syncCategories();
|
||||
}
|
||||
|
||||
private function syncCategories()
|
||||
{
|
||||
$cats = $this->product->categories()->get();
|
||||
|
||||
$cats = array_map(function ($cat) {
|
||||
return $cat['id'];
|
||||
}, $cats->toArray());
|
||||
|
||||
$this->product->categories()->detach($cats);
|
||||
$this->product->categories()->attach([$this->request->getCategoryID()]);
|
||||
}
|
||||
}
|
||||
43
app/Jobs/Dashboard/Region/Store.php
Executable file
43
app/Jobs/Dashboard/Region/Store.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Region;
|
||||
|
||||
use App\Models\Region;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Region\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'cash']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'cash' => $request->getCash()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return Region::create($this->attr);
|
||||
}
|
||||
}
|
||||
48
app/Jobs/Dashboard/Region/Update.php
Executable file
48
app/Jobs/Dashboard/Region/Update.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Region;
|
||||
|
||||
use App\Models\Region;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Region\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $region;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Region $region
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Region $region, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'cash']);
|
||||
$this->region = $region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Region $region
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Region $region, Request $request)
|
||||
{
|
||||
return new static($region, [
|
||||
'name' => $request->getName(),
|
||||
'cash' => $request->getCash()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->region->update($this->attr);
|
||||
}
|
||||
}
|
||||
43
app/Jobs/Dashboard/Role/Store.php
Executable file
43
app/Jobs/Dashboard/Role/Store.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Role;
|
||||
|
||||
use App\Models\Role;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Role\Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'permissions']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'permissions' => $request->getPermissions(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Role::create($this->attr);
|
||||
}
|
||||
}
|
||||
47
app/Jobs/Dashboard/Role/Update.php
Executable file
47
app/Jobs/Dashboard/Role/Update.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Role;
|
||||
|
||||
use App\Models\Role;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Role\Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
protected $role;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Role $role
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Role $role, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'permissions']);
|
||||
$this->role = $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Role $role
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Role $role, Request $request)
|
||||
{
|
||||
return new static($role, [
|
||||
'name' => $request->getName(),
|
||||
'permissions' => $request->getPermissions(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->role->update($this->attr);
|
||||
}
|
||||
}
|
||||
46
app/Jobs/Dashboard/Service/Store.php
Executable file
46
app/Jobs/Dashboard/Service/Store.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Service;
|
||||
|
||||
use App\Models\Service;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Service\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'image', 'type', 'status', 'position', 'is_power']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $path)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'image' => $path,
|
||||
'status' => $request->status,
|
||||
'position' => $request->getPosition(),
|
||||
'is_power' => $request->is_power == null ? false : true,
|
||||
'type' => $request->generateSlug(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return Service::create($this->attr);
|
||||
}
|
||||
}
|
||||
51
app/Jobs/Dashboard/Service/Update.php
Executable file
51
app/Jobs/Dashboard/Service/Update.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Service;
|
||||
|
||||
use App\Models\Service;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Service\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
protected $service;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Service $service
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Service $service, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'image', 'type', 'status', 'position', 'is_power', 'with_problem']);
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Service $service
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Service $service, Request $request, $path)
|
||||
{
|
||||
return new static($service, [
|
||||
'name' => $request->getName(),
|
||||
'image' => $path,
|
||||
'status' => $request->status,
|
||||
'position' => $request->getPosition(),
|
||||
'is_power' => $request->is_power == null ? false : true,
|
||||
'with_problem' => $request->with_problem == null ? false : true,
|
||||
'type' => $request->generateSlug(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->service->update($this->attr);
|
||||
}
|
||||
}
|
||||
52
app/Jobs/Dashboard/Setting/Update.php
Executable file
52
app/Jobs/Dashboard/Setting/Update.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Setting;
|
||||
|
||||
use App\Http\Requests\Dashboard\Setting\Update as Request;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class Update
|
||||
{
|
||||
protected $attr;
|
||||
protected $setting;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Setting $setting
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Setting $setting, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['title', 'address', 'email', 'phone', 'socials', 'keywords', 'description', 'landmark', 'on_credit', 'permissions', 'links', 'buy_one', 'master_price', 'group_id']);
|
||||
$this->setting = $setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Setting $setting
|
||||
* @param Request $request
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Setting $setting, Request $request){
|
||||
return new static($setting, [
|
||||
'title' => $request->getTitle(),
|
||||
'address' => $request->getAddress(),
|
||||
'keywords' => $request->getKeywords(),
|
||||
'description' => $request->getDescription(),
|
||||
'email' => $request->getEmail(),
|
||||
'phone' => $request->getPhone(),
|
||||
'socials' => $request->getSocials(),
|
||||
'landmark' => $request->getLandmark(),
|
||||
'master_price' => $request->master_price,
|
||||
'group_id' => $request->getGroupId(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->setting->update($this->attr);
|
||||
}
|
||||
}
|
||||
49
app/Jobs/Dashboard/Slider/Store.php
Executable file
49
app/Jobs/Dashboard/Slider/Store.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Slider;
|
||||
|
||||
use App\Models\Slider;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Slider\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['link', 'image', 'language', 'name', 'type', 'placement', 'published', 'position']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $path)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'link' => $request->getLink(),
|
||||
'language' => $request->getLanguage(),
|
||||
'type' => $request->getType(),
|
||||
'image' => $path,
|
||||
'position' => $request->getPosition(),
|
||||
'placement' => $request->getPlacement(),
|
||||
'published' => $request->getPublished()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Slider::create($this->attr);
|
||||
}
|
||||
}
|
||||
53
app/Jobs/Dashboard/Slider/Update.php
Executable file
53
app/Jobs/Dashboard/Slider/Update.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\Slider;
|
||||
|
||||
use App\Models\Slider;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\Slider\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $slider;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Slider $slider
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(Slider $slider, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['link', 'image', 'language', 'name', 'type', 'placement', 'published']);
|
||||
$this->slider = $slider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Slider $slider
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(Slider $slider, Request $request, $path)
|
||||
{
|
||||
return new static($slider, [
|
||||
'name' => $request->getName(),
|
||||
'link' => $request->getLink(),
|
||||
'image' => $path,
|
||||
'type' => $request->getType(),
|
||||
'language' => $request->getLanguage(),
|
||||
'placement' => $request->getPlacement(),
|
||||
'published' => $request->getPublished()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->slider->update($this->attr);
|
||||
}
|
||||
}
|
||||
50
app/Jobs/Dashboard/SpecialOffer/Store.php
Executable file
50
app/Jobs/Dashboard/SpecialOffer/Store.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\SpecialOffer;
|
||||
|
||||
use App\Models\SpecialOffer;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\SpecialOffer\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, [
|
||||
'name',
|
||||
'description',
|
||||
'link',
|
||||
'image'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $path)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'description' => $request->getDescription(),
|
||||
'link' => $request->getLink(),
|
||||
'image' => $path
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
SpecialOffer::create($this->attr);
|
||||
}
|
||||
}
|
||||
55
app/Jobs/Dashboard/SpecialOffer/Update.php
Executable file
55
app/Jobs/Dashboard/SpecialOffer/Update.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\SpecialOffer;
|
||||
|
||||
use App\Models\SpecialOffer;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\SpecialOffer\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
|
||||
protected $specialOffer;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param SpecialOffer $specialOffer
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(SpecialOffer $specialOffer, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, [
|
||||
'name',
|
||||
'description',
|
||||
'link',
|
||||
'image'
|
||||
]);
|
||||
$this->specialOffer = $specialOffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SpecialOffer $specialOffer
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(SpecialOffer $specialOffer, Request $request, $path)
|
||||
{
|
||||
return new static($specialOffer, [
|
||||
'name' => $request->getName(),
|
||||
'description' => $request->getDescription(),
|
||||
'link' => $request->getLink(),
|
||||
'image' => $path
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->specialOffer->update($this->attr);
|
||||
}
|
||||
}
|
||||
47
app/Jobs/Dashboard/UsefulInfoItemJob/Store.php
Executable file
47
app/Jobs/Dashboard/UsefulInfoItemJob/Store.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\UsefulInfoItemJob;
|
||||
|
||||
use App\Models\UsefulInfoItem;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\UsefulInfoItemRequest\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'description', 'file_url', 'video_url', 'link_url', 'useful_info_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $file_path
|
||||
* @param $useful_info_id
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $file_path, $useful_info_id)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'description' => $request->getDescription(),
|
||||
'video_url' => $request->video_url,
|
||||
'link_url' => $request->link_url,
|
||||
'file_url' => $file_path,
|
||||
'useful_info_id' => $useful_info_id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
UsefulInfoItem::create($this->attr);
|
||||
}
|
||||
}
|
||||
49
app/Jobs/Dashboard/UsefulInfoItemJob/Update.php
Executable file
49
app/Jobs/Dashboard/UsefulInfoItemJob/Update.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\UsefulInfoItemJob;
|
||||
|
||||
use App\Models\UsefulInfoItem;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\UsefulInfoItemRequest\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
protected $usefulInfoItem;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param UsefulInfoItem $usefulInfoItem
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(UsefulInfoItem $usefulInfoItem, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'file_url', 'description', 'video_url', 'link_url', 'useful_info_id']);
|
||||
$this->usefulInfoItem = $usefulInfoItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UsefulInfoItem $usefulInfoItem
|
||||
* @param Request $request
|
||||
* @param $file_path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(UsefulInfoItem $usefulInfoItem, Request $request, $file_path)
|
||||
{
|
||||
return new static($usefulInfoItem, [
|
||||
'name' => $request->getName(),
|
||||
'description' => $request->getDescription(),
|
||||
'video_url' => $request->video_url,
|
||||
'link_url' => $request->link_url,
|
||||
'file_url' => $file_path,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->usefulInfoItem->update($this->attr);
|
||||
}
|
||||
}
|
||||
43
app/Jobs/Dashboard/UsefulInfoJob/Store.php
Executable file
43
app/Jobs/Dashboard/UsefulInfoJob/Store.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\UsefulInfoJob;
|
||||
|
||||
use App\Models\UsefulInfo;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\UsefulInfoRequest\Store as Request;
|
||||
|
||||
class Store
|
||||
{
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'image', 'position']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Store
|
||||
*/
|
||||
public static function fromRequest(Request $request, $path)
|
||||
{
|
||||
return new static([
|
||||
'name' => $request->getName(),
|
||||
'image' => $path,
|
||||
'position' => $request->getPosition()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
UsefulInfo::create($this->attr);
|
||||
}
|
||||
}
|
||||
47
app/Jobs/Dashboard/UsefulInfoJob/Update.php
Executable file
47
app/Jobs/Dashboard/UsefulInfoJob/Update.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\UsefulInfoJob;
|
||||
|
||||
use App\Models\UsefulInfo;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\UsefulInfoRequest\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
protected $usefulinfo;
|
||||
protected $attr;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param UsefulInfo $usefulinfo
|
||||
* @param array $attr
|
||||
*/
|
||||
public function __construct(UsefulInfo $usefulinfo, array $attr = [])
|
||||
{
|
||||
$this->attr = Arr::only($attr, ['name', 'image', 'position']);
|
||||
$this->usefulinfo = $usefulinfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UsefulInfo $usefulinfo
|
||||
* @param Request $request
|
||||
* @param $path
|
||||
* @return Update
|
||||
*/
|
||||
public static function fromRequest(UsefulInfo $usefulinfo, Request $request, $path)
|
||||
{
|
||||
return new static($usefulinfo, [
|
||||
'name' => $request->getName(),
|
||||
'image' => $path,
|
||||
'position' => $request->getPosition()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->usefulinfo->update($this->attr);
|
||||
}
|
||||
}
|
||||
32
app/Jobs/Dashboard/User/Create.php
Executable file
32
app/Jobs/Dashboard/User/Create.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\User;
|
||||
|
||||
use App\Models\Staff;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use \App\Http\Requests\Dashboard\User\Create as Request;
|
||||
|
||||
class Create
|
||||
{
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user = Staff::create($this->request->validated());
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
50
app/Jobs/Dashboard/User/Edit.php
Executable file
50
app/Jobs/Dashboard/User/Edit.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\User;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Http\Requests\Dashboard\User\Edit as EditRequest;
|
||||
|
||||
|
||||
|
||||
class Edit
|
||||
{
|
||||
|
||||
protected $user;
|
||||
protected $attr;
|
||||
|
||||
public function __construct(User $user, array $attr = [])
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->attr = Arr::only($attr, ['first_name', 'last_name', 'gender', 'birth_day', 'category_id', 'role_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param EditRequest $request
|
||||
* @return static
|
||||
*/
|
||||
public static function fromRequest(User $user, EditRequest $request)
|
||||
{
|
||||
return new static($user, [
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'gender' => $request->gender,
|
||||
'birth_day' => $request->birth_day,
|
||||
'category_id' => $request->category_id,
|
||||
'role_id' => $request->role_id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->user->update($this->attr);
|
||||
}
|
||||
}
|
||||
34
app/Jobs/Dashboard/User/Update.php
Executable file
34
app/Jobs/Dashboard/User/Update.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Dashboard\User;
|
||||
|
||||
use App\Models\Staff;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests\Dashboard\User\Update as Request;
|
||||
|
||||
class Update
|
||||
{
|
||||
// protected $attr;
|
||||
protected $staff;
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Update constructor.
|
||||
* @param User $staff
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Staff $staff, Request $request)
|
||||
{
|
||||
$this->staff = $staff;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return $this->staff->update($this->request->validated());
|
||||
}
|
||||
}
|
||||
33
app/Jobs/Site/Checkout/AddressStoreJob.php
Executable file
33
app/Jobs/Site/Checkout/AddressStoreJob.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Site\Checkout;
|
||||
|
||||
use App\Models\Address;
|
||||
|
||||
class AddressStoreJob
|
||||
{
|
||||
protected $request;
|
||||
|
||||
public function __construct($request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$phone_other = $this->request->address['other_phone'] ? str_replace(['+', '(', ')', ' ', '-'], '', $this->request->address['other_phone']) : null;
|
||||
return Address::create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'first_name' => !empty(auth()->user()->first_name) ? auth()->user()->first_name : 'NoName',
|
||||
'phone_other' => $phone_other,
|
||||
'phone' => auth()->user()->phone,
|
||||
'city_id' => $this->request->address['city_id'],
|
||||
'street' => $this->request->address['address'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
34
app/Jobs/Site/Checkout/BillingStoreJob.php
Executable file
34
app/Jobs/Site/Checkout/BillingStoreJob.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Site\Checkout;
|
||||
|
||||
use App\Models\Billing;
|
||||
|
||||
class BillingStoreJob
|
||||
{
|
||||
|
||||
protected $order;
|
||||
protected $total;
|
||||
protected $payment_system;
|
||||
|
||||
public function __construct($order, $total, $payment_system)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->total = $total;
|
||||
$this->payment_system = $payment_system;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return Billing::create([
|
||||
'order_id' => $this->order->id,
|
||||
'amount' => $this->total,
|
||||
'payment_system' => $this->payment_system
|
||||
]);
|
||||
}
|
||||
}
|
||||
56
app/Jobs/Site/Checkout/ProductsOrderStoreJob.php
Executable file
56
app/Jobs/Site/Checkout/ProductsOrderStoreJob.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Site\Checkout;
|
||||
|
||||
use App\Models\Cart as CartModel;
|
||||
use App\Models\OrderProducts;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ProductsOrderStoreJob
|
||||
{
|
||||
protected $request;
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* ProductsOrderStoreJob constructor.
|
||||
* @param $request
|
||||
* @param $order
|
||||
*/
|
||||
public function __construct($request, $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
foreach ($this->request->products as $product) {
|
||||
$cart = CartModel::where('id', $product)->first();
|
||||
if (!empty($cart)) {
|
||||
$discount = $cart->product->product->price_discount ? 100 - $cart->product->product->price_discount * 100 / $cart->product->product->price : null;
|
||||
|
||||
// if ($this->request->payment_type == 'cash') {
|
||||
$product = Product::find($cart->product->product->id);
|
||||
$product->count = $product->count - (int) $cart->count;
|
||||
$product->save();
|
||||
// }
|
||||
|
||||
OrderProducts::create([
|
||||
'order_id' => $this->order->id,
|
||||
'product_id' => $cart->product->product->id,
|
||||
'discount' => round($discount),
|
||||
'count' => $cart->count,
|
||||
'size' => $cart->size,
|
||||
'color_id' => $cart->product_id,
|
||||
'price' => $cart->product->product->price_discount ? round($cart->product->product->price_discount, 0) : round($cart->product->product->price, 0)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
49
app/Jobs/Site/Checkout/StoreJob.php
Executable file
49
app/Jobs/Site/Checkout/StoreJob.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Site\Checkout;
|
||||
|
||||
use App\Models\Order;
|
||||
|
||||
class StoreJob
|
||||
{
|
||||
protected $request;
|
||||
protected $address;
|
||||
protected $delivery_price;
|
||||
protected $price_product;
|
||||
protected $currency;
|
||||
|
||||
/**
|
||||
* StoreJob constructor.
|
||||
* @param $request
|
||||
* @param $address
|
||||
* @param $delivery_price
|
||||
* @param $currency
|
||||
* @param $product_total
|
||||
*/
|
||||
public function __construct($request, $address, $delivery_price, $currency, $product_total)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->address = $address;
|
||||
$this->delivery_price = $delivery_price;
|
||||
$this->currency = $currency;
|
||||
$this->price_product = $product_total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return Order::create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'address_id' => $this->address === null ? null : $this->address->id,
|
||||
'type_delivery' => $this->request->delivery_type,
|
||||
'price_delivery' => $this->delivery_price,
|
||||
'currency' => $this->currency,
|
||||
'payment_type' => $this->request->payment_type,
|
||||
'payment_status' => $this->request->getPaymentStatus(),
|
||||
'comment' => $this->request->address['comment'],
|
||||
'price_product' => $this->price_product
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user