<?php

namespace App\Repositories;


use App\Models\Product;

use App\Models\WalkThrough;

use Illuminate\Support\Facades\DB;


/**
 * Class AppConfigurationRepository
 */
class WalkThroughRepository extends BaseRepository
{
    public $fieldSearchable = [
        'key',
    ];

    /**
     * @inheritDoc
     */
    public function getFieldsSearchable()
    {
        return $this->fieldSearchable;
    }

    /**
     * @inheritDoc
     */
    public function model()
    {
        return WalkThrough::class;
    }

    /**
     * @param $input
     *
     *
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|void
     */
//    
//    public function store($input)
//    {
//        try {
//            DB::beginTransaction();
//
//            $input['status'] = isset($input['status']) ? 1 : 0;
//            $walkThrougu = WalkThrough::create($input);
//
//            if (isset($input['walk_through_image']) && !empty($input['walk_through_image'])) {
//                $walkThrougu->addMedia($input['walk_through_image'])->toMediaCollection(WalkThrough::WALK_THROUGH_IMAGE,
//                    config('app.media_disc'));
//            }
//
//            DB::commit();
//
//            return $walkThrougu;
//        } catch (Exception $e) {
//            DB::rollBack();
//
//            throw new UnprocessableEntityHttpException($e->getMessage());
//        }
//    }

//    public function update($input,$id)
//    {
//        try {
//            DB::beginTransaction();
//            $input['status'] = isset($input['status']) ? 1 : 0;
//            $walkThrougu = WalkThrough::findOrFail($id);
//            $walkThrougu->update($input);
//
//            if (isset($input['walk_through_image']) && ! empty($input['walk_through_image'])) {
//                $walkThrougu->clearMediaCollection(WalkThrough::WALK_THROUGH_IMAGE);
//                $walkThrougu->addMedia($input['walk_through_image'])->toMediaCollection(WalkThrough::WALK_THROUGH_IMAGE,
//                    config('app.media_disc'));
//            }
//           
//
//            DB::commit();
//
//            return $walkThrougu;
//        } catch (Exception $e) {
//            DB::rollBack();
//
//            throw new UnprocessableEntityHttpException($e->getMessage());
//        }
//    }
}
