Example #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param NewsRequest $request
  * @param  int $id
  * @return Response
  */
 public function update(NewsRequest $request, $id)
 {
     $news = News::findOrFail($id);
     $news->update($request->all());
     \Flash::success('Nieuwsartikel aangepast');
     return redirect('admin/news');
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(NewsRequest $request, $id)
 {
     $news_item = Blog_Item::findOrFail($id);
     $news_item->fill($request->all());
     $news_item->save();
     return Redirect::back()->with("good", "Successfully updated news item.");
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(NewsRequest $request)
 {
     try {
         $request->merge(array('news' => 1));
         if ($request->hasFile('file')) {
             $fileInfo = $this->uploadFile($request->file('file'), 'news');
             if ($fileInfo) {
                 $ship = $this->ship->create($request->only($this->dataGet), $fileInfo['original-name']);
                 //save info file
                 $file = new FileRepository(new File());
                 $fileInfo['ship_id'] = $ship->id;
                 $file->create($fileInfo);
             }
         } else {
             $this->ship->create($request->only($this->dataGet));
         }
         return redirect()->back();
     } catch (Exception $e) {
         return redirect()->back()->withInput()->with('error', 'Xãy ra lỗi khi thêm dữ liệu');
     }
 }
Example #4
0
 /**
  * @param NewsRequest $request
  * @return mixed
  */
 public function store(NewsRequest $request)
 {
     if ($request->hasFile('photo')) {
         if ($request->file('photo')->isValid()) {
             $photoName = md5(Carbon::now()) . "." . $request->file('photo')->getClientOriginalExtension();
             $request->file('photo')->move(public_path('images'), $photoName);
             $photo = Photo::create(['url' => $photoName]);
             $slug = slug_for_url($request->title);
             $request->user()->news()->create(['title' => $request->title, 'type' => $request->type, 'description' => $request->description, 'photo_id' => $photo->id, 'slug' => $slug]);
             return back()->withNotification('News has been created!')->withType('success');
         }
     }
 }
Example #5
0
 /**
  * Update the news item in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update($id, NewsRequest $request)
 {
     $news = News::findOrFail($id);
     $news->update($request->all());
     flash()->success('Your news item has been updated');
     return redirect()->action('NewsController@edit', $news->id);
 }
Example #6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \App\Http\Requests\NewsRequest $request
  * @param  \App\News $news
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\NewsRequest $request, News $news)
 {
     DB::transaction(function () use($request, $news) {
         $update = ['active' => $request->get('active'), 'sort' => $request->get('sort')];
         if ($this->systemAdmin) {
             $update['department_id'] = $request->get('department_id');
         }
         $news->update($update);
         foreach ($news->langs as $lang) {
             $lang->update(['title' => $request->get('title_' . systemTrans($lang['lang_id'])), 'description' => $request->get('description_' . systemTrans($lang['lang_id']))]);
         }
     });
     return redirect(action('Admin\\NewsController@index'))->with('success', 'updated');
 }
 /**
  * @param $id
  * @param NewsRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($id, NewsRequest $request)
 {
     $getNews = $this->news->findOrFail($id);
     $slug = str_limit(str_slug($request->title), 50) . "--author-{$request->user()->username}";
     /*$news  = News::where('summary',$slug)->first();
     
             if($news)
             {
                 $slug = str_limit(str_slug($request->title),50)."-".time()."--author-{$request->user()->username}";
             }*/
     $news = $getNews->update(['title' => $request->title, 'text' => $request->text, 'summary' => $slug, 'is_published' => true, 'news_type' => $request->news_type]);
     return redirect()->route('news.show', $slug)->with('message', 'News Updated');
 }
Example #8
0
 /**
  * Edition d'une news en DB
  */
 public function update($id, NewsRequest $request)
 {
     $news = News::findOrFail($id);
     $news->update($request->only('name', 'slug', 'content'));
     return redirect(action('NewsController@index'))->with('success', 'La news à bien été modifiée');
 }