codigo actual del servidor, con avances de joan
This commit is contained in:
35
app/Http/Resources/PosProductCollection.php
Normal file
35
app/Http/Resources/PosProductCollection.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PosProductCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'stock_id' => $data->stock_id,
|
||||
'name' => $data->name,
|
||||
'thumbnail_image' => ($data->stock_image == null) ? uploaded_asset($data->thumbnail_img) : uploaded_asset($data->stock_image),
|
||||
'price' => home_discounted_base_price_by_stock_id($data->stock_id),
|
||||
'base_price' => home_base_price_by_stock_id($data->stock_id),
|
||||
'qty' => $data->stock_qty,
|
||||
'variant' => $data->variant,
|
||||
'digital' => $data->digital,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
52
app/Http/Resources/V2/AddressCollection.php
Normal file
52
app/Http/Resources/V2/AddressCollection.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AddressCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
|
||||
$location_available = false;
|
||||
$lat = 90.99;
|
||||
$lang = 180.99;
|
||||
|
||||
if($data->latitude || $data->longitude) {
|
||||
$location_available = true;
|
||||
$lat = floatval($data->latitude) ;
|
||||
$lang = floatval($data->longitude);
|
||||
}
|
||||
|
||||
return [
|
||||
'id' =>(int) $data->id,
|
||||
'user_id' =>(int) $data->user_id,
|
||||
'address' => $data->address,
|
||||
'country_id' => (int) $data->country_id,
|
||||
'state_id' => (int) $data->state_id,
|
||||
'city_id' => (int) $data->city_id,
|
||||
'country_name' => $data->country->name,
|
||||
'state_name' => $data->state->name,
|
||||
'city_name' => $data->city->name,
|
||||
'postal_code' => $data->postal_code,
|
||||
'phone' => $data->phone,
|
||||
'set_default' =>(int) $data->set_default,
|
||||
'location_available' => $location_available,
|
||||
'lat' => $lat,
|
||||
'lang' => $lang,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/V2/AuctionMiniCollection.php
Normal file
40
app/Http/Resources/V2/AuctionMiniCollection.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AuctionMiniCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
|
||||
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'has_discount' => home_base_price($data, false) != home_discounted_base_price($data, false),
|
||||
// 'discount' => "-" . discount_in_percentage($data) . "%",
|
||||
// 'stroked_price' => home_base_price($data),
|
||||
'main_price' => single_price($data->starting_bid),
|
||||
'rating' => (float) $data->rating,
|
||||
'sales' => (int) $data->num_of_sale,
|
||||
'links' => [
|
||||
'details' => route('products.show', $data->id),
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
97
app/Http/Resources/V2/AuctionProductDetailCollection.php
Normal file
97
app/Http/Resources/V2/AuctionProductDetailCollection.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use App\Models\Review;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AuctionProductDetailCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
|
||||
//photos
|
||||
$photo_paths = get_images_path($data->photos);
|
||||
$photos = [];
|
||||
if (!empty($photo_paths)) {
|
||||
for ($i = 0; $i < count($photo_paths); $i++) {
|
||||
if ($photo_paths[$i] != "") {
|
||||
$item = array();
|
||||
$item['variant'] = "";
|
||||
$item['path'] = $photo_paths[$i];
|
||||
$photos[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//branc
|
||||
|
||||
$brand = [
|
||||
'id' => 0,
|
||||
'name' => "",
|
||||
'logo' => "",
|
||||
];
|
||||
|
||||
if ($data->brand != null) {
|
||||
$brand = [
|
||||
'id' => $data->brand->id,
|
||||
'name' => $data->brand->getTranslation('name'),
|
||||
'logo' => uploaded_asset($data->brand->logo),
|
||||
];
|
||||
}
|
||||
$unit = '';
|
||||
if ($data->unit != null) {
|
||||
$unit = $data->getTranslation('unit');
|
||||
}
|
||||
// highest bids
|
||||
$highest_bid = $data->bids->max('amount');
|
||||
|
||||
|
||||
return [
|
||||
'id' => (int)$data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'added_by' => $data->added_by,
|
||||
'seller_id' => $data->user->id,
|
||||
'shop_id' => $data->added_by == 'admin' ? 0 : $data->user->shop->id,
|
||||
'shop_name' => $data->added_by == 'admin' ? translate('In House Product') : $data->user->shop->name,
|
||||
'shop_logo' => $data->added_by == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($data->user->shop->logo) ?? "",
|
||||
'photos' => $photos,
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'tags' => explode(',', $data->tags),
|
||||
'rating' => (float)$data->rating,
|
||||
'rating_count' => (int)Review::where(['product_id' => $data->id])->count(),
|
||||
'brand' => $brand,
|
||||
// "auction_end_date" => $data->auction_end_date > strtotime('now') ? date('Y/m/d H:i:s', $data->auction_end_date) : 'Ended',
|
||||
"auction_end_date" => $data->auction_end_date > strtotime('now') ? $data->auction_end_date : 'Ended',
|
||||
"starting_bid" => single_price($data->starting_bid),
|
||||
'unit' => $unit,
|
||||
'min_bid_price' => $highest_bid != null? ($highest_bid +1): $data->starting_bid,
|
||||
'highest_bid' => $highest_bid != null ? single_price($highest_bid) : '',
|
||||
'description' => str_replace(' ', ' ', strip_tags($data->getTranslation('description'))),
|
||||
'video_link' => $data->video_link != null ? $data->video_link : "",
|
||||
'link' => route('product', $data->slug)
|
||||
// 'data' => $data
|
||||
|
||||
|
||||
];
|
||||
})
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/BannerCollection.php
Normal file
29
app/Http/Resources/V2/BannerCollection.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class BannerCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'photo' => uploaded_asset($data),
|
||||
'url' => route('home'),
|
||||
'position' => 1
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Resources/V2/BrandCollection.php
Normal file
32
app/Http/Resources/V2/BrandCollection.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class BrandCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'logo' => uploaded_asset($data->logo),
|
||||
'links' => [
|
||||
'products' => route('api.products.brand', $data->id)
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Resources/V2/BusinessSettingCollection.php
Normal file
28
app/Http/Resources/V2/BusinessSettingCollection.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class BusinessSettingCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'type' => $data->type,
|
||||
'value' => $data->type == 'verification_form' ? json_decode($data->value) : $data->value
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/V2/CarrierCollection.php
Normal file
40
app/Http/Resources/V2/CarrierCollection.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class CarrierCollection extends ResourceCollection
|
||||
{
|
||||
protected $ownerId;
|
||||
|
||||
public function extra($owner_id){
|
||||
$this->ownerId = $owner_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->name,
|
||||
'logo' => uploaded_asset($data->logo),
|
||||
'transit_time' => (integer) $data->transit_time,
|
||||
'free_shipping' => $data->free_shipping == 1 ? true : false,
|
||||
'transit_price' => single_price(carrier_base_price(auth()->user()->carts, $data->id, $this->ownerId)),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/V2/CartCollection.php
Normal file
38
app/Http/Resources/V2/CartCollection.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class CartCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'seller_id' => $data->seller_id,
|
||||
'product' => [
|
||||
'name' => $data->product->name,
|
||||
'image' => uploaded_asset($data->product->thumbnail_img)
|
||||
],
|
||||
'variation' => $data->variation,
|
||||
'price' => (double) cart_product_price($data, $data->product, false, false),
|
||||
'tax' => (double)cart_product_tax($data, $data->product ,false),
|
||||
'shipping_cost' => (double) $data->shipping_cost,
|
||||
'quantity' => (integer) $data->quantity,
|
||||
'date' => $data->created_at->diffForHumans()
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Http/Resources/V2/CategoryCollection.php
Normal file
44
app/Http/Resources/V2/CategoryCollection.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Utility\CategoryUtility;
|
||||
|
||||
class CategoryCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
$banner ='';
|
||||
if(uploaded_asset($data->banner)) {
|
||||
$banner = uploaded_asset($data->banner);
|
||||
}
|
||||
$icon ='';
|
||||
if(uploaded_asset(uploaded_asset($data->icon))) {
|
||||
$icon = uploaded_asset($data->icon);
|
||||
}
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'banner' => $banner,
|
||||
'icon' => $icon,
|
||||
'number_of_children' => CategoryUtility::get_immediate_children_count($data->id),
|
||||
'links' => [
|
||||
'products' => route('api.products.category', $data->id),
|
||||
'sub_categories' => route('subCategories.index', $data->id)
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/V2/CitiesCollection.php
Normal file
30
app/Http/Resources/V2/CitiesCollection.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class CitiesCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' =>(int) $data->id,
|
||||
'state_id' => (int) $data->state_id,
|
||||
'name' => $data->name,
|
||||
'cost' => $data->cost,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
102
app/Http/Resources/V2/ClassifiedProductDetailCollection.php
Normal file
102
app/Http/Resources/V2/ClassifiedProductDetailCollection.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Models\Review;
|
||||
use App\Models\Attribute;
|
||||
|
||||
|
||||
class ClassifiedProductDetailCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
|
||||
$photo_paths = get_images_path($data->photos);
|
||||
|
||||
$photos = [];
|
||||
|
||||
|
||||
if (!empty($photo_paths)) {
|
||||
for ($i = 0; $i < count($photo_paths); $i++) {
|
||||
if ($photo_paths[$i] != "" ) {
|
||||
$item = array();
|
||||
$item['variant'] = "";
|
||||
$item['path'] = $photo_paths[$i];
|
||||
$photos[]= $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$brand = [
|
||||
'id'=> 0,
|
||||
'name'=> "",
|
||||
'logo'=> "",
|
||||
];
|
||||
|
||||
if($data->brand != null) {
|
||||
$brand = [
|
||||
'id'=> $data->brand->id,
|
||||
'name'=> $data->brand->getTranslation('name'),
|
||||
'logo'=> uploaded_asset($data->brand->logo),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'id' => (integer)$data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'added_by' => $data->user->name,
|
||||
'phone' => $data->user->phone??"",
|
||||
'condition'=>$data->conditon,
|
||||
'photos' => $photos,
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'tags' => explode(',', $data->tags),
|
||||
'location' => $data->location,
|
||||
'unit_price' => single_price($data->unit_price),
|
||||
'unit' => $data->unit??"",
|
||||
'description' => $data->getTranslation('description'),
|
||||
'video_link' => $data->video_link != null ? $data->video_link : "",
|
||||
'brand' => $brand,
|
||||
'category' => $data->category->name,
|
||||
'link' => route('product', $data->slug)
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
|
||||
protected function convertToChoiceOptions($data)
|
||||
{
|
||||
$result = array();
|
||||
if($data) {
|
||||
foreach ($data as $key => $choice) {
|
||||
$item['name'] = $choice->attribute_id;
|
||||
$item['title'] = Attribute::find($choice->attribute_id)->getTranslation('name');
|
||||
$item['options'] = $choice->values;
|
||||
array_push($result, $item);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function convertPhotos($data)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($data as $key => $item) {
|
||||
array_push($result, uploaded_asset($item));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/V2/ClassifiedProductMiniCollection.php
Normal file
36
app/Http/Resources/V2/ClassifiedProductMiniCollection.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ClassifiedProductMiniCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
|
||||
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'condition'=>$data->conditon,
|
||||
'unit_price' => single_price($data->unit_price),
|
||||
'category' => $data->category->name,
|
||||
'published' => $data->published==1?true:false,
|
||||
'status' => $data->status==1?true:false,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/V2/ClubpointCollection.php
Normal file
37
app/Http/Resources/V2/ClubpointCollection.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ClubpointCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
|
||||
$points = number_format($data->points, 2, '.', '');
|
||||
$points = floatval($points);
|
||||
|
||||
return [
|
||||
'id' => (int) $data->id,
|
||||
'user_id' => (int) $data->user_id,
|
||||
'order_code' =>$data->order->code,
|
||||
'convertible_club_point' =>$data->club_point_details->where('refunded',0)->sum('point'),
|
||||
'points' => floatval($points),
|
||||
'convert_status' => (int) $data->convert_status,
|
||||
'date' => date('d-m-Y', strtotime($data->created_at)),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Resources/V2/ColorCollection.php
Normal file
28
app/Http/Resources/V2/ColorCollection.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ColorCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'name' => $data->name,
|
||||
'code' => $data->code
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/V2/ConversationCollection.php
Normal file
36
app/Http/Resources/V2/ConversationCollection.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ConversationCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'receiver_id' => intval($data->receiver_id) ,
|
||||
'receiver_type'=> $data->receiver->user_type,
|
||||
'shop_id' => $data->receiver->user_type == 'admin' ? 0 : $data->receiver->shop->id,
|
||||
'shop_name' => $data->receiver->user_type == 'admin' ? 'In House Product' : $data->receiver->shop->name,
|
||||
'shop_logo' => $data->receiver->user_type == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($data->receiver->shop->logo),
|
||||
'title'=> $data->title,
|
||||
'sender_viewed'=> intval($data->sender_viewed),
|
||||
'receiver_viewed'=> intval($data->receiver_viewed),
|
||||
'date'=> $data->updated_at,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/V2/CountriesCollection.php
Normal file
30
app/Http/Resources/V2/CountriesCollection.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class CountriesCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => (int) $data->id,
|
||||
'code' => $data->code,
|
||||
'name' => $data->name,
|
||||
'status' => (int) $data->status,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Resources/V2/CurrencyCollection.php
Normal file
32
app/Http/Resources/V2/CurrencyCollection.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class CurrencyCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->name,
|
||||
'code' => $data->code,
|
||||
'symbol' => $data->symbol,
|
||||
'exchange_rate' => (double) $data->exchange_rate,
|
||||
'is_default' => get_setting('system_default_currency')==$data->id?true:false
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Http/Resources/V2/CustomerCollection.php
Normal file
39
app/Http/Resources/V2/CustomerCollection.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class CustomerCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'name' => $data->name,
|
||||
'email' => $data->email,
|
||||
'avatar' => uploaded_asset($data->avatar),
|
||||
'address' => $data->address??"",
|
||||
'country' => $data->country??"",
|
||||
'state' => $data->state??"",
|
||||
'city' => $data->city??"",
|
||||
'postal_code' => $data->postal_code??"",
|
||||
'phone' =>$data->phone??"",
|
||||
'balance' =>single_price($data->balance),
|
||||
'remaining_uploads' => $data->remaining_uploads,
|
||||
'package_id' => $data->customer_package_id??"",
|
||||
'package_name' => $data->customer_package->name??"",
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Http/Resources/V2/CustomerPackageResource.php
Normal file
26
app/Http/Resources/V2/CustomerPackageResource.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CustomerPackageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' => $this->getTranslation('name'),
|
||||
'logo' => uploaded_asset($this->logo),
|
||||
'product_upload_limit' =>(int) $this->product_upload,
|
||||
'amount' => ($this->amount > 0) ? single_price($this->amount) : translate('Free'),
|
||||
'price' => (double) $this->amount,
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/V2/DeliveryBoyCollection.php
Normal file
31
app/Http/Resources/V2/DeliveryBoyCollection.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class DeliveryBoyCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'user_id' => $data->user_id,
|
||||
'total_collection' => $data->total_collection,
|
||||
'total_earning' => $data->total_earning,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class DeliveryBoyPurchaseHistoryMiniCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
$delivery_pickup_latitude = 90.99;
|
||||
$delivery_pickup_longitude = 180.99;
|
||||
$store_location_available = false;
|
||||
if($data->shop && $data->shop->delivery_pickup_latitude) {
|
||||
$store_location_available = true;
|
||||
$delivery_pickup_latitude = floatval($data->shop->delivery_pickup_latitude);
|
||||
$delivery_pickup_longitude = floatval($data->shop->delivery_pickup_longitude);
|
||||
} if(!$data->shop) {
|
||||
$store_location_available = true;
|
||||
if(get_setting('delivery_pickup_latitude') && get_setting('delivery_pickup_longitude')) {
|
||||
$delivery_pickup_latitude = floatval(get_setting('delivery_pickup_latitude'));
|
||||
$delivery_pickup_longitude = floatval(get_setting('delivery_pickup_longitude'));
|
||||
}
|
||||
|
||||
}
|
||||
$shipping_address = json_decode($data->shipping_address,true);
|
||||
$location_available = false;
|
||||
$lat = 90.99;
|
||||
$lang = 180.99;
|
||||
|
||||
if(isset($shipping_address['lat_lang'])){
|
||||
$location_available = true;
|
||||
$exploded_lat_lang = explode(',',$shipping_address['lat_lang']);
|
||||
$lat = floatval($exploded_lat_lang[0]);
|
||||
$lang = floatval($exploded_lat_lang[1]);
|
||||
}
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'code' => $data->code,
|
||||
'user_id' => intval($data->user_id),
|
||||
'payment_type' => ucwords(str_replace('_', ' ', $data->payment_type)) ,
|
||||
'payment_status' => $data->payment_status,
|
||||
'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)),
|
||||
'delivery_status' => $data->delivery_status,
|
||||
'delivery_status_string' => $data->delivery_status == 'pending'? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)),
|
||||
'grand_total' => format_price($data->grand_total) ,
|
||||
'date' => Carbon::createFromFormat('Y-m-d H:i:s',$data->delivery_history_date)->format('d-m-Y'),
|
||||
'cancel_request' => $data->cancel_request == 1,
|
||||
'delivery_history_date' => $data->delivery_history_date,
|
||||
'location_available' => $location_available,
|
||||
'lat' => $lat,
|
||||
'lang' => $lang,
|
||||
'store_location_available' => $store_location_available,
|
||||
'delivery_pickup_latitude' => $delivery_pickup_latitude,
|
||||
'delivery_pickup_longitude' => $delivery_pickup_longitude,
|
||||
'links' => [
|
||||
'details' => ""
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/V2/DeliveryHistoryCollection.php
Normal file
36
app/Http/Resources/V2/DeliveryHistoryCollection.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class DeliveryHistoryCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'delivery_boy_id' => $data->delivery_boy_id,
|
||||
'order_id' => $data->order_id,
|
||||
'order_code' => $data->order->code,
|
||||
'delivery_status' => $data->delivery_status,
|
||||
'earning' => format_price($data->earning) ,
|
||||
'collection' => format_price($data->collection),
|
||||
'payment_type' => $data->payment_type,
|
||||
'date' => Carbon::createFromTimestamp($data->created_at)->format('d-m-Y'),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
80
app/Http/Resources/V2/DigitalProductDetailCollection.php
Normal file
80
app/Http/Resources/V2/DigitalProductDetailCollection.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use App\Models\Review;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class DigitalProductDetailCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$precision = 2;
|
||||
$calculable_price = home_discounted_base_price($data, false);
|
||||
$calculable_price = number_format($calculable_price, $precision, '.', '');
|
||||
$calculable_price = floatval($calculable_price);
|
||||
$photo_paths = get_images_path($data->photos);
|
||||
|
||||
$photos = [];
|
||||
|
||||
if (!empty($photo_paths)) {
|
||||
for ($i = 0; $i < count($photo_paths); $i++) {
|
||||
if ($photo_paths[$i] != "" ) {
|
||||
$item = array();
|
||||
$item['variant'] = "";
|
||||
$item['path'] = $photo_paths[$i];
|
||||
$photos[]= $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($data->stocks as $stockItem){
|
||||
if($stockItem->image != null && $stockItem->image != ""){
|
||||
$item = array();
|
||||
$item['variant'] = $stockItem->variant;
|
||||
$item['path'] = uploaded_asset($stockItem->image) ;
|
||||
$photos[]= $item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'id' => (integer)$data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'added_by' => $data->added_by,
|
||||
'seller_id' => $data->user->id,
|
||||
'shop_id' => $data->added_by == 'admin' ? 0 : $data->user->shop->id,
|
||||
'shop_name' => $data->added_by == 'admin' ? translate('In House Product') : $data->user->shop->name,
|
||||
'shop_logo' => $data->added_by == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($data->user->shop->logo)??"",
|
||||
'photos' => $photos,
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'tags' => explode(',', $data->tags),
|
||||
'price_high_low' => (double)explode('-', home_discounted_base_price($data, false))[0] == (double)explode('-', home_discounted_price($data, false))[1] ? format_price((double)explode('-', home_discounted_price($data, false))[0]) : "From " . format_price((double)explode('-', home_discounted_price($data, false))[0]) . " to " . format_price((double)explode('-', home_discounted_price($data, false))[1]),
|
||||
'has_discount' => home_base_price($data, false) != home_discounted_base_price($data, false),
|
||||
'stroked_price' => home_base_price($data),
|
||||
'main_price' => home_discounted_base_price($data),
|
||||
'calculable_price' => $calculable_price,
|
||||
'currency_symbol' => currency_symbol(),
|
||||
'rating' => (double)$data->rating,
|
||||
'rating_count' => (integer)Review::where(['product_id' => $data->id])->count(),
|
||||
'earn_point' => (double)$data->earn_point,
|
||||
'description' => $data->getTranslation('description'),
|
||||
'video_link' => $data->video_link != null ? $data->video_link : "",
|
||||
'link' => route('product', $data->slug)
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/V2/FlashDealCollection.php
Normal file
40
app/Http/Resources/V2/FlashDealCollection.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Http\Resources\ProductCollection;
|
||||
use App\Models\FlashDeal;
|
||||
use App\Models\Product;
|
||||
|
||||
class FlashDealCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'title' => $data->title,
|
||||
'date' => (int) $data->end_date,
|
||||
'banner' => uploaded_asset($data->banner),
|
||||
'products' => new FlashDealProductCollection($data->flash_deal_products()->take(6)->get())
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/V2/FlashDealProductCollection.php
Normal file
31
app/Http/Resources/V2/FlashDealProductCollection.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class FlashDealProductCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->product_id,
|
||||
'name' => $data->product->name,
|
||||
'image' => uploaded_asset($data->product->thumbnail_img),
|
||||
'price' => home_discounted_base_price($data->product),
|
||||
'links' => [
|
||||
'details' => route('products.show', $data->product_id),
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Http/Resources/V2/FollowSellerResource.php
Normal file
26
app/Http/Resources/V2/FollowSellerResource.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FollowSellerResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'shop_id'=> $this->shop->id,
|
||||
'shop_name'=> $this->shop->name,
|
||||
'shop_url'=> $this->shop->slug,
|
||||
'shop_rating'=> $this->shop->rating,
|
||||
'shop_num_of_reviews'=> $this->shop->num_of_reviews,
|
||||
'shop_logo' => uploaded_asset($this->shop->logo),
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/V2/GeneralSettingCollection.php
Normal file
37
app/Http/Resources/V2/GeneralSettingCollection.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class GeneralSettingCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'logo' => $data->logo,
|
||||
'site_name' => $data->site_name,
|
||||
'address' => $data->address,
|
||||
'description' => $data->description,
|
||||
'phone' => $data->phone,
|
||||
'email' => $data->email,
|
||||
'facebook' => $data->facebook,
|
||||
'twitter' => $data->twitter,
|
||||
'instagram' => $data->instagram,
|
||||
'youtube' => $data->youtube,
|
||||
'google_plus' => $data->google_plus
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/V2/HomeCategoryCollection.php
Normal file
33
app/Http/Resources/V2/HomeCategoryCollection.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class HomeCategoryCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'name' => $data->category->name,
|
||||
'banner' => uploaded_asset($data->category->banner),
|
||||
'icon' => uploaded_asset($data->category->icon),
|
||||
'links' => [
|
||||
'products' => route('api.products.category', $data->category->id),
|
||||
'sub_categories' => route('subCategories.index', $data->category->id)
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/V2/LanguageCollection.php
Normal file
35
app/Http/Resources/V2/LanguageCollection.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class LanguageCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
|
||||
return [
|
||||
'id' =>(int) $data->id,
|
||||
'name' => translate($data->name),
|
||||
'code' => $data->code,
|
||||
'mobile_app_code' => $data->app_lang_code,
|
||||
'rtl' => $data->rtl == 1,
|
||||
'is_default' => env("DEFAULT_LANGUAGE",'en') == $data->code,
|
||||
'image' => static_asset('assets/img/flags/'.$data->code.'.png') ,
|
||||
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/V2/MessageCollection.php
Normal file
36
app/Http/Resources/V2/MessageCollection.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class MessageCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'user_id' => intval($data->user_id),
|
||||
'send_type' => $data->user->user_type,
|
||||
'message' => $data->message,
|
||||
'year' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('Y'),
|
||||
'month' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('m'),
|
||||
'day_of_month' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('d-M'),
|
||||
'date' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('F d, Y'),
|
||||
'time' => Carbon::createFromFormat('Y-m-d H:i:s',$data->created_at)->format('h:i a'),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/V2/PickupPointResource.php
Normal file
35
app/Http/Resources/V2/PickupPointResource.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PickupPointResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
"staff_id" => $this->staff_id,
|
||||
"name" => $this->name,
|
||||
"address" => $this->address,
|
||||
"phone" => $this->phone,
|
||||
"pick_up_status" => $this->pick_up_status,
|
||||
"cash_on_pickup_status" => $this->cash_on_pickup_status,
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Http/Resources/V2/PolicyCollection.php
Normal file
27
app/Http/Resources/V2/PolicyCollection.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PolicyCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'content' => $data->content
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/V2/PosProductCollection.php
Normal file
31
app/Http/Resources/V2/PosProductCollection.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PosProductCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->name,
|
||||
'variant_product' => $data->variant_product,
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'price' => single_price($data->unit_price)
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
45
app/Http/Resources/V2/ProductCollection.php
Normal file
45
app/Http/Resources/V2/ProductCollection.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ProductCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'photos' => explode(',', $data->photos),
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'base_price' => (double) home_base_price($data, false),
|
||||
'base_discounted_price' => (double) home_discounted_base_price($data, false),
|
||||
'todays_deal' => (integer) $data->todays_deal,
|
||||
'featured' =>(integer) $data->featured,
|
||||
'unit' => $data->unit,
|
||||
'discount' => (double) $data->discount,
|
||||
'discount_type' => $data->discount_type,
|
||||
'rating' => (double) $data->rating,
|
||||
'sales' => (integer) $data->num_of_sale,
|
||||
'links' => [
|
||||
'details' => route('products.show', $data->id),
|
||||
'reviews' => route('api.reviews.index', $data->id),
|
||||
'related' => route('products.related', $data->id),
|
||||
'top_from_seller' => route('products.topFromSeller', $data->id)
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
131
app/Http/Resources/V2/ProductDetailCollection.php
Normal file
131
app/Http/Resources/V2/ProductDetailCollection.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Models\Review;
|
||||
use App\Models\Attribute;
|
||||
|
||||
|
||||
class ProductDetailCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$precision = 2;
|
||||
$calculable_price = home_discounted_base_price($data, false);
|
||||
$calculable_price = number_format($calculable_price, $precision, '.', '');
|
||||
$calculable_price = floatval($calculable_price);
|
||||
// $calculable_price = round($calculable_price, 2);
|
||||
$photo_paths = get_images_path($data->photos);
|
||||
|
||||
$photos = [];
|
||||
|
||||
|
||||
if (!empty($photo_paths)) {
|
||||
for ($i = 0; $i < count($photo_paths); $i++) {
|
||||
if ($photo_paths[$i] != "") {
|
||||
$item = array();
|
||||
$item['variant'] = "";
|
||||
$item['path'] = $photo_paths[$i];
|
||||
$photos[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data->stocks as $stockItem) {
|
||||
if ($stockItem->image != null && $stockItem->image != "") {
|
||||
$item = array();
|
||||
$item['variant'] = $stockItem->variant;
|
||||
$item['path'] = uploaded_asset($stockItem->image);
|
||||
$photos[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$brand = [
|
||||
'id' => 0,
|
||||
'name' => "",
|
||||
'logo' => "",
|
||||
];
|
||||
|
||||
if ($data->brand != null) {
|
||||
$brand = [
|
||||
'id' => $data->brand->id,
|
||||
'name' => $data->brand->getTranslation('name'),
|
||||
'logo' => uploaded_asset($data->brand->logo),
|
||||
];
|
||||
}
|
||||
|
||||
$whole_sale = [];
|
||||
if (addon_is_activated('wholesale')) {
|
||||
$whole_sale = ProductWholesaleResource::collection($data->stocks->first()->wholesalePrices);
|
||||
}
|
||||
return [
|
||||
'id' => (int)$data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'added_by' => $data->added_by,
|
||||
'seller_id' => $data->user->id,
|
||||
'shop_id' => $data->added_by == 'admin' ? 0 : $data->user->shop->id,
|
||||
'shop_name' => $data->added_by == 'admin' ? translate('In House Product') : $data->user->shop->name,
|
||||
'shop_logo' => $data->added_by == 'admin' ? uploaded_asset(get_setting('header_logo')) : uploaded_asset($data->user->shop->logo) ?? "",
|
||||
'photos' => $photos,
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'tags' => explode(',', $data->tags),
|
||||
'price_high_low' => (float)explode('-', home_discounted_base_price($data, false))[0] == (float)explode('-', home_discounted_price($data, false))[1] ? format_price((float)explode('-', home_discounted_price($data, false))[0]) : "From " . format_price((float)explode('-', home_discounted_price($data, false))[0]) . " to " . format_price((float)explode('-', home_discounted_price($data, false))[1]),
|
||||
'choice_options' => $this->convertToChoiceOptions(json_decode($data->choice_options)),
|
||||
'colors' => json_decode($data->colors) ?? [],
|
||||
'has_discount' => home_base_price($data, false) != home_discounted_base_price($data, false),
|
||||
'discount' => "-" . discount_in_percentage($data) . "%",
|
||||
'stroked_price' => home_base_price($data),
|
||||
'main_price' => home_discounted_base_price($data),
|
||||
'calculable_price' => $calculable_price,
|
||||
'currency_symbol' => currency_symbol(),
|
||||
'current_stock' => (int)$data->stocks->first()->qty,
|
||||
'unit' => $data->unit ?? "",
|
||||
'rating' => (float)$data->rating,
|
||||
'rating_count' => (int)Review::where(['product_id' => $data->id])->count(),
|
||||
'earn_point' => (float)$data->earn_point,
|
||||
'description' => $data->getTranslation('description'),
|
||||
'video_link' => $data->video_link != null ? $data->video_link : "",
|
||||
'brand' => $brand,
|
||||
'link' => route('product', $data->slug),
|
||||
'wholesale' => $whole_sale,
|
||||
'est_shipping_time' => (int)$data->est_shipping_days,
|
||||
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
|
||||
protected function convertToChoiceOptions($data)
|
||||
{
|
||||
$result = array();
|
||||
if ($data) {
|
||||
foreach ($data as $key => $choice) {
|
||||
$item['name'] = $choice->attribute_id;
|
||||
$item['title'] = Attribute::find($choice->attribute_id)->getTranslation('name');
|
||||
$item['options'] = $choice->values;
|
||||
array_push($result, $item);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function convertPhotos($data)
|
||||
{
|
||||
$result = array();
|
||||
foreach ($data as $key => $item) {
|
||||
array_push($result, uploaded_asset($item));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
41
app/Http/Resources/V2/ProductMiniCollection.php
Normal file
41
app/Http/Resources/V2/ProductMiniCollection.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ProductMiniCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$wholesale_product =
|
||||
($data->wholesale_product == 1) ? true : false;
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'has_discount' => home_base_price($data, false) != home_discounted_base_price($data, false),
|
||||
'discount' => "-" . discount_in_percentage($data) . "%",
|
||||
'stroked_price' => home_base_price($data),
|
||||
'main_price' => home_discounted_base_price($data),
|
||||
'rating' => (float) $data->rating,
|
||||
'sales' => (int) $data->num_of_sale,
|
||||
'is_wholesale' => $wholesale_product,
|
||||
'links' => [
|
||||
'details' => route('products.show', $data->id),
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Http/Resources/V2/ProductWholesaleResource.php
Normal file
26
app/Http/Resources/V2/ProductWholesaleResource.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductWholesaleResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
// return parent::toArray($request);
|
||||
return [
|
||||
// 'id' => $this->id,
|
||||
// 'product_stock_id' => $this->product_stock_id,
|
||||
'min_qty' => (int)$this->min_qty,
|
||||
'max_qty' => (int) $this->max_qty,
|
||||
'price' => single_price($this->price)
|
||||
];
|
||||
}
|
||||
}
|
||||
56
app/Http/Resources/V2/PurchaseHistoryCollection.php
Normal file
56
app/Http/Resources/V2/PurchaseHistoryCollection.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PurchaseHistoryCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$pickup_point = null;
|
||||
if ($data->shipping_type == 'pickup_point' && $data->pickup_point_id) {
|
||||
$pickup_point = $data->pickup_point;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'code' => $data->code,
|
||||
'user_id' => (int) $data->user_id,
|
||||
'shipping_address' => json_decode($data->shipping_address),
|
||||
'payment_type' => ucwords(str_replace('_', ' ', $data->payment_type)),
|
||||
'pickup_point' => $pickup_point,
|
||||
'shipping_type' => $data->shipping_type,
|
||||
'shipping_type_string' => $data->shipping_type != null ? ucwords(str_replace('_', ' ', $data->shipping_type)) : "",
|
||||
'payment_status' => $data->payment_status,
|
||||
'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)),
|
||||
'delivery_status' => $data->delivery_status,
|
||||
'delivery_status_string' => $data->delivery_status == 'pending'? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)),
|
||||
'grand_total' => format_price($data->grand_total),
|
||||
'plane_grand_total' => $data->grand_total,
|
||||
'coupon_discount' => format_price($data->coupon_discount),
|
||||
'shipping_cost' => format_price($data->orderDetails->sum('shipping_cost')),
|
||||
'subtotal' => format_price($data->orderDetails->sum('price')),
|
||||
'tax' => format_price($data->orderDetails->sum('tax')),
|
||||
'date' => Carbon::createFromTimestamp($data->date)->format('d-m-Y'),
|
||||
'cancel_request' => $data->cancel_request == 1,
|
||||
'manually_payable' => $data->manual_payment && $data->manual_payment_data == null,
|
||||
'links' => [
|
||||
'details' => ''
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
75
app/Http/Resources/V2/PurchaseHistoryItemsCollection.php
Normal file
75
app/Http/Resources/V2/PurchaseHistoryItemsCollection.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PurchaseHistoryItemsCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
|
||||
$refund_section = false;
|
||||
$refund_button = false;
|
||||
$refund_label = "";
|
||||
$refund_request_status = 99;
|
||||
if (addon_is_activated('refund_request')) {
|
||||
$refund_section = true;
|
||||
$no_of_max_day = get_setting('refund_request_time');
|
||||
$last_refund_date = $data->created_at->addDays($no_of_max_day);
|
||||
$today_date = \Carbon\Carbon::now();
|
||||
if ($data->product != null &&
|
||||
$data->product->refundable != 0 &&
|
||||
$data->refund_request == null &&
|
||||
$today_date <= $last_refund_date &&
|
||||
$data->payment_status == 'paid' &&
|
||||
$data->delivery_status == 'delivered') {
|
||||
$refund_button = true;
|
||||
} else if ($data->refund_request != null && $data->refund_request->refund_status == 0) {
|
||||
$refund_label = "Pending";
|
||||
$refund_request_status = $data->refund_request->refund_status;
|
||||
} else if ($data->refund_request != null && $data->refund_request->refund_status == 2) {
|
||||
$refund_label = "Rejected";
|
||||
$refund_request_status = $data->refund_request->refund_status;
|
||||
} else if ($data->refund_request != null && $data->refund_request->refund_status == 1) {
|
||||
$refund_label = "Approved";
|
||||
$refund_request_status = $data->refund_request->refund_status;
|
||||
} else if ($data->product->refundable != 0) {
|
||||
$refund_label = "N/A";
|
||||
} else {
|
||||
$refund_label = "Non-refundable";
|
||||
}
|
||||
}
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'product_id' => $data->product->id,
|
||||
'product_name' => $data->product->name,
|
||||
'variation' => $data->variation,
|
||||
'price' => format_price($data->price),
|
||||
'tax' => format_price($data->tax),
|
||||
'shipping_cost' => format_price($data->shipping_cost),
|
||||
'coupon_discount' => format_price($data->coupon_discount),
|
||||
'quantity' => (int)$data->quantity,
|
||||
'payment_status' => $data->payment_status,
|
||||
'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)),
|
||||
'delivery_status' => $data->delivery_status,
|
||||
'delivery_status_string' => $data->delivery_status == 'pending' ? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)),
|
||||
'refund_section' => $refund_section,
|
||||
'refund_button' => $refund_button,
|
||||
'refund_label' => $refund_label,
|
||||
'refund_request_status' => $refund_request_status,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/V2/PurchaseHistoryMiniCollection.php
Normal file
40
app/Http/Resources/V2/PurchaseHistoryMiniCollection.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class PurchaseHistoryMiniCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'code' => $data->code,
|
||||
'user_id' => intval($data->user_id),
|
||||
'payment_type' => ucwords(str_replace('_', ' ', $data->payment_type)) ,
|
||||
'payment_status' => $data->payment_status,
|
||||
'payment_status_string' => ucwords(str_replace('_', ' ', $data->payment_status)),
|
||||
'delivery_status' => $data->delivery_status,
|
||||
'delivery_status_string' => $data->delivery_status == 'pending'? "Order Placed" : ucwords(str_replace('_', ' ', $data->delivery_status)),
|
||||
'grand_total' => format_price($data->grand_total) ,
|
||||
'date' => Carbon::createFromTimestamp($data->date)->format('d-m-Y'),
|
||||
'links' => [
|
||||
'details' => ''
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/V2/PurchasedResource.php
Normal file
23
app/Http/Resources/V2/PurchasedResource.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PurchasedResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id'=> $this->id,
|
||||
'name'=> $this->getTranslation('name'),
|
||||
'thumbnail_image' => uploaded_asset($this->thumbnail_img),
|
||||
];
|
||||
}
|
||||
}
|
||||
46
app/Http/Resources/V2/RefundRequestCollection.php
Normal file
46
app/Http/Resources/V2/RefundRequestCollection.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class RefundRequestCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$refund_label = '';
|
||||
if($data->refund_status == 1) {
|
||||
$refund_label = 'Approved';
|
||||
} elseif($data->refund_status == 2) {
|
||||
$refund_label = 'Rejected';
|
||||
}else {
|
||||
$refund_label = 'PENDING';
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (int)$data->id,
|
||||
'user_id' => (int)$data->user_id,
|
||||
'order_code' => $data->order == null ? "" : $data->order->code,
|
||||
'product_name' => $data->orderDetail != null && $data->orderDetail->product != null ? $data->orderDetail->product->getTranslation('name', 'en') : "",
|
||||
'product_price' => $data->orderDetail != null ? single_price($data->orderDetail->price) : "",
|
||||
'refund_status' => (int) $data->refund_status,
|
||||
'refund_label' => $refund_label,
|
||||
'seller_approval' => $data->seller_approval,
|
||||
'reject_reason' => $data->reject_reason,
|
||||
'reason' => $data->reason,
|
||||
'date' => date('d-m-Y', strtotime($data->created_at)),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Resources/V2/ReviewCollection.php
Normal file
32
app/Http/Resources/V2/ReviewCollection.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ReviewCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'user_id'=> $data->user->id,
|
||||
'user_name'=> $data->user->name,
|
||||
'avatar'=> uploaded_asset($data->user->avatar_original),
|
||||
'rating' => floatval(number_format($data->rating,1,'.','')),
|
||||
'comment' => $data->comment,
|
||||
'time' => $data->updated_at->diffForHumans()
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/V2/SearchProductCollection.php
Normal file
37
app/Http/Resources/V2/SearchProductCollection.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class SearchProductCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'name' => $data->name,
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'base_price' => (double) home_base_price($data, false),
|
||||
'base_discounted_price' => (double) home_discounted_base_price($data, false),
|
||||
'rating' => (double) $data->rating,
|
||||
'links' => [
|
||||
'details' => route('products.show', $data->id),
|
||||
'reviews' => route('api.reviews.index', $data->id),
|
||||
'related' => route('products.related', $data->id),
|
||||
'top_from_seller' => route('products.topFromSeller', $data->id)
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/V2/Seller/AttributeCollection.php
Normal file
23
app/Http/Resources/V2/Seller/AttributeCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AttributeCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' =>$this->name,
|
||||
'values' => $this->attribute_values
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/V2/Seller/AuctionProductBidCollection.php
Normal file
38
app/Http/Resources/V2/Seller/AuctionProductBidCollection.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AuctionProductBidCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'customer_name' => $data->user->name,
|
||||
'customer_email' => $data->user->email ?? '',
|
||||
'customer_phone' => $data->user->phone ?? '',
|
||||
'bidded_amout' => format_price($data->amount),
|
||||
// 'date' => date("d-m-Y", $this->created_at),
|
||||
'date' => $data->created_at->format('d-m-Y'),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Http/Resources/V2/Seller/AuctionProductCollection.php
Normal file
34
app/Http/Resources/V2/Seller/AuctionProductCollection.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AuctionProductCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->getTranslation('name'),
|
||||
'thumbnail_image' => uploaded_asset($data->thumbnail_img),
|
||||
'main_price' => single_price($data->starting_bid),
|
||||
'start_date' => date('Y-m-d H:i:s', $data->auction_start_date),
|
||||
'end_date' => date('Y-m-d H:i:s', $data->auction_end_date),
|
||||
'total_bids' => (int) $data->bids->count(),
|
||||
'links' => [
|
||||
'details' => route('products.show', $data->id),
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AuctionProductDetailsResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
'lang' => $this->lang,
|
||||
'product_name' => $this->getTranslation('name', $this->lang),
|
||||
"category_id" => $this->category_id,
|
||||
"brand_id" => $this->brand_id,
|
||||
'product_unit' => $this->getTranslation('unit', $this->lang),
|
||||
"weight" => $this->weight,
|
||||
"tags" => $this->tags,
|
||||
"photos" => new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->photos))->get()),
|
||||
"thumbnail_img" => new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->thumbnail_img))->get()),
|
||||
"video_provider" => $this->video_provider,
|
||||
"video_link" => $this->video_link,
|
||||
"starting_bid" => $this->starting_bid,
|
||||
"auction_start_date" => date("Y-m-d", $this->auction_start_date),
|
||||
"auction_end_date" => date("Y-m-d", $this->auction_end_date),
|
||||
'description' => $this->getTranslation('description', $this->lang),
|
||||
"shipping_type" => $this->shipping_type,
|
||||
"shipping_cost" => $this->shipping_cost,
|
||||
"cash_on_delivery" => $this->cash_on_delivery,
|
||||
"est_shipping_days" => $this->est_shipping_days,
|
||||
"tax" => $this->taxes,
|
||||
"tax_type" => $this->tax_type,
|
||||
"pdf" => new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->pdf))->get()),
|
||||
"meta_title" => $this->meta_title,
|
||||
"meta_description" => $this->meta_description,
|
||||
"meta_img" => new UploadedFileCollection(Upload::where("id",$this->meta_img)->get()),
|
||||
"slug" => $this->slug,
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
23
app/Http/Resources/V2/Seller/BrandCollection.php
Normal file
23
app/Http/Resources/V2/Seller/BrandCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class BrandCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' =>$this->name,
|
||||
'icon' => uploaded_asset($this->logo)
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/CategoriesCollection.php
Normal file
29
app/Http/Resources/V2/Seller/CategoriesCollection.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CategoriesCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'parent_id' => $this->parent_id,
|
||||
'level' => $this->level,
|
||||
'name' =>$this->name,
|
||||
'banner' =>uploaded_asset($this->banner),
|
||||
'icon' => uploaded_asset($this->icon),
|
||||
'featured' =>$this->featured==0?false:true,
|
||||
'digital' =>$this->digital==0?false:true,
|
||||
'child' => ChildCategoriesCollection::collection( $this->childrenCategories)
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/ChildCategoriesCollection.php
Normal file
29
app/Http/Resources/V2/Seller/ChildCategoriesCollection.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ChildCategoriesCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'parent_id' => $this->parent_id,
|
||||
'level' => $this->level,
|
||||
'name' =>$this->name,
|
||||
'banner' =>uploaded_asset($this->banner),
|
||||
'icon' => uploaded_asset($this->icon),
|
||||
'featured' =>$this->featured==0?false:true,
|
||||
'digital' =>$this->digital==0?false:true,
|
||||
'child' => $this->categories?ChildCategoriesCollection::collection($this->categories):[]
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/V2/Seller/ColorCollection.php
Normal file
23
app/Http/Resources/V2/Seller/ColorCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ColorCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' =>$this->name,
|
||||
'code' => $this->code
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/CommissionHistoryResource.php
Normal file
29
app/Http/Resources/V2/Seller/CommissionHistoryResource.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CommissionHistoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$order_code = 'Order Deleted';
|
||||
if(isset($this->order)){
|
||||
$order_code = $this->order->code;
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'order_code' => $order_code,
|
||||
'admin_commission' => $this->admin_commission,
|
||||
'seller_earning' => format_price($this->seller_earning),
|
||||
'created_at' => date('d-m-Y', strtotime($this->created_at)),
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Http/Resources/V2/Seller/ConversationCollection.php
Normal file
43
app/Http/Resources/V2/Seller/ConversationCollection.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ConversationCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$seen_status = false;
|
||||
if (
|
||||
(auth()->user()->id == $data->sender_id && $data->sender_viewed == 0) ||
|
||||
(auth()->user()->id == $data->receiver_id && $data->receiver_viewed == 0)
|
||||
) {
|
||||
$seen_status = true;
|
||||
}
|
||||
if (auth()->user()->id == $data->sender_id) {
|
||||
$image = uploaded_asset($data->receiver->avatar_original);
|
||||
$name = $data->receiver->name;
|
||||
} else {
|
||||
$image = uploaded_asset($data->sender->avatar_original);
|
||||
$name = $data->sender->name;
|
||||
}
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'image' => $image,
|
||||
'name' => $name,
|
||||
'title' => $data->title,
|
||||
'is_seen' => $seen_status,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ConversationMessageCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$image = null;
|
||||
$is_seller_message = false;
|
||||
|
||||
if($this->user != null){
|
||||
$image = uploaded_asset($this->user->avatar_original);
|
||||
}
|
||||
if($this->user->id == auth()->user->id) {
|
||||
$is_seller_message = true;
|
||||
}
|
||||
return [
|
||||
'image' => $image,
|
||||
'id' => $this->user->id,
|
||||
'name' => $this->user->name,
|
||||
'message' => $this->message,
|
||||
'is_seller_message' => $is_seller_message,
|
||||
'created_at' => $this->created_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/ConversationResource.php
Normal file
29
app/Http/Resources/V2/Seller/ConversationResource.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ConversationResource extends JsonResource
|
||||
{
|
||||
|
||||
public function toArray($request)
|
||||
{
|
||||
//dd(uploaded_asset($this->sender->avatar_original));
|
||||
$image="";
|
||||
$name="";
|
||||
if (auth()->user()->id == $this->sender_id) {
|
||||
$image = uploaded_asset($this->receiver->avatar_original);
|
||||
$name = $this->receiver->name;
|
||||
} else {
|
||||
$image = uploaded_asset($this->sender->avatar_original);
|
||||
$name = $this->sender->name;
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'image' => $image,
|
||||
'name' => $name,
|
||||
'title' => $this->title,
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/V2/Seller/CouponResource.php
Normal file
38
app/Http/Resources/V2/Seller/CouponResource.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class CouponResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if($this->type == 'product_base') {
|
||||
|
||||
$decoded_product = Arr::pluck(json_decode($this->details, true), 'product_id');
|
||||
$products = filter_products(Product::whereIn('id', $decoded_product))->get();
|
||||
|
||||
}
|
||||
|
||||
// dd(json_encode(new ProductCollection($products)));
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'type' => $this->type,
|
||||
'code' => $this->code,
|
||||
'details' => ($this->type == 'product_base') ?json_encode( new ProductCollection($products)) : $this->details,
|
||||
'discount' =>(float) $this->discount,
|
||||
'discount_type' => $this->discount_type,
|
||||
'start_date' => date('d/m/Y', $this->start_date),
|
||||
'end_date' => date('d/m/Y', $this->end_date),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/V2/Seller/OrderCollection.php
Normal file
30
app/Http/Resources/V2/Seller/OrderCollection.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class OrderCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'order_code' => $data->code,
|
||||
'total' => format_price($data->grand_total),
|
||||
'order_date' => date('d-m-Y', strtotime($data->created_at)),
|
||||
'payment_status' => $data->payment_status,
|
||||
'delivery_status' => join(" ", explode('_', $data->delivery_status)),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/V2/Seller/OrderDetailResource.php
Normal file
37
app/Http/Resources/V2/Seller/OrderDetailResource.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderDetailResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
|
||||
$shipping_address = json_decode($this->shipping_address);
|
||||
return [
|
||||
'order_code' => $this->code,
|
||||
'total' => format_price($this->grand_total),
|
||||
'order_date' => date('d-m-Y', strtotime($this->created_at)),
|
||||
'payment_status' => $this->payment_status,
|
||||
'payment_type' => ucwords(str_replace('_', ' ', $this->payment_type)),
|
||||
'delivery_status' => $this->delivery_status,
|
||||
'shipping_type' => $this->shipping_type,
|
||||
'payment_method' => $this->payment_type,
|
||||
'shipping_address' => $shipping_address,
|
||||
'shipping_cost' => format_price($this->orderDetails->sum('shipping_cost')),
|
||||
'subtotal' => format_price($this->orderDetails->sum('price')),
|
||||
'coupon_discount' => format_price($this->coupon_discount),
|
||||
'tax' => format_price($this->orderDetails->sum('tax')),
|
||||
'order_items' => OrderItemResource::collection($this->orderDetails)
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/V2/Seller/OrderItemResource.php
Normal file
30
app/Http/Resources/V2/Seller/OrderItemResource.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderItemResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$description = $this->quantity;
|
||||
if($this->variation) {
|
||||
$description = $this->quantity. ' x '. $this->variation;
|
||||
}
|
||||
return [
|
||||
'name' => optional($this->product)->name,
|
||||
'description' => $description,
|
||||
'delivery_status' => $this->delivery_status,
|
||||
'price' => format_price($this->price),
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/V2/Seller/ProductCollection.php
Normal file
38
app/Http/Resources/V2/Seller/ProductCollection.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ProductCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
$qty = 0;
|
||||
foreach ($data->stocks as $key => $stock) {
|
||||
$qty += $stock->qty;
|
||||
}
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->name,
|
||||
'thumbnail_img' => uploaded_asset($data->thumbnail_img),
|
||||
'price' => format_price($data->unit_price),
|
||||
'current_stock' => $qty,
|
||||
'status' => $data->published == 0 ? false : true,
|
||||
'category' => $data->category->name,
|
||||
'featured' => $data->seller_featured == 0 ? false : true,
|
||||
];
|
||||
}),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
89
app/Http/Resources/V2/Seller/ProductDetailsCollection.php
Normal file
89
app/Http/Resources/V2/Seller/ProductDetailsCollection.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductDetailsCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
'lang' => $this->lang,
|
||||
'product_name' => $this->getTranslation('name', $this->lang),
|
||||
'product_unit' => $this->getTranslation('unit', $this->lang),
|
||||
'description' => $this->getTranslation('description', $this->lang),
|
||||
"category_id" => $this->category_id,
|
||||
"brand_id" => $this->brand_id,
|
||||
"photos" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->photos))->get()),
|
||||
"thumbnail_img" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->thumbnail_img))->get()),
|
||||
"video_provider" => $this->video_provider,
|
||||
"video_link" => $this->video_link,
|
||||
"tags" => $this->tags,
|
||||
"unit_price" => $this->unit_price,
|
||||
"purchase_price" => $this->purchase_price,
|
||||
"variant_product" => $this->variant_product,
|
||||
"attributes" => json_decode($this->attributes),
|
||||
"choice_options" => json_decode($this->choice_options),
|
||||
"colors" => json_decode($this->colors),
|
||||
"variations" => $this->variations,
|
||||
"stocks" => new StockCollection($this->stocks),
|
||||
"todays_deal" => $this->todays_deal,
|
||||
"published" => $this->published,
|
||||
"approved" => $this->approved,
|
||||
"stock_visibility_state" => $this->stock_visibility_state,
|
||||
"cash_on_delivery" => $this->cash_on_delivery,
|
||||
"featured" => $this->featured,
|
||||
"seller_featured" => $this->seller_featured,
|
||||
"current_stock" => $this->current_stock,
|
||||
"weight" => $this->weight,
|
||||
"min_qty" => $this->min_qty,
|
||||
"low_stock_quantity" => $this->low_stock_quantity,
|
||||
"discount" => $this->discount,
|
||||
"discount_type" => $this->discount_type,
|
||||
"discount_start_date" => date("Y-m-d", $this->discount_start_date),
|
||||
"discount_end_date" => date("Y-m-d", $this->discount_end_date),
|
||||
"tax" => $this->taxes,
|
||||
"tax_type" => $this->tax_type,
|
||||
"shipping_type" => $this->shipping_type,
|
||||
"shipping_cost" => $this->shipping_cost,
|
||||
"is_quantity_multiplied" => $this->is_quantity_multiplied,
|
||||
"est_shipping_days" => $this->est_shipping_days,
|
||||
"num_of_sale" => $this->num_of_sale,
|
||||
"meta_title" => $this->meta_title,
|
||||
"meta_description" => $this->meta_description,
|
||||
"meta_img" =>new UploadedFileCollection(Upload::where("id",$this->meta_img)->get()),
|
||||
"pdf" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->pdf))->get()),
|
||||
"slug" => $this->slug,
|
||||
"rating" => $this->rating,
|
||||
"barcode" => $this->barcode,
|
||||
"digital" => $this->digital,
|
||||
"auction_product" => $this->auction_product,
|
||||
"file_name" => $this->file_name,
|
||||
"file_path" => $this->file_path,
|
||||
"external_link" => $this->external_link,
|
||||
"external_link_btn" => $this->external_link_btn,
|
||||
"wholesale_product" => $this->wholesale_product,
|
||||
"created_at" => $this->created_at,
|
||||
"updated_at" => $this->updated_at,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Http/Resources/V2/Seller/ProductResource.php
Normal file
19
app/Http/Resources/V2/Seller/ProductResource.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/V2/Seller/ProductReviewCollection.php
Normal file
37
app/Http/Resources/V2/Seller/ProductReviewCollection.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ProductReviewCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
// dd($this);
|
||||
return [
|
||||
"data"=>$this->collection->map( function ($data){
|
||||
return [
|
||||
"id"=> (int) $data->id,
|
||||
"rating"=>(int) $data->rating,
|
||||
"comment"=> $data->comment,
|
||||
"status"=>(int) $data->status,
|
||||
"updated_at"=> $data->updated_at,
|
||||
"product_name"=> $data->product_name,
|
||||
"user_id"=>(int) $data->user_id,
|
||||
"name"=> $data->name,
|
||||
"avatar"=> $data->avatar
|
||||
];
|
||||
|
||||
}),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
27
app/Http/Resources/V2/Seller/SellerPackageResource.php
Normal file
27
app/Http/Resources/V2/Seller/SellerPackageResource.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SellerPackageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' => $this->getTranslation('name'),
|
||||
'logo' => uploaded_asset($this->logo),
|
||||
'product_upload_limit' =>(int) $this->product_upload_limit,
|
||||
'amount' => ($this->amount > 0) ? single_price($this->amount) : translate('Free'),
|
||||
'price' => (double) $this->amount,
|
||||
'duration' =>(int) $this->duration,
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/Seller/SellerPaymentResource.php
Normal file
29
app/Http/Resources/V2/Seller/SellerPaymentResource.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SellerPaymentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$payment_method = ucfirst(str_replace('_', ' ', $this->payment_method));
|
||||
if ($this->txn_code != null) {
|
||||
$payment_method = ucfirst(str_replace('_', ' ', $this->payment_method)). ' ' .translate('TRX ID'). ':' .$this->txn_code;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'amount' => format_price($this->amount),
|
||||
'payment_method' => $payment_method,
|
||||
'payment_date' => date('d-m-Y', strtotime($this->created_at)),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Resources/V2/Seller/SellerWithdrawResource.php
Normal file
28
app/Http/Resources/V2/Seller/SellerWithdrawResource.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SellerWithdrawResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$status = translate('Paid');
|
||||
if($this->status == 0) {
|
||||
$status = translate('Pending');
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'amount' => format_price($this->amount),
|
||||
'status' => $status,
|
||||
'created_at' => date('d-m-Y', strtotime($this->created_at)),
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/V2/Seller/StockCollection.php
Normal file
35
app/Http/Resources/V2/Seller/StockCollection.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class StockCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
|
||||
return [
|
||||
"data" => $this->collection->map(function ($data) {
|
||||
return [
|
||||
"id" => (int) $data->id,
|
||||
"product_id" => $data->product_id,
|
||||
"variant" => $data->variant,
|
||||
"sku" => $data->sku,
|
||||
"price" => $data->price,
|
||||
"qty" => $data->qty,
|
||||
"image" =>new UploadedFileCollection(Upload::where("id",$data->image)->get())
|
||||
];
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/Http/Resources/V2/Seller/TaxCollection.php
Normal file
22
app/Http/Resources/V2/Seller/TaxCollection.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TaxCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' =>(int) $this->id,
|
||||
'name' =>$this->name
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2\Seller;
|
||||
|
||||
use App\Http\Resources\V2\UploadedFileCollection;
|
||||
use App\Models\Upload;
|
||||
use App\Models\WholesalePrice;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class WholesaleProductDetailsCollection extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
'lang' => $this->lang,
|
||||
'product_name' => $this->getTranslation('name', $this->lang),
|
||||
'product_unit' => $this->getTranslation('unit', $this->lang),
|
||||
'description' => $this->getTranslation('description', $this->lang),
|
||||
"category_id" => $this->category_id,
|
||||
"brand_id" => $this->brand_id,
|
||||
"photos" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->photos))->get()),
|
||||
"thumbnail_img" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->thumbnail_img))->get()),
|
||||
"video_provider" => $this->video_provider,
|
||||
"video_link" => $this->video_link,
|
||||
"tags" => $this->tags,
|
||||
"unit_price" => $this->unit_price,
|
||||
"purchase_price" => $this->purchase_price,
|
||||
"variant_product" => $this->variant_product,
|
||||
"attributes" => json_decode($this->attributes),
|
||||
"choice_options" => json_decode($this->choice_options),
|
||||
"colors" => json_decode($this->colors),
|
||||
"variations" => $this->variations,
|
||||
"stocks" => new StockCollection($this->stocks),
|
||||
"todays_deal" => $this->todays_deal,
|
||||
"published" => $this->published,
|
||||
"approved" => $this->approved,
|
||||
"stock_visibility_state" => $this->stock_visibility_state,
|
||||
"cash_on_delivery" => $this->cash_on_delivery,
|
||||
"featured" => $this->featured,
|
||||
"seller_featured" => $this->seller_featured,
|
||||
"current_stock" => $this->current_stock,
|
||||
"weight" => $this->weight,
|
||||
"min_qty" => $this->min_qty,
|
||||
"low_stock_quantity" => $this->low_stock_quantity,
|
||||
"discount" => $this->discount,
|
||||
"discount_type" => $this->discount_type,
|
||||
"discount_start_date" => date("Y-m-d", $this->discount_start_date),
|
||||
"discount_end_date" => date("Y-m-d", $this->discount_end_date),
|
||||
"tax" => $this->taxes,
|
||||
"tax_type" => $this->tax_type,
|
||||
"shipping_type" => $this->shipping_type,
|
||||
"shipping_cost" => $this->shipping_cost,
|
||||
"is_quantity_multiplied" => $this->is_quantity_multiplied,
|
||||
"est_shipping_days" => $this->est_shipping_days,
|
||||
"num_of_sale" => $this->num_of_sale,
|
||||
"meta_title" => $this->meta_title,
|
||||
"meta_description" => $this->meta_description,
|
||||
"meta_img" =>new UploadedFileCollection(Upload::where("id",$this->meta_img)->get()),
|
||||
"pdf" =>new UploadedFileCollection(Upload::whereIn("id",explode(",",$this->pdf))->get()),
|
||||
"slug" => $this->slug,
|
||||
"barcode" => $this->barcode,
|
||||
"file_name" => $this->file_name,
|
||||
"file_path" => $this->file_path,
|
||||
"external_link" => $this->external_link,
|
||||
"refundable"=>$this->refundable,
|
||||
"external_link_btn" => $this->external_link_btn,
|
||||
"wholesale_prices" =>WholesalePrice::where('product_stock_id',$this->stocks->first()->id)->get(),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
47
app/Http/Resources/V2/SettingsCollection.php
Normal file
47
app/Http/Resources/V2/SettingsCollection.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Models\BusinessSetting;
|
||||
use App\Models\Currency;
|
||||
|
||||
class SettingsCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'name' => $data->name,
|
||||
'logo' => $data->logo,
|
||||
'facebook' => $data->facebook,
|
||||
'twitter' => $data->twitter,
|
||||
'instagram' => $data->instagram,
|
||||
'youtube' => $data->youtube,
|
||||
'google_plus' => $data->google_plus,
|
||||
'currency' => [
|
||||
'name' => Currency::findOrFail(BusinessSetting::where('type', 'system_default_currency')->first()->value)->name,
|
||||
'symbol' => Currency::findOrFail(BusinessSetting::where('type', 'system_default_currency')->first()->value)->symbol,
|
||||
'exchange_rate' => (double) $this->exchangeRate(Currency::findOrFail(BusinessSetting::where('type', 'system_default_currency')->first()->value)),
|
||||
'code' => Currency::findOrFail(BusinessSetting::where('type', 'system_default_currency')->first()->value)->code
|
||||
],
|
||||
'currency_format' => $data->currency_format
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
|
||||
public function exchangeRate($currency){
|
||||
$base_currency = Currency::find(BusinessSetting::where('type', 'system_default_currency')->first()->value);
|
||||
return $currency->exchange_rate/$base_currency->exchange_rate;
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/V2/ShopCollection.php
Normal file
38
app/Http/Resources/V2/ShopCollection.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class ShopCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'name' => $data->name,
|
||||
'logo' => uploaded_asset($data->logo),
|
||||
'rating' => $data->rating,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
|
||||
protected function convertPhotos($data){
|
||||
$result = array();
|
||||
foreach ($data as $key => $item) {
|
||||
array_push($result, uploaded_asset($item));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
72
app/Http/Resources/V2/ShopDetailsCollection.php
Normal file
72
app/Http/Resources/V2/ShopDetailsCollection.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use \App\Models\Product;
|
||||
|
||||
class ShopDetailsCollection extends JsonResource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return
|
||||
[
|
||||
'id' => $this->id,
|
||||
'user_id' => intval($this->user_id) ,
|
||||
'name' => $this->name,
|
||||
'title' => $this->meta_title,
|
||||
'description' => $this->meta_description,
|
||||
'delivery_pickup_latitude' => $this->delivery_pickup_latitude,
|
||||
'delivery_pickup_longitude' => $this->delivery_pickup_longitude,
|
||||
'logo' => uploaded_asset($this->logo),
|
||||
'package_invalid_at' => $this->package_invalid_at??"",
|
||||
'product_upload_limit' => $this->product_upload_limit,
|
||||
'seller_package' => $this->seller_package->name??"",
|
||||
'seller_package_img' =>uploaded_asset($this->seller_package->logo??"") ,
|
||||
'upload_id' => $this->logo,
|
||||
'sliders' => get_images_path($this->sliders),
|
||||
'sliders_id' => $this->sliders,
|
||||
'address' => $this->address,
|
||||
'admin_to_pay' => format_price( $this->admin_to_pay),
|
||||
'phone' => $this->phone,
|
||||
'facebook' => $this->facebook,
|
||||
'google' => $this->google,
|
||||
'twitter' => $this->twitter,
|
||||
'instagram' => $this->instagram,
|
||||
'youtube' => $this->youtube,
|
||||
|
||||
'cash_on_delivery_status' => $this->cash_on_delivery_status,
|
||||
'bank_payment_status' => $this->bank_payment_status,
|
||||
'bank_name' => $this->bank_name,
|
||||
'bank_acc_name' => $this->bank_acc_name,
|
||||
'bank_acc_no' => $this->bank_acc_no,
|
||||
'bank_routing_no' => $this->bank_routing_no,
|
||||
|
||||
'rating' => (double) $this->rating,
|
||||
'verified'=> $this->verification_status==1,
|
||||
'is_submitted_form'=> $this->verification_info !=null,
|
||||
'verified_img'=> $this->verification_status==1?static_asset("assets/img/verified.png"):static_asset("assets/img/non_verified.png"),
|
||||
'verify_text'=> $this->verification_status==1?translate("Verified seller"):translate("Non-Verified seller"),
|
||||
'email'=> $this->user->email,
|
||||
'products'=> $this->user->products()->count(),
|
||||
'orders'=> $this->user->seller_orders()->where("delivery_status","delivered")->count(),
|
||||
'sales'=>format_price( $this->user->seller_sales()->where("payment_status","paid")->sum('price'),true),
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
|
||||
protected function convertPhotos($data){
|
||||
$result = array();
|
||||
foreach ($data as $key => $item) {
|
||||
array_push($result, uploaded_asset($item));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
27
app/Http/Resources/V2/SliderCollection.php
Normal file
27
app/Http/Resources/V2/SliderCollection.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class SliderCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'photo' => uploaded_asset($data)
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/V2/StatesCollection.php
Normal file
29
app/Http/Resources/V2/StatesCollection.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class StatesCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function ($data) {
|
||||
return [
|
||||
'id' => (int) $data->id,
|
||||
'country_id' => (int) $data->country_id,
|
||||
'name' => $data->name,
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/V2/SubCategoryCollection.php
Normal file
31
app/Http/Resources/V2/SubCategoryCollection.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class SubCategoryCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'name' => $data->name,
|
||||
'subSubCategories' => new SubSubCategoryCollection($data->subSubCategories),
|
||||
'links' => [
|
||||
'products' => route('products.subCategory', $data->id)
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/V2/SubSubCategoryCollection.php
Normal file
30
app/Http/Resources/V2/SubSubCategoryCollection.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class SubSubCategoryCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'name' => $data->name,
|
||||
'links' => [
|
||||
'products' => route('products.subSubCategory', $data->id)
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/V2/UploadedFileCollection.php
Normal file
33
app/Http/Resources/V2/UploadedFileCollection.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class UploadedFileCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'file_original_name' =>$data->file_original_name,
|
||||
'file_name' => $data->file_name,
|
||||
'url' => uploaded_asset($data->id),
|
||||
'file_size' => $data->file_size,
|
||||
'extension' => $data->extension,
|
||||
'type' => $data->type
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/V2/UserCollection.php
Normal file
37
app/Http/Resources/V2/UserCollection.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class UserCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => (integer) $data->id,
|
||||
'name' => $data->name,
|
||||
'type' => $data->user_type,
|
||||
'email' => $data->email,
|
||||
'avatar' => $data->avatar,
|
||||
'avatar_original' => uploaded_asset($data->avatar_original),
|
||||
'address' => $data->address,
|
||||
'city' => $data->city,
|
||||
'country' => $data->country,
|
||||
'postal_code' => $data->postal_code,
|
||||
'phone' => $data->phone
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Resources/V2/WalletCollection.php
Normal file
31
app/Http/Resources/V2/WalletCollection.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class WalletCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'amount' => format_price ($data->amount) ,
|
||||
'payment_method' => ucwords(str_replace('_', ' ', $data->payment_method)),
|
||||
'approval_string' => $data->offline_payment ? ($data->approval == 1 ? "Approved" : "Decliend") : "N/A",
|
||||
'date' => Carbon::createFromTimestamp(strtotime($data->created_at))->format('d-m-Y'),
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'result' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Http/Resources/V2/WishlistCollection.php
Normal file
34
app/Http/Resources/V2/WishlistCollection.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class WishlistCollection extends ResourceCollection
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => (integer) $data->id,
|
||||
'product' => [
|
||||
'id' => $data->product->id,
|
||||
'name' => $data->product->name,
|
||||
'thumbnail_image' => uploaded_asset($data->product->thumbnail_img),
|
||||
'base_price' => format_price(home_base_price($data->product, false)) ,
|
||||
'rating' => (double) $data->product->rating,
|
||||
]
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user