Issues (25)

laravel/helpers.php (1 issue)

Labels
Severity
1
<?php
2
3
use Illuminate\Database\Eloquent\Model;
4
5
if (! function_exists('home_route')) {
6
    /**
7
     * Return the route to the "home" page depending on authentication/authorization status.
8
     *
9
     * @return string
10
     */
11
    function home_route()
12
    {
13
        if (Gate::allows('access backend')) {
14
            return route('admin.home');
15
        }
16
17
        return route('user.home');
18
    }
19
}
20
21
if (! function_exists('is_admin_route')) {
22
    /**
23
     * @param \Illuminate\Http\Request $request
24
     *
25
     * @return bool
26
     */
27
    function is_admin_route(Illuminate\Http\Request $request)
28
    {
29
        $action = $request->route()->getAction();
30
31
        return 'App\Http\Controllers\Dashboard' === $action['namespace'];
32
    }
33
}
34
35
if (! function_exists('image_template_url')) {
36
    /**
37
     * @param $template
38
     * @param $imagePath
39
     *
40
     * @return string
41
     */
42
    function image_template_url($template, $imagePath)
43
    {
44
        $imagePath = str_replace('/storage', '', $imagePath);
45
46
        return url(config('imagecache.route')."/{$template}{$imagePath}");
47
    }
48
}
49
50
if (! function_exists('localize_url')) {
51
    function localize_url($locale = null, $attributes = [], Model $translatable = null)
52
    {
53
        $url = null;
54
55
        if ($translatable && method_exists($translatable, 'getTranslation')) {
56
            /** @var \Spatie\Translatable\HasTranslations $translatable */
57
            if ($slug = $translatable->getTranslation('slug', $locale)) {
58
                $url = route(Route::current()->getName(), ['post' => $slug]);
59
            } else {
60
                $url = route('home');
61
            }
62
        }
63
64
        return LaravelLocalization::getLocalizedURL($locale, $url, $attributes, true);
0 ignored issues
show
The type LaravelLocalization 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...
65
    }
66
}
67