Exemplo n.º 1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $story = Story::find($id);
     $partial_display_link = 'story.partials._';
     $partial_display_link = $partial_display_link . $story->slug;
     return view('story/show', compact('story', 'partial_display_link'));
 }
 /**
  * get a view to view user stories
  * @param $id
  * @return $this
  */
 public function viewStory($id)
 {
     $story = Story::find($id);
     $comments = DB::table('comments')->where('storyid', $id)->get();
     if (Auth::check()) {
         return view('client.view_story1')->with('comments', $comments)->with('story', $story);
     } else {
         return view('client.view_story')->with('comments', $comments)->with('story', $story);
     }
 }
Exemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, StoryFormRequest $request)
 {
     $story = Story::find($id);
     $story->update(['title' => $request->get('title'), 'user_id' => $request->get('user_id'), 'thumbnail' => $request->get('thumbnail'), 'story' => $request->get('story')]);
     //
     return \Redirect::route('stories.edit', array($story->id))->with('message', 'Your list has been updated!');
 }
Exemplo n.º 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $story = Story::find($id);
     if (empty($story)) {
         abort(404);
     }
     if ($request->user()->cannot('edit-story', $story)) {
         abort(403);
     }
     if ($request->input('lock')) {
         if ($story->lock()) {
             return;
             // 200 OK
         } else {
             abort(423);
             // 423 Locked
         }
     }
     $this->validate($request, ['image_id' => 'integer|exists:image,id', 'user_id' => 'integer|exists:user,id', 'tag_ids.*' => 'integer|exists:tag,id', 'translations' => 'array', 'translations.*.title' => 'string|max:255', 'translations.*.content' => 'string']);
     $story->update(app_array_filter($request->all(), ['image_id', 'tag_ids']));
     // TODO transfer story page to another user...
     if ($request->has('translations')) {
         foreach ($request->input('translations') as $locale => $texts) {
             if (!Languages::has($locale)) {
                 continue;
             }
             $translation = StoryTranslation::firstOrCreate(['story_id' => $id, 'locale' => $locale]);
             $translation->update(app_array_filter($texts, ['title', 'content']));
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $story = Story::find($id);
     $story->title = Input::get('title');
     $story->subtitle = Input::get('subtitle');
     $story->description = Input::get('description');
     $story->location = Input::get('location');
     $story->save();
     return redirect('story/' . $id);
 }