<?php

namespace File\File\Workflow;

use Exception;
use Litepie\Workflow\Exceptions\WorkflowActionNotPerformedException;

use File\File\Models\Image;

class ImageAction
{
    /**
     * Perform the complete action.
     *
     * @param Image $image
     *
     * @return Image
     */
    public function complete(Image $image)
    {
        try {
            $image->status = 'complete';
            return $image->save();
        } catch (Exception $e) {
            throw new WorkflowActionNotPerformedException();
        }
    }

    /**
     * Perform the verify action.
     *
     * @param Image $image
     *
     * @return Image
     */public function verify(Image $image)
    {
        try {
            $image->status = 'verify';
            return $image->save();
        } catch (Exception $e) {
            throw new WorkflowActionNotPerformedException();
        }
    }

    /**
     * Perform the approve action.
     *
     * @param Image $image
     *
     * @return Image
     */public function approve(Image $image)
    {
        try {
            $image->status = 'approve';
            return $image->save();
        } catch (Exception $e) {
            throw new WorkflowActionNotPerformedException();
        }
    }

    /**
     * Perform the publish action.
     *
     * @param Image $image
     *
     * @return Image
     */public function publish(Image $image)
    {
        try {
            $image->status = 'publish';
            return $image->save();
        } catch (Exception $e) {
            throw new WorkflowActionNotPerformedException();
        }
    }

    /**
     * Perform the archive action.
     *
     * @param Image $image
     *
     * @return Image
     */
    public function archive(Image $image)
    {
        try {
            $image->status = 'archive';
            return $image->save();
        } catch (Exception $e) {
            throw new WorkflowActionNotPerformedException();
        }
    }

    /**
     * Perform the unpublish action.
     *
     * @param Image $image
     *
     * @return Image
     */
    public function unpublish(Image $image)
    {
        try {
            $image->status = 'unpublish';
            return $image->save();
        } catch (Exception $e) {
            throw new WorkflowActionNotPerformedException();
        }
    }
}