app/Http/Controllers/Api/BlogController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(BlogRequest $request)
    {
        try {
            $blog = new Blog;
            $blog->fill($request->validated())->save();
            return new BlogResource($blog);
        } catch(\Exception $exception) {
            throw new HttpException(400, "Invalid data - {$exception->getMessage}");
        }
    }
public function store ( BlogRequest $ request ) { try { $ blog = new Blog ; $ blog -> fill ( $ request -> validated ( ) ) -> save ( ) ; return new BlogResource ( $ blog ) ; } catch ( \ Exception $ exception ) { throw new HttpException ( 400 , " Invalid data -  { $ exception -> getMessage } " ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .