rma
This commit is contained in:
parent
dd1828a94a
commit
315c3e8a2e
|
|
@ -38,7 +38,7 @@ class Rma extends Base
|
|||
|
||||
public function reason() :BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RmaReason::class);
|
||||
return $this->belongsTo(RmaReason::class)->where('locale', locale());
|
||||
}
|
||||
|
||||
public function histories() :HasMany
|
||||
|
|
|
|||
|
|
@ -130,8 +130,9 @@ class RmaRepo
|
|||
}
|
||||
|
||||
$results = [];
|
||||
foreach ($customer->rmas as $rma) {
|
||||
$results[$rma->first][] = (new RmaDetail($rma))->jsonSerialize();
|
||||
|
||||
foreach ($customer->rmas()->with('reason')->get() as $rma) {
|
||||
$results[] = (new RmaDetail($rma))->jsonSerialize();
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class RmaController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$rmas = RmaRepo::listByCustomer(current_customer());
|
||||
|
||||
$data = [
|
||||
'rmas' => $rmas,
|
||||
];
|
||||
|
|
@ -63,6 +64,6 @@ class RmaController extends Controller
|
|||
{
|
||||
$rma = RmaService::createFromShop($request->only('order_product_id', 'quantity', 'opened', 'rma_reason_id', 'type', 'comment'));
|
||||
|
||||
return redirect()->to(shop_route('account.rmas.index'))->with('success', '售后服务申请提交成功');
|
||||
return redirect()->to(shop_route('account.rma.index'))->with('success', '售后服务申请提交成功');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,22 @@ class RmaDetail extends JsonResource
|
|||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return $this->toArray($request);
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'order_product_id' => $this->order_product_id,
|
||||
'quantity' => $this->quantity,
|
||||
'opened' => $this->opened,
|
||||
'type' => $this->type,
|
||||
'comment' => $this->comment,
|
||||
'status' => $this->status,
|
||||
'created_at' => time_format($this->created_at),
|
||||
'email' => $this->email,
|
||||
'telephone' => $this->telephone,
|
||||
'product_name' => $this->product_name,
|
||||
'name' => $this->name,
|
||||
'sku' => $this->sku,
|
||||
'reason' => $this->reason,
|
||||
'type_text' => $this->type_text,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class RmaService
|
|||
'customer_id' => $customer->id,
|
||||
'name' => $customer->name,
|
||||
'email' => $customer->email,
|
||||
'telephone' => $customer->telephone,
|
||||
'telephone' => $customer->telephone ?? '',
|
||||
'product_name' => $orderProduct->name,
|
||||
'sku' => $orderProduct->product_sku,
|
||||
'product_name' => $orderProduct->name,
|
||||
|
|
@ -37,6 +37,7 @@ class RmaService
|
|||
'rma_reason_id' => $data['rma_reason_id'],
|
||||
'type' => $data['type'],
|
||||
'comment' => $data['comment'],
|
||||
'status' => true,
|
||||
];
|
||||
|
||||
$rma = RmaRepo::create($params);
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
{{-- {{ dd($rmas) }} --}}
|
||||
Loading…
Reference in New Issue