jet
7 months ago

Creating default object from empty value

Posted 7 months ago by jet

pls help i want to get the image, store it an display to the browser but am getting that error

    public function store(Request $request)
    {

        $data = $request->input();
        unset($data['_token']);
         $data['user_id'] = Auth::id();
         $data['slug'] = str_start('this/string', '/');
            if($request->hasFile('image')){
                        $image = $request->file('image');
                        $filename = time() . '.' . $image->getClientOriginalExtension();
                        $location = public_path('img/' . $filename);
                        Image::make($image)->resize(300, 300)->save($location );
                        $properties->image = $filename;
                    }
        $properties = new Property;

        $properties->category_id = $request->category_id;
        $properties->purpose = $request->purpose;
        //$properties->image = $request->image;
        $properties->type = $request->type;
        $properties->description = $request->description;
        $properties->country = $request->country;
        $properties->region = $request->region;
        $properties->city = $request->city;
        $properties->lon_lat = $request->lon_lat;
        $properties->status = $request->status;

        $properties->save();

        Session::flash('success', 'sucessfully save!');

        return redirect()->route('properties.index');
    }

Please sign in or create an account to participate in this conversation.