<?php

namespace App\Http\Controllers\Deed;

use App\Http\Controllers\Core\Auth;
use App\Models\Deed\PaintModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class PaintController extends Controller
{
    //

    public function index(Request $request)
    {
    }


    /**
     * 创建绘画
     * @param  Request  $request
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required|max:8',
            'pic_url' => 'required|url',
            'actions' => 'required',
        ]);
        $uid = Auth::auth();
        $paint = PaintModel::create($request->merge(['uid' => $uid])->all());
        return response([
            'code' => 200,
            'message' => 'OK',
            'data' => $paint
        ]);
    }


    /**
     * 查看指定绘画
     * @param $id
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
     */
    public function show($id)
    {
        $paint = PaintModel::findOrFail($id);
        $paint->user;
        return response([
            'code' => 200,
            'message' => 'OK',
            'data' => $paint
        ]);
    }
}
