コード例 #1
0
ファイル: AdminController.php プロジェクト: GraninNikita/feo
 public function news(Request $request)
 {
     if ($request->isMethod('POST')) {
         //            News::create($request->except('_token'));
         // read image from temporary file
         $file = $request->file('imagePrev');
         $img = Image::make($file->getRealPath());
         $nameFile = $file->getClientOriginalName();
         //          resize image
         $img->fit(263, 263);
         // save image
         $img->save("images/" . $nameFile);
         News::create(['text' => $request->input('editor1'), 'header' => $request->input('header'), 'picture' => "images/" . $nameFile]);
         //            switch ( $request->input('type') ) {
         //                case 'insert':
         //                    News::create($request->except('_token'));
         //                    break;
         //                case 'update':
         //                    News::find( $request->input('id') )->update([
         //                        'header' => $request->input('header'),
         //                        'text' => $request->input('editor1'),
         //                    ]);
         //                    break;
         //            }
     }
     if ($request->isMethod('GET')) {
         $item = News::find($request->input('remove'));
         if ($item) {
             $item->delete();
         }
     }
     $news = News::orderBy('created_at', 'DESC')->paginate(15);
     return view('admin/news', ['news' => $news]);
 }
コード例 #2
0
ファイル: NewsController.php プロジェクト: AmirHome/AmirHome
 /**
  * Show the form for editing the specified news.
  *
  * @param  int  $id
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $news = News::find($id);
     $direction = News::$direction;
     $language = News::$language;
     return view('admin.news.edit', compact('news', "direction", "language"));
 }
コード例 #3
0
 public function show($id)
 {
     $news = News::find($id);
     $news->visit++;
     $news->save();
     return view('news.show')->withNavSelection(3)->withTagSelection(-1)->withNews($news);
 }
コード例 #4
0
 public function delete_news(Request $request)
 {
     $id = $request->item_id;
     $news = News::find($id);
     $news->delete();
     return back()->with('message', "Новость удалена");
 }
コード例 #5
0
 public function show($id)
 {
     $article = News::find($id);
     $year = Carbon::now();
     $year = $year->year;
     return view('shownews')->with('article', $article)->with('year', $year);
 }
コード例 #6
0
 /**
  * Show the form for editing the specified news.
  *
  * @param  int  $id
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     $news = News::find($id);
     $sitelanguages = Sitelanguages::site_access()->join('sites', function ($join) {
         $join->on('sites.id', '=', 'sitelanguages.sites_id');
     })->join('languages', 'languages.id', '=', 'sitelanguages.languages_id')->select('sitelanguages.id', \DB::raw(' CONCAT(sites.title, \'-\',languages.code) as site_language'))->get()->lists('site_language', 'id')->prepend('Please select', '');
     $category = Category::site_access()->join('sitelanguages', 'sitelanguages.id', '=', 'category.sitelanguages_id')->join('languages', 'languages.id', '=', 'sitelanguages.languages_id')->join('sites', 'sites.id', '=', 'sitelanguages.sites_id')->select('category.id', 'category.title')->get()->lists('title', 'id')->prepend('Please select', '');
     return view('admin.news.edit', compact('news', "sitelanguages", "category"));
 }
コード例 #7
0
 public function delete($id)
 {
     $entry = News::find($id);
     if (isset($entry)) {
         News::where('id', $id)->update(array('trash' => 1));
         return \Redirect::route('news')->with('success', $entry->title . ' deleted succesfully!');
     } else {
         return \Redirect::route('news')->with('error', 'Failed to delete, invalid credentials.');
     }
 }
コード例 #8
0
ファイル: NewsController.php プロジェクト: siwaphol/med-site2
 public function update(Requests\NewsFormRequest $request, $id)
 {
     $news = News::find($id);
     $news->headline = $request->input('headline');
     $news->message = $request->input('message');
     $news->image = $request->file('image')->getClientOriginalName();
     $news->save();
     $request->file('image')->move(storage_path('app'), $news->image);
     $message = 'Successfully create news';
     return view('news.create', compact('message'));
 }
コード例 #9
0
 /**
  * Display the specified news article.
  *
  * @param  int  $id - id of a news artical
  * @return Response
  */
 public function show($id)
 {
     // find by $id
     $news_item = News::find($id);
     // if no news item found
     if (!$news_item) {
         // set response as an error
         return Response()->json(['message' => 'The news article could not be found', 'code' => 404], 404);
     }
     // set response as json with data
     return Response()->json(['data' => $news_item, 'code' => 200], 200);
 }
コード例 #10
0
ファイル: NewsController.php プロジェクト: stjanilofts/ofncms
 public function edit($id, $extra = array())
 {
     $news = \App\News::find($id);
     $extra['types'] = array('news' => 'Frétt');
     $extra['images'] = ['' => ' - Veldu mynd - '];
     if ($news->img()->exists()) {
         foreach ($news->img()->all() as $k => $img) {
             $extra['images'][$img['name']] = $img['name'];
         }
     }
     return parent::edit($id, $extra);
 }
コード例 #11
0
 /**
  * Отображает одну новость.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function getShow($id)
 {
     // Получаем новость из БД
     $data['news'] = News::find($id);
     if (!empty($data['news'])) {
         // Последние 3 новости
         $data['latest_news'] = News::where('id', '<>', $id)->orderBy('created_at', 'DESC')->take(3)->get();
         // Отображаем представление
         return view('marketing.news.show', $data);
     } else {
         abort(404);
     }
 }
コード例 #12
0
 public function update($id)
 {
     $aNewsData = Input::get('news');
     $validator = Validator::make($aNewsData, ['title' => 'sometimes|required|max:255', 'content' => 'sometimes|required', 'state' => 'sometimes|in:created,visible,deleted']);
     if ($validator->fails()) {
         $aRet = ['success' => 'false', 'errors' => $validator->errors()];
     } elseif ($oNews = News::find($id) and $oNews->fill($aNewsData)->update()) {
         $aRet = ['success' => 'true'];
     } else {
         $aRet = ['success' => 'false'];
     }
     return response()->json($aRet);
 }
コード例 #13
0
ファイル: AdminController.php プロジェクト: prudywsh/tpe
 public function destroyNews(Request $request)
 {
     $news = News::find($request->news_id);
     if ($news != NULL) {
         try {
             $news->delete();
             $message = array("reponse" => "success", "message" => "La news a bien été supprimée");
         } catch (\Exception $e) {
             $message = array("reponse" => "error", "message" => "Une erreur innatendue s'est produite");
         }
     } else {
         $message = array("reponse" => "error", "message" => "Une erreur innatendue s'est produite");
     }
     echo json_encode($message);
     return Redirect::route('AdminDisplayNews');
 }
コード例 #14
0
ファイル: NewsController.php プロジェクト: poudigne/lcdj
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['news_title' => 'required', 'news_text' => 'required']);
     $news = News::find($id);
     $news->is_published = $request->get('is_published') == 'on' ? 1 : 0;
     $news->title = $request->get('news_title');
     $news->text = $request->get('news_text');
     $news->save();
     $news->categories()->detach();
     if ($request->get('news_categories') != null) {
         foreach ($request->get('news_categories') as $category_id) {
             $news->categories()->attach($category_id);
         }
     }
     Session::flash('flash_message', 'Event successfully added!');
     return view('dashboard/create_news')->with('success', 1)->with('categories', Category::get())->with('news', $news);
 }
コード例 #15
0
ファイル: NewsController.php プロジェクト: AmirHome/AmirHome
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function bulid_slugs()
 {
     $news = News::select(['id', 'title', 'keywords', 'content', 'language'])->get();
     foreach ($news as $news_item) {
         $news_record = News::find($news_item->id);
         if ('fa' == $news_item->language) {
             $news_record->title = persian_normalizer($news_item->title);
             $news_record->keywords = persian_normalizer($news_item->keywords);
             $news_record->content = persian_normalizer($news_item->content);
             $news_record->slug = persian_slug($news_item->title);
         } elseif ('tr' == $news_item->language) {
             $news_record->slug = turkish_slug($news_item->title);
         } else {
             $news_record->slug = str_slug($news_item->title);
         }
         $news_record->save();
     }
     return 'Done bulid slugs';
 }
コード例 #16
0
 public function spotlight(Request $request)
 {
     $month = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
     $day = array('', '1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th', '21st', '22nd', '23rd', '24th', '25th', '26th', '27th', '28th', '29th', '30th', '31st');
     $filepath = public_path('../HomepageConfig.json');
     $file = fopen($filepath, "r");
     $config = json_decode(fread($file, filesize($filepath)));
     fclose($file);
     $newconfig = clone $config;
     $newconfig->spotlights = array();
     for ($i = 0; $i < count($request->input('newsid')); $i++) {
         $news = News::find($request->input('newsid')[$i]);
         if ($news != null) {
             $time = $news->created_at;
             $newconfig->spotlights[$i] = array('newsid' => $request->input('newsid')[$i], 'month' => $month[$time->month], 'day' => $day[$time->day], 'title' => $news->title);
         }
     }
     $file = fopen($filepath, "w");
     fwrite($file, json_encode($newconfig));
     fclose($file);
     return Redirect::to('admin/homepage');
 }
コード例 #17
0
 public function delete($id)
 {
     $news = News::find($id);
     return view('admin.news.delete')->withNews($news);
 }
コード例 #18
0
ファイル: NewsController.php プロジェクト: Techraav/PolyMusic
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $slug
  * @return Response
  */
 public function destroy(Request $request)
 {
     $model = News::find($request->id);
     if (empty($model)) {
         Flash::error('Impossible de supprimer cette news.');
         return Redirect::back();
     }
     $title = $model->title;
     $model->delete();
     makeModification('news', 'The news &laquo; ' . $title . ' &raquo; has been removed.');
     Flash::success('La news a bien été supprimé.');
     return redirect('news');
 }
コード例 #19
0
ファイル: NewsController.php プロジェクト: TheJokersThief/Eve
 public function update(Request $request, $newsID)
 {
     if (!Auth::check() || !Auth::user()->is_admin) {
         return response(view('errors.403', ['error' => $this->errorMessages['incorrect_permissions']]), 403);
     }
     $data = $request->only(['mce_0', 'mce_1', 'tags', 'featured_image']);
     // Validate all input
     $validator = Validator::make($data, ['mce_0' => 'required', 'mce_1' => 'required', 'featured_image' => 'image|sometimes']);
     if ($validator->fails()) {
         // If validation fails, redirect back to
         // registration form with errors
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if ($request->hasFile('featured_image')) {
         $data['featured_image'] = MediaController::uploadImage($request->file('featured_image'), time(), $directory = "news_images", $bestFit = true, $fitDimensions = [1920, 1080]);
     } else {
         unset($data['featured_image']);
     }
     $data['title'] = $data['mce_0'];
     $data['content'] = $data['mce_1'];
     $news = News::find($newsID);
     $news->update($data);
     return Redirect::route('news.edit', [$news->id]);
 }
コード例 #20
0
 public function post($id)
 {
     $nav = new category();
     $menu_top = $nav->menu_top($nav->all()->toArray());
     $news = News::getList();
     $post = News::find($id);
     $auth = User::all();
     $count = newsComment::getCount($id);
     $review = newsComment::getreview($id);
     return view('frontend.pages.post', array('post' => $post, 'auth' => $auth, 'news' => $news, 'menu_top' => $menu_top, 'count' => $count, 'review' => $review));
 }
コード例 #21
0
ファイル: NewsController.php プロジェクト: klokand/JulySite
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::all();
     $news = News::find($id);
     $validation = Validator::make($input, News::$news_update_rules);
     if ($validation->passes()) {
         if (Input::get('types') == 'news') {
             if (Input::file('coverImage') != null) {
                 $image = Input::file('coverImage');
                 $extension = $image->getClientOriginalExtension();
                 $filename = sha1(time() . time()) . ".{$extension}";
                 $upload_success = \Image::make($image)->resize(\Config::get('image.news_image_width'), \Config::get('image.news_image_height'))->save(\Config::get('image.news_image') . $filename);
                 if ($upload_success) {
                     $news->types = Input::get('types');
                     $news->author = Input::get('author');
                     $news->content = Input::get('content');
                     $news->title = Input::get('title');
                     $news->coverImage = $filename;
                     $news->save();
                     return Redirect::to('admin/newsList');
                 }
             } else {
                 $news->types = Input::get('types');
                 $news->author = Input::get('author');
                 $news->content = Input::get('content');
                 $news->title = Input::get('title');
                 $news->save();
                 return Redirect::to('admin/newsList');
             }
         } elseif (Input::get('types') == 'development') {
             if (Input::file('coverImage') != null) {
                 $image = Input::file('coverImage');
                 $extension = $image->getClientOriginalExtension();
                 $filename = sha1(time() . time()) . ".{$extension}";
                 $upload_success = \Image::make($image)->save(\Config::get('image.news_image') . $filename);
                 if ($upload_success) {
                     $news->types = Input::get('types');
                     $news->author = Input::get('author');
                     $news->content = Input::get('content');
                     $news->title = Input::get('title');
                     $news->coverImage = $filename;
                     $news->save();
                     return Redirect::to('admin/newsList');
                 }
             } else {
                 $news->types = Input::get('types');
                 $news->author = Input::get('author');
                 $news->content = Input::get('content');
                 $news->title = Input::get('title');
                 $news->save();
                 return Redirect::to('admin/newsList');
             }
         }
     } else {
         $error = $validation->errors()->first();
         return Redirect::back()->withInput(Input::all())->with(compact('error'));
     }
 }
コード例 #22
0
 public function unpublish($id)
 {
     $news = News::find($id);
     $news->active = 0;
     $news->save();
     return 'true';
 }
コード例 #23
0
ファイル: NewsController.php プロジェクト: hilmysyarif/sic
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     News::find($id)->delete();
     return redirect('/admin/news');
 }
コード例 #24
0
ファイル: HomeController.php プロジェクト: ryujikun/bridge
 public function show_news($id)
 {
     $this->data['news'] = News::find($id);
     return view('news_full', $this->data);
 }
コード例 #25
0
ファイル: NewsController.php プロジェクト: ryleto/nightjar
 public function item($id)
 {
     // Get all articles
     $news = News::find($id);
     return view('site.news.view_news', compact('news'));
 }
コード例 #26
0
 public function postEditNews(Request $request, $id)
 {
     $article = News::find($id);
     $article->title = $request->title;
     $article->slug = $request->slug;
     $article->anonce = $request->anonce;
     $article->container = $request->editor;
     $article->category = $request->category;
     $article->date_publish = Carbon::parse($request->date_publish)->format('Y-m-d H:i');
     if ($request->has_preview == 0) {
         $article->preview = null;
     }
     if ($request->hasFile('preview')) {
         $file = $request->file('preview');
         $filename = str_random(10);
         $extension = $file->getClientOriginalExtension();
         $surl = $this->globalSiteSettings['site_url'];
         $imgurl = $surl . '/uploads/' . $filename . '.' . $extension;
         Image::make($request->file('preview'))->fit(500, 200)->save(public_path() . '/uploads/' . $filename . '.' . $extension);
         $article->preview = $imgurl;
     }
     if ($article->save()) {
         return redirect('/dashboard/news');
     }
 }
コード例 #27
0
ファイル: NewsController.php プロジェクト: ryleto/nightjar
 /**
  * Remove the specified resource from storage.
  *
  * @param $id
  * @return Response
  */
 public function postDelete(DeleteRequest $request, $id)
 {
     $news = News::find($id);
     $news->delete();
 }
コード例 #28
0
 /**
  * Удаляет новость
  *
  * @param  int  $id
  * @return Response
  */
 public function getDelete($id)
 {
     $news = News::find($id);
     if (empty($news)) {
         abort(404);
     }
     // Удаляем изображение
     File::delete(public_path('assets' . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'news' . DIRECTORY_SEPARATOR . $news->thumbnail));
     $news->delete();
     return redirect()->action('Admin\\NewsController@getIndex')->with('success', 'Новость успешно удалена.');
 }
コード例 #29
0
ファイル: UserController.php プロジェクト: GraninNikita/feo
 public function detail_news($id)
 {
     $news = News::find($id);
     //        die();
     return view('detail_news', ['news' => $news]);
 }
コード例 #30
0
ファイル: NewsController.php プロジェクト: ResidentSleep/site
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     $news = News::find($id);
     $news->delete();
     // redirect
     Session::flash('success-delete', 'Material delete!');
     return Redirect::to('administrator/edit');
 }