Issues (66)

src/Controllers/LocalesController.php (5 issues)

Labels
Severity
1
<?php
2
3
namespace Lionix\SeoManager\Controllers;
4
5
use App\Http\Controllers\Controller;
0 ignored issues
show
The type App\Http\Controllers\Controller was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Http\Request;
0 ignored issues
show
The type Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Lionix\SeoManager\Models\Locale;
8
9
class LocalesController extends Controller
10
{
11
12
    /**
13
     * @return \Illuminate\Http\JsonResponse
0 ignored issues
show
The type Illuminate\Http\JsonResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
     */
15
    public function getLocales()
16
    {
17
        $locales = Locale::pluck('name');
18
        return response()->json(['locales' => $locales]);
0 ignored issues
show
The function response was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        return /** @scrutinizer ignore-call */ response()->json(['locales' => $locales]);
Loading history...
19
    }
20
21
    /**
22
     * @param Request $request
23
     * @return \Illuminate\Http\JsonResponse
24
     */
25
    public function addLocale(Request $request)
26
    {
27
        try{
28
            $locale = Locale::whereName($request->get('name'))->first();
29
            if(!$locale){
30
                $locale = new Locale();
31
                $locale->fill($request->all());
32
                $locale->save();
33
                return response()->json(['locale' => $locale->name]);
0 ignored issues
show
The function response was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
                return /** @scrutinizer ignore-call */ response()->json(['locale' => $locale->name]);
Loading history...
34
            }
35
            throw new \Exception('Locale is already exist');
36
        }catch (\Exception $exception){
37
            return response()->json(['status' => false, 'message' => $exception->getMessage()], 400);
38
        }
39
    }
40
}
41