/** * Store a newly created resource in storage. * * @param PhotosRequest $request * @return \Illuminate\Http\Response */ public function store(PhotosRequest $request) { // input variables $input = \Input::except('item_id', 'item_model', 'item_type', 'image'); $input['slug'] = \trslug::trslug(\Input::get('title')); $input['photo_id'] = \Input::get('item_id'); $input['photo_type'] = \Input::get('item_type'); $input['line'] = 0; // create photo $img = Photos::create($input); // save image slug&&upload $storagepath = storage_path('app') . '/img/photos/' . $img->id; $img->slug = '/img/photos/' . $img->id . '/' . $input['slug'] . '.jpg'; $img->save(); !file_exists($storagepath) ? mkdir($storagepath, 0777, true) : null; \Intervention::make(\Input::file('image'))->save($storagepath . '/' . $input['slug'] . '.jpg'); return \Redirect::back()->with('message', 'Kaydedildi!'); }