public function store() { $data = Input::all(); $album = new Album(); $album['title'] = $data['title']; $album['user_id'] = Session::get('user')['id']; $album['privacy'] = $data['privacy']; $file = Input::file('img'); $folder_user = Session::get('user')['account']; $album_path = 'public/upload/' . $folder_user . '/' . uniqid(date('ymdHisu')); foreach ($file as $key => $f) { $name = uniqid() . "." . $f->getClientOriginalExtension(); $f->move($album_path, $name); if ($key == 0) { // $album['album_img'] = $name; $album->save(); FEEntriesHelper::save($album->id, FEEntriesHelper::getId("Album"), $album->user_id, $album->privacy); } $path = $album_path . '/' . $name; $image = new Image(); $image['path'] = $path; $image['user_id'] = Session::get('user')['id']; $image['album_id'] = $album['id']; $image['width'] = getimagesize($path)[0]; $image['height'] = getimagesize($path)[1]; $image->save(); } echo json_encode($file); }
public function store() { $datas = Input::all(); $post = new Post(); $post->content = $datas['content']; $post->user_id = Session::get('user')['id']; $post->privacy = $datas['privacy']; $post->save(); FEEntriesHelper::save($post->id, FEEntriesHelper::getId("Post"), $post->user_id, $post->privacy); return Redirect::back()->with('message', 'Đăng thành công!'); }
public function store() { $datas = Input::all(); $blog = new Blog(); if ($datas['title']) { $blog->title = $datas['title']; } else { $blog->title = "Không tiêu đề"; } $blog->content = $datas['content']; $blog->user_id = Session::get('user')['id']; $blog->privacy = $datas['privacy']; $blog->save(); FEEntriesHelper::save($blog->id, FEEntriesHelper::getId("Blog"), $blog->user_id, $blog->privacy); return Redirect::back(); }