<?php

namespace App\Admin\Actions\Post;

use Encore\Admin\Actions\BatchAction;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Request;

class BatchMsg extends BatchAction
{
    public $name = '批量回复';
    protected $selector = '.report-posts';

    public function handle(Collection $collection, Request $request){
        foreach ($collection as $model) {
            $model->msg = $request->get('msg');
            $model->save();
        }

        return $this->response()->success('回复成功！')->refresh();
    }

    public function form(){
        $this->textarea('msg', '回复内容');
    }

    // public function html()
    // {
    //     return "<a class='report-posts btn btn-sm btn-success'>批量回复</a>";
    // }
}