32 lines
852 B
PHP
32 lines
852 B
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Swap;
|
|
|
|
use App\Swap;
|
|
use App\User;
|
|
use Encore\Admin\Actions\RowAction;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class Replicate extends RowAction
|
|
{
|
|
public $name = '拒绝';
|
|
|
|
public function handle(Model $model)
|
|
{
|
|
if ($model['status'] == 0) {
|
|
$user = User::where(['address' => $model['address']])->first();
|
|
|
|
DB::transaction(function () use ($model, $user) {
|
|
Swap::where(['id' => $model['id']])->update(['status' => 2]);
|
|
|
|
User::where(['id' => $user['id']])->increment('balance', $model['balance']);
|
|
});
|
|
return $this->response()->success('Success message.')->refresh();
|
|
}else{
|
|
return $this->response()->error('不要给人家送钱')->refresh();
|
|
}
|
|
|
|
}
|
|
|
|
} |