<?php

namespace App\Http\Controllers\Admin\Interaction;

use App\Models\CommentInfoModel;
use App\Models\DreamInfoModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Admin\Controller;

class InfoController extends Controller
{
    public function view(Request $request)
    {
        $dream = DreamInfoModel::find($request->id);
        $list = $dream->interactions;
        foreach ($list as $item){
            $item->comms =   $item->comments;
        }
        return view('admin.dream.interaction.view',compact('list'));
    }

    public function update(Request $request,$id)
    {
        $data = (array) request('data');
        $ok =CommentInfoModel::where('id',$id)->update($data);
        if($ok) {
            $url[] = array('url'=>U( 'Dream/Info/index'),'title'=>'返回列表');
            return $this->showMessage('操作成功',urldecode(request('_referer')));
        }else{
            $url[] = array('url'=>U( 'Dream/Info/index'),'title'=>'返回列表');
            return $this->showWarning('操作失败',$url);
        }
//        dd($data);
    }
}
