<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2017/11/20
 * Time: 16:17
 */

namespace App\Http\Controllers\Channel\Promotion;

use App\Http\Controllers\Channel\BaseController;
use App\Http\Controllers\Channel\Promotion\Transformers\DocumentCoversTransformer;
use App\Modules\Promotion\Services\PromotionService;
use DB;

class DocumentCoversController extends BaseController
{
    /**
     * @apiDefine promotion 推广
     */

    /**
     * @apiVersion 1.0.0
     * @api {GET} promotion/documentCovers 获取推广文案封面列表
     * @apiGroup promotion
     * @apiName getPromotionDocumentCovers
     * @apiSuccess {Number}  id 文案封面id..
     * @apiSuccess {String}  origin_cover 封面地址.
     * @apiSuccessExample {json} Success-Response:
     *
     *     {
     *         "code": 0,
     *         "msg": "",
     *
     *         "data": [
     *           {
     *              "id": 1,
     *              "origin_cover": "sfsd"
     *            },
     *           {
     *              "id": 2,
     *              "origin_cover": "sfsd"
     *            }
     *        ]
     *     }
     */

    function getPromotionDocumentCovers()
    {
        $distribution_channel_id = $this->getChannelId();
        $promotionDocumentCoversResult = PromotionService::getAllDocumentCovers($distribution_channel_id);
        return response()->collection(new DocumentCoversTransformer(), $promotionDocumentCoversResult);
    }
}