<?php

namespace App\Admin\Actions\backstage\Orders;

use App\Models\Order;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use App\Models\RefundApplication;

class RefundApplicationAction extends RowAction
{
    public $name = '退款申请';

    public function handle(Model $model)
    {
        // $model ...
        //插入退款申请表
        $arr = [
            'order_id' => $this->row->id,
            'status' => 1,
            'refund_applicant' => \Admin::user()->id,
        ];
        RefundApplication::create($arr);
        Order::where('id',$this->row->id)->update(['payment_status'=> 3]);
        return $this->response()->success('申请退款成功')->refresh();
    }

}