public function update($data) { $post = strip_tags($data['post']); $blog = Blog::find($data['blogID']); $blog->post = $post; $blog->save(); }
/** * Add the point to * * */ public function getShare($id, $social) { $url = ''; $post = \App\Blog::find($id); if ($post == NULL) { App::abort(404); } // add social point if it is not robot if (!isset($_SERVER['HTTP_USER_AGENT']) && !preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) { $post->socialPoint++; $post->save(); } switch ($social) { case 'twitter': $url = 'https://twitter.com/home?status='; $url .= $post['title'] . ' ' . $post->getUrl(); break; case 'facebook': $url = 'https://www.facebook.com/sharer/sharer.php?u='; $url .= $post->getUrl(); break; case 'googlePlus': $url = 'https://plus.google.com/share?url='; $url .= $post->getUrl(); break; case 'linkedIn': $url = 'https://www.linkedin.com/shareArticle?mini=true&'; $url .= 'url=' . $post->getUrl() . '&title=' . $post['title'] . '&summary=&source='; break; } return \Redirect::to($url); }
public function update() { $b = Blog::find($_POST['id']); $b->title = $_POST['title']; $b->date = $_POST['date']; $b->content = $_POST['content']; $b->save(); Functions::redirect('/'); }
public function edit(EditBlogRequest $request, $id) { $blog = Blog::find($id); $params = $request->all(); if ($request->hasFile('picture')) { $params['picture'] = $request->file('picture')->getClientOriginalName(); \File::delete('images/blog/' . $params['old_picture_name']); $request->file('picture')->move('images/blog', $params['picture']); } $blog->fill($params); $blog->save(); return redirect()->back()->with('success_message', 'Datos actualizados'); }
public function report(Request $request, $id) { $blog = Blog::find($id); Message::create(['content' => $request->note, 'to_user_id' => $blog->user->id, 'from_user_id' => $request->from, 'read' => false]); $user = $blog->user; $from = User::find($request->from); if ($user->notify_email) { Mail::send('email.report', ['username' => $blog->username, 'from' => $from, 'note' => $request->note], function ($message) use($user) { $message->to($user['email'], $user['username'])->subject('Blog signalé'); }); } $url = route('blog', $blog->username); $note = 'Blog ' . $blog->id . ' signalé: (<a href="' . $url . '">' . $url . '</a>)<br>'; $note .= $request->note; Message::create(['content' => $note, 'to_user_id' => User::where('role', '=', 'admin')->first()->id, 'from_user_id' => $request->from, 'read' => false]); return redirect()->back(); }
public function read(Request $request) { $page = 'blog'; $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json"); $pages = Pages::where('slug', '=', $page)->first(); $date = $request->year . '-' . $request->month . '-' . $request->day; $blog = Blog::where('date', '=', $date)->where('slug', '=', $request->slug)->first(); array_set($blog, "date", Carbon::createFromFormat('Y-m-d', $blog->date)); //INCREMENT Blog::find($blog->blogId)->increment('read'); //MORE BLOG $moreBlog = Blog::orderBy('date', 'desc')->where('blogId', '!=', $blog->blogId)->limit(2)->addSelect('title')->addSelect('date')->addSelect('slug')->get(); foreach ($moreBlog as $item) { array_set($item, "date", Carbon::createFromFormat('Y-m-d', $item->date)); } return view('website.blog.intern')->with(compact('page', 'pages', 'websiteSettings', 'blog', 'moreBlog')); }
public function storeNewBlog(Request $request) { $blog = new Blog(); $id = $blog->create($request->all())->id; if ($request->hasFile('img')) { $extension = $request->file('img')->getClientOriginalExtension(); $days = date("Ymd"); $secs = date("His", strtotime('+1 hour')); $imgName = "blog_id_" . $id . "_" . $days . "_" . $secs . "." . $extension; $path = public_path() . '/upload/blogs'; $image = $request->file('img'); $request->file('img')->move($path, $imgName); $image = Blog::find($id); $image->img = $imgName; $image->save(); } return redirect('/administration/blog/showAllBlogs'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $blog = Blog::find($id); $blog->delete(); session()->flash('flash_message', 'Post Deleted!!!'); return redirect('Recent-Posts'); }
public function tagData($tag) { $tagId = Tag::where('tagTitle', $tag)->pluck('id'); $tags = Tag::where('tagStatus', 1)->get(); $blogTag = BlogTag::where('tag_id', $tagId)->pluck('id'); #return $tagId; if ($blogTag == '') { return view('public.tag')->with('error', 'No Blog Post related to the Tag <b>' . $tag . '</b>')->with('tags', $tags)->with('tagName', $tag); } else { $tagData = Blog::find($tagId)->getBlogs; return view('public.tag')->with('tagData', $tagData)->with('tagList', $tagData)->with('tags', $tags)->with('tagName', $tag); } }
/** * Remove the specified resource from storage. * * DELETE /{id} * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $res = Blog::find($id)->delete(); $text = $res ? 'Запись удалена' : 'Запись не удалена'; session()->flash('global', $text); return redirect('/blog'); }
public function update(Request $request, Blog $blog) { $user = Sentinel::getUser()->id; $rules = ['title' => 'required|min:5|max:150|alpha_num', 'content' => 'required|min:10']; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return back()->withInput()->withErrors($validator); } else { # Create Blog $blog = Blog::find($blog->id); $blog->title = $request->title; $blog->content = $request->content; $blog->user_id = $user; # Redirect on Success if ($blog->save()) { $tags = $request->tags; foreach ($tags as $tag) { if (is_numeric($tag)) { $tagabledeletedRows = Taggable::where('tag_id', $tag)->delete(); $tagableSave = new Taggable(); $tagableSave->taggable_id = $blog->id; $tagableSave->tag_id = $tag; $tagableSave->taggable_type = 'App\\Blog'; $tagableSave->user_id = $user; $tagableSave->save(); } else { if (strlen($tag) >= 3) { $tagExist = Tag::where('text', $tag)->count(); if ($tagExist == 0) { $tagSave = new Tag(); $tagSave->text = $tag; $tagSave->save(); } } } } return redirect()->route('user.blog.index')->with('success', trans('validation.blog_success')); } } return back()->withInput()->with('error', 'مشکل در اتصال به سرور. لطفا مجددا تلاش کنید.'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $blog = Blog::find($id); $blog->delete(); return redirect('crud')->with('pesan', 'Data sudah di hapus'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $blog = Blog::find($id); return view('blog.edit', compact('blog')); }
| and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('index'); }); Route::get('demo', function () { return view('test'); }); Route::get('users', function () { $users = \App\User::All(); //select * from users return view('userhome')->with('blogger', $users); }); Route::get('profile/{id}', function ($uid) { $user = \App\User::find($uid); return view('profile')->with('user', $user); }); Route::get('blogdetail/{id}', function ($blogid) { $blog = \App\Blog::find($blogid); return view('blogdetails')->with('blogs', $blog); }); Route::post('/signup', array('as' => 'signup', 'before' => 'csrf', 'uses' => 'AuthController@userSignup')); Route::post('/signin', array('as' => 'signin', 'before' => 'csrf', 'uses' => 'AuthController@userSignin')); Route::get('home', array('as' => 'home', 'before' => 'auth', 'uses' => 'HomeController@getHome')); Route::get('vehicle', 'Front@vehicle'); Route::get('freeVehicle', 'Front@freeVehicle'); Route::get('bookingSuccess', 'Front@reservation'); Route::get('viewRoom', 'Front@viewRoom'); Route::get('viewLab', 'Front@viewLab'); Route::get('viewVehicle', 'Front@viewVehicle');
public function delete(Request $request) { if (!ACL::hasPermission('blog', 'delete')) { return redirect(route('blog'))->withErrors(['Você não tem permissão para deletar.']); } if ($request->image != "") { if (File::exists($this->folder . $request->image)) { File::delete($this->folder . $request->image); } } Blog::find($request->get('blogId'))->delete(); $success = "Matéria excluída com sucesso."; return redirect(route('blog'))->with(compact('success')); }
Route::get('/', 'PagesController@home'); Route::get('/about/{name}', 'PagesController@about'); Route::get('/contact', 'PagesController@contact'); Route::get('auth/login', 'Auth\\AuthController@getLogin'); Route::post('auth/login', 'Auth\\AuthController@postLogin'); Route::get('auth/logout', 'Auth\\AuthController@getLogout'); // Registration routes... Route::get('auth/register', 'Auth\\AuthController@getRegister'); Route::post('auth/register', 'Auth\\AuthController@postRegister'); use App\User; use App\Blog; Route::get('/user', function () { dd(User::all()); }); Route::get('/blog/create', function () { $blog = new Blog(); $blog->name = "First Blog"; $blog->description = "First Blog"; $blog->save(); }); Route::get('/blog', function () { return Blog::all(); }); Route::get('/blog/{id}', function ($id) { $blog = Blog::find($id); return $blog; }); Route::get('/blog/t/{tit}', function ($tit) { $blog = Blog::where('name', "=", $tit)->get(); return $blog; });
public function blog($title, $id) { $section = 'blog'; $blog = Blog::find($id); return view('blog', compact('section', 'blog')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function suspend($id) { $blog = Blog::find($id); $blog->state = 0; $blog->save(); return Redirect::to('adminPanel'); }
public function getBlogEdit($id) { $article = $this->blog->find($id); $cateObj = $this->cate->orderBy('created_at', 'desc')->get(); $bytes = md5(uniqid(rand(), TRUE)); session(['del_key' => $bytes]); //リレーションのオブジェクトを取得 $rels = Blog::find($id)->cateRelation; //Blogモデル内でhasManyメソッドを指定すると取得可能となる // foreach($rels as $rel) { // echo $rel->cate_id; // } return view('dbd_blogs.blogform', ['article' => $article, 'cateObj' => $cateObj, 'rels' => $rels]); }
public function show($id) { $blog = Blog::find($id); return view('blogs.show')->with('blog', $blog); }
public function postPublish(Request $request) { $id = $request->id; $id = explode(",", $id); foreach ($id as $val) { $B = Blog::find($val); $B->draft = 0; $B->arsip = 0; $B->save(); } }