app/Http/Controllers/ProductController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create()
    {
        if (Session::has("productImages")) {
            $productImages = [];
            foreach(Session::get("productImages") as $image) {
                if (!Storage::has("images/" . $image["name"])) continue;
                $file['name'] = $image;
                $file['url'] = asset('storage') . '/' . $image["name"];
                $file['size'] = Storage::size("images/" . $image["name"]);
                array_push($productImages, $file);
            }
            self::$viewData["productImages"] = json_encode($productImages);
        } else {
            self::$viewData["productImages"] = '[]';
        }
        self::$viewData["categories"] = Categories::all();
        self::$viewData["pageTitle"] .= 'New Product';
        return view("admin.newProduct", self::$viewData);
    }
public function create ( ) { if ( Session :: has ( " productImages " ) ) { $ productImages = [ ] ; foreach ( Session :: get ( " productImages " ) as $ image ) { if ( ! Storage :: has ( " images/ " . $ image [ " name " ] ) ) continue ; $ file [ 'name' ] = $ image ; $ file [ 'url' ] = asset ( 'storage' ) . '/' . $ image [ " name " ] ; $ file [ 'size' ] = Storage :: size ( " images/ " . $ image [ " name " ] ) ; array_push ( $ productImages , $ file ) ; } self :: $ viewData [ " productImages " ] = json_encode ( $ productImages ) ; } else { self :: $ viewData [ " productImages " ] = '[]' ; } self :: $ viewData [ " categories " ] = Categories :: all ( ) ; self :: $ viewData [ " pageTitle " ] .= 'New Product' ; return view ( " admin.newProduct " , self :: $ viewData ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .