pratiksh404 /
adminetic-website
| 1 | <?php |
||||
| 2 | |||||
| 3 | use Adminetic\Website\Models\Admin\Post; |
||||
| 4 | use Adminetic\Website\Models\Admin\Service; |
||||
| 5 | use Adminetic\Website\Models\Admin\Software; |
||||
| 6 | use Carbon\Carbon; |
||||
| 7 | use Illuminate\Support\Facades\Cache; |
||||
| 8 | use Spatie\SchemaOrg\Article; |
||||
| 9 | use Spatie\SchemaOrg\Graph; |
||||
| 10 | use Spatie\SchemaOrg\Schema; |
||||
|
0 ignored issues
–
show
|
|||||
| 11 | use Spatie\SchemaOrg\Service as SchemaOrgService; |
||||
| 12 | use Spatie\SchemaOrg\SoftwareApplication; |
||||
| 13 | |||||
| 14 | // Search Schema |
||||
| 15 | |||||
| 16 | if (! function_exists('about_organization_schema')) { |
||||
| 17 | function about_organization_schema() |
||||
| 18 | { |
||||
| 19 | $org = Schema::organization() |
||||
| 20 | ->name(title()) |
||||
|
0 ignored issues
–
show
The function
title 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
Loading history...
|
|||||
| 21 | ->alternateName('DTI') |
||||
| 22 | ->address(address()) |
||||
| 23 | ->phone(phone()) |
||||
| 24 | ->email(email()) |
||||
| 25 | ->image(logoBanner()) |
||||
|
0 ignored issues
–
show
The function
logoBanner 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
Loading history...
|
|||||
| 26 | ->logo(logo()); |
||||
|
0 ignored issues
–
show
The function
logo 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
Loading history...
|
|||||
| 27 | |||||
| 28 | return $org->toScript(); |
||||
| 29 | } |
||||
| 30 | } |
||||
| 31 | |||||
| 32 | if (! function_exists('services_schema')) { |
||||
| 33 | function services_schema() |
||||
| 34 | { |
||||
| 35 | $graph = new Graph(); |
||||
| 36 | $services = Cache::get('services', Service::orderBy('position')->get()); |
||||
| 37 | foreach ($services as $service) { |
||||
| 38 | $graph->service(str_replace(' ', '', $service->name), function (SchemaOrgService $schema, Graph $graph) use ($service): void { |
||||
|
0 ignored issues
–
show
The parameter
$graph is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 39 | $schema |
||||
| 40 | ->name($service->meta_name ?? $service->name) |
||||
| 41 | ->description($service->meta_description ?? $service->excerpt) |
||||
| 42 | ->url(route('website.service', ['service' => $service->slug])) |
||||
| 43 | ->keywords($service->meta_keywords); |
||||
| 44 | }); |
||||
| 45 | } |
||||
| 46 | |||||
| 47 | return $graph->toScript(); |
||||
| 48 | } |
||||
| 49 | } |
||||
| 50 | |||||
| 51 | if (! function_exists('software_schema')) { |
||||
| 52 | function software_schema() |
||||
| 53 | { |
||||
| 54 | $graph = new Graph(); |
||||
| 55 | $software = Cache::get('software', Software::orderBy('position')->get()); |
||||
| 56 | foreach ($software as $sw) { |
||||
| 57 | $modules = isset($sw->data['modules']) ? $sw->data['modules'] : null; |
||||
| 58 | $graph->softwareApplication(str_replace(' ', '', $sw->name), function (SoftwareApplication $schema, Graph $graph) use ($sw, $modules): void { |
||||
|
0 ignored issues
–
show
The parameter
$graph is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 59 | $schema |
||||
| 60 | ->name($sw->meta_name ?? $sw->name) |
||||
| 61 | ->author(title()) |
||||
|
0 ignored issues
–
show
The function
title 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
Loading history...
|
|||||
| 62 | ->description($sw->meta_description ?? $sw->excerpt) |
||||
| 63 | ->image($sw->banner) |
||||
| 64 | ->if(! is_null($modules), function (SoftwareApplication $schema) use ($modules) { |
||||
| 65 | $schema->email(collect($modules)->pluck('name')->toArray()); |
||||
| 66 | }) |
||||
| 67 | ->url(route('website.software', ['software' => $sw->slug])) |
||||
| 68 | ->keywords($sw->meta_keywords); |
||||
| 69 | }); |
||||
| 70 | } |
||||
| 71 | |||||
| 72 | return $graph->toScript(); |
||||
| 73 | } |
||||
| 74 | } |
||||
| 75 | |||||
| 76 | if (! function_exists('posts_schema')) { |
||||
| 77 | function posts_schema() |
||||
| 78 | { |
||||
| 79 | $graph = new Graph(); |
||||
| 80 | $posts = Cache::get('posts', Post::published()->orderBy('position')->get()); |
||||
| 81 | foreach ($posts as $post) { |
||||
| 82 | $graph->article(str_replace(' ', '', $post->name), function (Article $schema, Graph $graph) use ($post): void { |
||||
|
0 ignored issues
–
show
The parameter
$graph is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 83 | $schema |
||||
| 84 | ->name($post->meta_name ?? $post->name) |
||||
| 85 | ->description($post->meta_description ?? $post->excerpt) |
||||
| 86 | ->if(! is_null($post->getFirstMedia('image')), function (Article $schema) use ($post) { |
||||
| 87 | $schema->image($post->getFirstMediaUrl('image')); |
||||
| 88 | }) |
||||
| 89 | ->keywords($post->meta_keywords); |
||||
| 90 | }); |
||||
| 91 | } |
||||
| 92 | |||||
| 93 | return $graph->toScript(); |
||||
| 94 | } |
||||
| 95 | } |
||||
| 96 | |||||
| 97 | if (! function_exists('dateMode')) { |
||||
| 98 | function dateMode() |
||||
| 99 | { |
||||
| 100 | $mode = config('adminetic.cache_mode', true) ? |
||||
| 101 | Cache::has('date_mode') ? Cache::get('date_mode') : Cache::rememberForever('date_mode', function () { |
||||
| 102 | return setting('date_mode', config('website.date_mode', 'bs')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 103 | }) |
||||
| 104 | : setting('date_mode', config('website.date_mode', 'bs')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 105 | |||||
| 106 | return $mode; |
||||
| 107 | } |
||||
| 108 | } |
||||
| 109 | |||||
| 110 | if (! function_exists('modeDate')) { |
||||
| 111 | function modeDate(Carbon $date) |
||||
| 112 | { |
||||
| 113 | return dateMode() == 'bs' ? nepaliDate($date) : $date->toFormattedDateString(); |
||||
| 114 | } |
||||
| 115 | } |
||||
| 116 | |||||
| 117 | if (! function_exists('currency')) { |
||||
| 118 | function currency() |
||||
| 119 | { |
||||
| 120 | return setting('currency', config('website.currency', 'Rs.')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 121 | } |
||||
| 122 | } |
||||
| 123 | |||||
| 124 | if (! function_exists('short_description')) { |
||||
| 125 | function short_description() |
||||
| 126 | { |
||||
| 127 | return setting('short_description', config('website.short_description', null)); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 128 | } |
||||
| 129 | } |
||||
| 130 | |||||
| 131 | if (! function_exists('description')) { |
||||
| 132 | function description() |
||||
| 133 | { |
||||
| 134 | return setting('description', config('website.description', null)); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 135 | } |
||||
| 136 | } |
||||
| 137 | |||||
| 138 | if (! function_exists('map')) { |
||||
| 139 | function map() |
||||
| 140 | { |
||||
| 141 | return setting('map', config('website.map', null)); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 142 | } |
||||
| 143 | } |
||||
| 144 | |||||
| 145 | if (! function_exists('phone')) { |
||||
| 146 | function phone() |
||||
| 147 | { |
||||
| 148 | return setting('phone', config('website.phone', '')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 149 | } |
||||
| 150 | } |
||||
| 151 | |||||
| 152 | if (! function_exists('email')) { |
||||
| 153 | function email() |
||||
| 154 | { |
||||
| 155 | return setting('email', config('website.email', '')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 156 | } |
||||
| 157 | } |
||||
| 158 | |||||
| 159 | if (! function_exists('address')) { |
||||
| 160 | function address() |
||||
| 161 | { |
||||
| 162 | return setting('address', config('website.address', '')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 163 | } |
||||
| 164 | } |
||||
| 165 | |||||
| 166 | if (! function_exists('keywords')) { |
||||
| 167 | function keywords() |
||||
| 168 | { |
||||
| 169 | return setting('keywords', config('website.keywords', 'event management, doctype innovations')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 170 | } |
||||
| 171 | } |
||||
| 172 | |||||
| 173 | if (! function_exists('opening_hour')) { |
||||
| 174 | function opening_hour() |
||||
| 175 | { |
||||
| 176 | return setting('opening_hour', config('website.opening_hour', '9am to 6pm')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 177 | } |
||||
| 178 | } |
||||
| 179 | |||||
| 180 | if (! function_exists('facebook')) { |
||||
| 181 | function facebook() |
||||
| 182 | { |
||||
| 183 | return setting('facebook', config('website.facebook', 'https://www.facebook.com/doctypenepal')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 184 | } |
||||
| 185 | } |
||||
| 186 | |||||
| 187 | if (! function_exists('email')) { |
||||
| 188 | function email() |
||||
| 189 | { |
||||
| 190 | return setting('email', config('website.email', '[email protected]')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 191 | } |
||||
| 192 | } |
||||
| 193 | |||||
| 194 | if (! function_exists('facebook_messenger')) { |
||||
| 195 | function facebook_messenger() |
||||
| 196 | { |
||||
| 197 | return setting('facebook_messenger', config('website.facebook_messenger', 'https://m.me/doctypenepal')); |
||||
|
0 ignored issues
–
show
The function
setting 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
Loading history...
|
|||||
| 198 | } |
||||
| 199 | } |
||||
| 200 | |||||
| 201 | if (! function_exists('parseYoutube')) { |
||||
| 202 | function parseYoutube($video) |
||||
| 203 | { |
||||
| 204 | return preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", '<div class="embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" style="width: 100%;height: 30vh;" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe></div>', $video); |
||||
| 205 | } |
||||
| 206 | } |
||||
| 207 | |||||
| 208 | if (! function_exists('services')) { |
||||
| 209 | function services() |
||||
| 210 | { |
||||
| 211 | return Cache::get('services', Service::orderBy('position')->get()); |
||||
| 212 | } |
||||
| 213 | } |
||||
| 214 | |||||
| 215 | if (! function_exists('software')) { |
||||
| 216 | function software() |
||||
| 217 | { |
||||
| 218 | return Cache::get('software', Software::orderBy('position')->get()); |
||||
| 219 | } |
||||
| 220 | } |
||||
| 221 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: