Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /** * The file was created by Assimon. * * @author assimon<[email protected]> * ..

Decoded Output download

<?php
/**
 * The file was created by Assimon.
 *
 * @author    assimon<[email protected]>
 * @copyright assimon<[email protected]>
 * @link      http://utf8.hk/
 */

namespace App\Service;


use App\Exceptions\RuleValidationException;
use App\Models\Carmis;
use App\Models\Goods;
use App\Models\GoodsGroup;

/**
 * 
 *
 * Class GoodsService
 * @package App\Service
 * @author: Assimon
 * @email: [email protected]
 * @blog: https://utf8.hk
 * Date: 2021/5/30
 */
class GoodsService
{

    /**
     * 
     *
     * @return array|null
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function withGroup(): ?array
    {
        $goods = GoodsGroup::query()
            ->with(['goods' => function($query) {
                $query->withCount(['carmis' => function($query) {
                    $query->where('status', Carmis::STATUS_UNSOLD);
                }])->where('is_open', Goods::STATUS_OPEN)->orderBy('ord', 'DESC');
            }])
            ->where('is_open', GoodsGroup::STATUS_OPEN)
            ->orderBy('ord', 'DESC')
            ->get();
        // 
        return $goods ? $goods->toArray() : null;
    }

    /**
     * 
     *
     * @param int $id id
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function detail(int $id)
    {
        $goods = Goods::query()
            ->with(['coupon'])
            ->withCount(['carmis' => function($query) {
                $query->where('status', Carmis::STATUS_UNSOLD);
            }])->where('id', $id)->first();
        return $goods;
    }

    /**
     * 
     *
     * @param Goods $goods 
     * @return Goods
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function format(Goods $goods)
    {
        // 
        $goods->wholesale_price_cnf = $goods->wholesale_price_cnf ?
            format_wholesale_price($goods->wholesale_price_cnf) :
            null;
        // 
        $goods->other_ipu = $goods->other_ipu_cnf ?
            format_charge_input($goods->other_ipu_cnf) :
            null;
        return $goods;
    }

    /**
     * 
     *
     * @param Goods $goods
     * @return Goods
     * @throws RuleValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorGoodsStatus(Goods $goods): Goods
    {
        if (empty($goods)) {
            throw new RuleValidationException(__('dujiaoka.prompt.goods_does_not_exist'));
        }
        // .
        if ($goods->is_open != Goods::STATUS_OPEN) {
            throw new RuleValidationException(__('dujiaoka.prompt.the_goods_is_not_on_the_shelves'));
        }
        return $goods;
    }

    /**
     * 
     *
     * @param int $id id
     * @param int $number 
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function inStockDecr(int $id, int $number = 1): bool
    {
        return Goods::query()->where('id', $id)->decrement('in_stock', $number);
    }

    /**
     * 
     *
     * @param int $id id
     * @param int $number 
     * @return bool
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function salesVolumeIncr(int $id, int $number = 1): bool
    {
        return Goods::query()->where('id', $id)->increment('sales_volume', $number);
    }

}
 ?>

Did this file decode correctly?

Original Code

<?php
/**
 * The file was created by Assimon.
 *
 * @author    assimon<[email protected]>
 * @copyright assimon<[email protected]>
 * @link      http://utf8.hk/
 */

namespace App\Service;


use App\Exceptions\RuleValidationException;
use App\Models\Carmis;
use App\Models\Goods;
use App\Models\GoodsGroup;

/**
 * 
 *
 * Class GoodsService
 * @package App\Service
 * @author: Assimon
 * @email: [email protected]
 * @blog: https://utf8.hk
 * Date: 2021/5/30
 */
class GoodsService
{

    /**
     * 
     *
     * @return array|null
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function withGroup(): ?array
    {
        $goods = GoodsGroup::query()
            ->with(['goods' => function($query) {
                $query->withCount(['carmis' => function($query) {
                    $query->where('status', Carmis::STATUS_UNSOLD);
                }])->where('is_open', Goods::STATUS_OPEN)->orderBy('ord', 'DESC');
            }])
            ->where('is_open', GoodsGroup::STATUS_OPEN)
            ->orderBy('ord', 'DESC')
            ->get();
        // 
        return $goods ? $goods->toArray() : null;
    }

    /**
     * 
     *
     * @param int $id id
     * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function detail(int $id)
    {
        $goods = Goods::query()
            ->with(['coupon'])
            ->withCount(['carmis' => function($query) {
                $query->where('status', Carmis::STATUS_UNSOLD);
            }])->where('id', $id)->first();
        return $goods;
    }

    /**
     * 
     *
     * @param Goods $goods 
     * @return Goods
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function format(Goods $goods)
    {
        // 
        $goods->wholesale_price_cnf = $goods->wholesale_price_cnf ?
            format_wholesale_price($goods->wholesale_price_cnf) :
            null;
        // 
        $goods->other_ipu = $goods->other_ipu_cnf ?
            format_charge_input($goods->other_ipu_cnf) :
            null;
        return $goods;
    }

    /**
     * 
     *
     * @param Goods $goods
     * @return Goods
     * @throws RuleValidationException
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function validatorGoodsStatus(Goods $goods): Goods
    {
        if (empty($goods)) {
            throw new RuleValidationException(__('dujiaoka.prompt.goods_does_not_exist'));
        }
        // .
        if ($goods->is_open != Goods::STATUS_OPEN) {
            throw new RuleValidationException(__('dujiaoka.prompt.the_goods_is_not_on_the_shelves'));
        }
        return $goods;
    }

    /**
     * 
     *
     * @param int $id id
     * @param int $number 
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function inStockDecr(int $id, int $number = 1): bool
    {
        return Goods::query()->where('id', $id)->decrement('in_stock', $number);
    }

    /**
     * 
     *
     * @param int $id id
     * @param int $number 
     * @return bool
     *
     * @author    assimon<[email protected]>
     * @copyright assimon<[email protected]>
     * @link      http://utf8.hk/
     */
    public function salesVolumeIncr(int $id, int $number = 1): bool
    {
        return Goods::query()->where('id', $id)->increment('sales_volume', $number);
    }

}

Function Calls

None

Variables

None

Stats

MD5 b787ed9c3a0472c9219ed39073cebfeb
Eval Count 0
Decode Time 97 ms