app/Http/Controllers/Blog/Admin/PostController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(BlogPostUpdateRequest $request, $id)
    {
        $item = $this->blogPostRepository->getEdit($id);
        if(empty($item)){
            return back()
                ->withErrors(['msg' => "Post id=[{$id}] not found"])
                ->withInput();
        }
        $data = $request->all();
        if(empty($item->published_at) && $data['is_published']){
            $data['published_at'] = Carbon::now();
        -----------------------------------
        $result = $item->update($data);
        dd($data);
        if ($result){
            return redirect()
                ->route('blog.admin.posts.edit', $item->id)
                ->with(['success' => 'Saved']);
        }else {
            return back()
                ->withErrors(['msg' => 'Save errors'])
                ->withInput();
        }
    }
public function update ( BlogPostUpdateRequest $ request , $ id ) { $ item = $ this -> blogPostRepository -> getEdit ( $ id ) ; if ( empty ( $ item ) ) { return back ( ) -> withErrors ( [ 'msg' => " Post id=[ { $ id } ] not found " ] ) -> withInput ( ) ; } $ data = $ request -> all ( ) ; $ result = $ item -> update ( $ data ) ; if ( $ result ) { return redirect ( ) -> route ( 'blog.admin.posts.edit' , $ item -> id ) -> with ( [ 'success' => 'Saved' ] ) ; } else { return back ( ) -> withErrors ( [ 'msg' => 'Save errors' ] ) -> withInput ( ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
//Закинуть в обсервер {Закинул :D} //        if(empty($data['slug'])){ //            $data['slug'] = \Str::slug($data['title']); //        } // //        if(empty($item->published_at) && $data['is_published']){ //            $data['published_at'] = Carbon::now(); //        } //----------------------------------- //dd($data);