TestimonialController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
dl 0
loc 29
rs 10
c 1
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 6 1
A store() 0 7 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Actions\Testimonial\Store;
6
use App\Http\Resources\TestimonialResource;
7
use App\Models\Testimonial;
8
use ArinaSystems\JsonResponse\Facades\JsonResponse;
9
use Illuminate\Http\Request;
10
11
class TestimonialController extends Controller
12
{
13
    /**
14
     * Display a listing of the resource.
15
     *
16
     * @return \Illuminate\Http\JsonResponse
17
     */
18
    public function index()
19
    {
20
        $testimonials = Testimonial::published()->get();
21
22
        return JsonResponse::json('ok', [
23
            'data' => TestimonialResource::collection($testimonials),
24
        ]);
25
    }
26
27
    /**
28
     * Store a newly created resource in storage.
29
     *
30
     * @param  \Illuminate\Http\Request    $request
31
     * @return \Illuminate\Http\JsonResponse
32
     */
33
    public function store(Request $request)
34
    {
35
        $testimonial = Store::run($request->all());
36
37
        return JsonResponse::json('ok', [
38
            'message' => "I'm delighted of your testimonial 😍, it'll be published as soon as possible. Thank you!",
39
            'data'    => $testimonial,
40
        ]);
41
    }
42
}
43