src/Http/Controllers/PostsController.php
public function store($id)
    {
        $data = [
            'title' => request('title'),
            'excerpt' => request('excerpt', ''),
            'slug' => request('slug'),
            'body' => request('body', ''),
            'published' => request('published'),
            'author_id' => request('author_id'),
            'featured_image' => request('featured_image'),
            'featured_image_caption' => request('featured_image_caption', ''),
            'publish_date' => request('publish_date', ''),
            'meta' => request('meta', (object) []),
        ];

        validator($data, [
            'publish_date' => 'required|date',
            'author_id' => 'required',
            'title' => 'required',
            'slug' => 'required|'.Rule::unique(config('wink.database_connection').'.wink_posts', 'slug')->ignore(request('id')),
        ])->validate();

        $entry = $id !== 'new' ? WinkPost::findOrFail($id) : new WinkPost(['id' => request('id')]);

        $entry->fill($data);

        $entry->save();

        $entry->tags()->sync(
            $this->collectTags(request('tags'))
        );

        return response()->json([
            'entry' => $entry,
        ]);
    }
public function store($id)
    {
        $data = [
            'title' => request('title'),
            'excerpt' => request('excerpt', ''),
            'slug' => request('slug'),
            'body' => request('body', ''),
            'published' => request('published'),
            'author_id' => request('author_id'),
            'featured_image' => request('featured_image'),
            'featured_image_caption' => request('featured_image_caption', ''),
            'publish_date' => request('publish_date', ''),
            'meta' => request('meta', (object) []),
        ];

        validator($data, [
            'publish_date' => 'required|date',
            'author_id' => 'required',
            'title' => 'required',
            'slug' => 'required|'.Rule::unique(config('wink.database_connection').'.wink_posts', 'slug')->ignore(request('id')),
        ])->validate();

        $entry = $id !== 'new' ? WinkPost::findOrFail($id) : new WinkPost(['id' => request('id')]);

        $entry->fill($data);

        $entry->save();

        $entry->tags()->sync(
            $this->collectTags(request('tags'))
        );

        return response()->json([
            'entry' => $entry,
        ]);
    }
public function store ( $ id ) { $ data = [ 'title' => request ( 'title' ) , 'excerpt' => request ( 'excerpt' , '' ) , 'slug' => request ( 'slug' ) , 'body' => request ( 'body' , '' ) , 'published' => request ( 'published' ) , 'author_id' => request ( 'author_id' ) , 'featured_image' => request ( 'featured_image' ) , 'featured_image_caption' => request ( 'featured_image_caption' , '' ) , 'publish_date' => request ( 'publish_date' , '' ) , 'meta' => request ( 'meta' , ( object ) [ ] ) , ] ; validator ( $ data , [ 'publish_date' => 'required|date' , 'author_id' => 'required' , 'title' => 'required' , 'slug' => 'required|' . Rule :: unique ( config ( 'wink.database_connection' ) . '.wink_posts' , 'slug' ) -> ignore ( request ( 'id' ) ) , ] ) -> validate ( ) ; $ entry = $ id !== 'new' ? WinkPost :: findOrFail ( $ id ) : new WinkPost ( [ 'id' => request ( 'id' ) ] ) ; $ entry -> fill ( $ data ) ; $ entry -> save ( ) ; $ entry -> tags ( ) -> sync ( $ this -> collectTags ( request ( 'tags' ) ) ) ; return response ( ) -> json ( [ 'entry' => $ entry , ] ) ; }
Store a single post.

@param  string  $id
@return \Illuminate\Http\JsonResponse
Store a single post .