-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelpers.php
39 lines (31 loc) · 970 Bytes
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
use Illuminate\Support\Str;
if (!function_exists('is_running_on_frontend')) {
function is_running_on_frontend(): bool
{
return Str::startsWith(optional(request()->route())->getName(), ['front.', 'api.']);
}
}
if (!function_exists('repository')) {
function repository($moduleName)
{
$repository = 'App\\Repositories\\' . ucfirst(Str::singular($moduleName)) . 'Repository';
if (class_exists($repository)) {
return app($repository);
}
$repository =
'App\\Twill\\Capsules\\' .
ucfirst(Str::plural($moduleName)) .
'\Repositories\\' .
ucfirst(Str::singular($moduleName)) .
'Repository';
return app($repository);
}
}
if (!function_exists('create_seo_fields')) {
function create_seo_fields($table)
{
$table->string('seo_title')->nullable();
$table->string('seo_description')->nullable();
}
}