App\Http\Controllers\ProductsController::edit PHP Method

edit() public method

Show the form for editing the specified resource.
public edit ( integer $id ) : Response
$id integer
return Response
    public function edit($id)
    {
        $product = Product::find($id);
        if (\Auth::id() != $product->user_id) {
            return redirect('products/' . $product->user_id)->withErrors(['not_access' => [trans('globals.not_access')]]);
        }
        $typeItem = $product->type;
        $disabled = '';
        $order = OrderDetail::where('product_id', $id)->join('orders', 'order_details.order_id', '=', 'orders.id')->first();
        if ($order) {
            $disabled = 'disabled';
        }
        $features = ProductDetail::all()->toArray();
        $allCategoriesStore = Category::actives()->lightSelection()->get()->toArray();
        $categories = ['' => trans('product.controller.select_category')];
        //categories drop down formatted
        productsHelper::categoriesDropDownFormat($allCategoriesStore, $categories);
        $condition = ['new' => trans('product.controller.new'), 'refurbished' => trans('product.controller.refurbished'), 'used' => trans('product.controller.used')];
        $edit = true;
        $panel = $this->panel;
        $oldFeatures = ProductDetail::oldFeatures($product->features);
        $productsDetails = new featuresHelper();
        return view('products.form', compact('product', 'panel', 'features', 'categories', 'condition', 'typeItem', 'disabled', 'edit', 'oldFeatures', 'productsDetails'));
    }