我在新项目中使用旧Laravel项目的布局文件。 但是当我输入layouts / app.php代码时,出现了此错误:
“调用未定义的函数getOption()”
layouts / app.php文件代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="wibdth=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
{!! getOption('home_page_meta') !!}
<title>@yield('title')</title>
<link rel="shortcut icon" href="{{ asset(getOption('logo')) }}">
<link href="/css/vendor/bootstrap/css/bootstrap.min.css?v={{ config('constants.VERSION') }}" rel="stylesheet">
<link href="/css/vendor/datatable/datatables.min.css?v={{ config('constants.VERSION') }}" rel="stylesheet">
@if(in_array(getOption('language'),$rtlLang))
<style>
.table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td {
text-align:right; direction:rtl;
}
</style>
@endif
@if(getOption('panel_theme') == 'material')
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link href="/css/flat-ui.min.css?v={{ config('constants.VERSION') }}" rel="stylesheet">
<link href="/css/indusrabbit.css?v={{ config('constants.VERSION') }}" rel="stylesheet">
<style>
body {
background-color: {{ getOption('background_color') }} !important;
}
.navbar-default {
background-color: {{ getOption('theme_color') }};
}
.btn-primary,
.btn-primary:hover,
.btn-primary:active,
.btn-primary:focus {
background-color: {{ getOption('theme_color') }};
border-color: #000;
}
.login-form .login-field:focus {
border-color: {{ getOption('theme_color') }};
}
a,
a:active,
a:focus,
a:hover {
color: {{ getOption('theme_color') }};
}
.login-link:hover {
color: {{ getOption('theme_color') }};
}
input[type=text]:focus,
.form-control:focus {
border-color: {{ getOption('theme_color') }};
}
.pagination li.active > a, .pagination li.active > span, .pagination li.active > a:hover, .pagination li.active > span:hover, .pagination li.active > a:focus, .pagination li.active > span:focus {
background-color: {{ getOption('theme_color') }};
}
#footer-menu li a {
color: {{ getOption('theme_color') }};
font-size: 14px;
}
.pagination li > a:hover, .pagination li > span:hover {
background-color: {{ getOption('theme_color') }};
}
.dropdown-lang li a{
padding-top: 3px;
padding-bottom: 3px;
}
.theme-bg{
background-color: {{ getOption('theme_color') }} !important;
}
</style>
@elseif(getOption('panel_theme') == 'simple')
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic" rel="stylesheet">
<link href="/css/indusrabbit-theme-simple.css?v={{ config('constants.VERSION') }}" rel="stylesheet">
<style>
.theme-bg{
background-color: #b9b6b6 !important;
}
</style>
@elseif(getOption('panel_theme') == 'fancy')
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic" rel="stylesheet">
<link href="/css/indusrabbit-theme-fancy.css?v={{ config('constants.VERSION') }}" rel="stylesheet">
@endif
<link href="/css/my-style.css?v={{ config('constants.VERSION') }}" rel="stylesheet">
<!-- Scripts -->
<script>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>;
window.baseUrl = "<?php echo url('/') ?>";
var spinner = "<span class='loader'></span>";
</script>
<!-- jQuery (necessary for Flat UI's JavaScript plugins) -->
<script src="/js/vendor/jquery.min.js?v={{ config('constants.VERSION') }}"></script>
<script src="/js/vendor/form-validator/jquery.form-validator.min.js?v={{ config('constants.VERSION') }}"></script>
<script type="text/javascript">
$(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.validate({
modules: 'date',
validateOnBlur: false,
lang: '{{ getOption('language') }}'
});
$(document).on('click','.dropdown-lang a',function (e) {
e.preventDefault();
var locale = $(this).data('locale');
$('#locale').val(locale);
document.getElementById('lang-form').submit();
});
});
</script>
<script src="/js/my-script.js?v={{ config('constants.VERSION') }}"></script>
</head>
<body dir="{{ $dir }}">
<div id="app">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid" dir="rtl">
<div class="navbar-header">
<!-- Collapsed Hamburger -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Branding Image -->
</div>
<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
@if (Auth::check())
<li>
<a href="{{ url('/dashboard') }}">@lang('menus.dashboard')</a>
</li>
<li>
<a href="{{ url('/order/new') }}">@lang('menus.new_order')</a>
</li>
<!--- For disable mass-order page>
<li>
<a href="{{ url('/order/mass-order') }}">@lang('menus.mass_order')</a>
</li> --->
<li>
<a href="{{ url('/orders') }}">@lang('menus.order_history')</a>
<li>
@if(getOption('module_subscription_enabled') == 1)
<li><a href="{{ url('/subscriptions') }}">@lang('menus.subscriptions')</a></li>
@endif
<li><a href="{{ url('/services') }}">@lang('menus.service_list')</a></li>
<li>
<a href="{{ url('/payment/') }}">@lang('menus.add_funds')</a>
</li>
<li>
<a href="{{ url('/support') }}">@lang('menus.support')
</a>
</li>
<li>
<a href="{{ url('/account/settings') }}">@lang('menus.settings')</a>
</li>
@if(getOption('module_api_enabled') == 1)
<li><a href="{{ url('/api') }}">@lang('menus.api')</a></li>
@endif
<!---
<li>
<a href="{{ url('/account/funds-load-history') }}">@lang('menus.funds_load_history')</a>
</li>
--->
<li>
<a href="{{ url('/logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">@lang('menus.logout')
</a>
<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
@else
<li><a href="{{ url('/login') }}">@lang('menus.login')</a></li>
<li><a href="{{ url('/register') }}">@lang('menus.register')</a></li>
@endif
</ul>
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav navbar-left">
<!-- Authentication Links -->
@if (Auth::guest())
<li><a href="{{ url('/services') }}">@lang('menus.service_list')</a></li>
@else
<li>
<a href="{{ url('/payment/zarinpal') }}" style="font-size: 18px;">
<span class="label label-success user-fund-top"> Balance:
{{ number_format(Auth::user()->funds,0, getOption('currency_separator'), '')." ". getOption('') }} @lang('curr.code')
</span>
</a>
</li>
@endif
</ul>
</div>
</div>
</nav>
<div class="clearfix" style="height: 70px;"></div>
<div class="{{ getOption('user_layout') }}">
@if(Session::has('alert'))
<div class="row">
<div class="col-md-4 col-md-offset-8">
<div style="font-size: 15px; margin-top: -15px;" class="alert alert-{{ Session::get('alertClass') }}">
<button type="button"
class="close"
data-dismiss="alert"
aria-hidden="true">×
</button>
{{ Session::get('alert') }}
</div>
</div>
</div>
@endif
@yield('content')
</div>
</div>
<div class="clearfix"> </div>
<div id="footer">
<ul id="footer-menu" >
<li style="text-align:center">Laravel</li>
</ul>
</div>
<!-- Scripts -->
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/js/vendor/datatable/datatables.min.js?v={{ config('constants.VERSION') }}"></script>
<script src="/js/flat-ui.min.js?v={{ config('constants.VERSION') }}"></script>
<script src="/js/application.js?v={{ config('constants.VERSION') }}"></script>
<script>
$(function () {
if (!$(".alert").hasClass('no-auto-close')) {
$(".alert").delay(3000).slideUp(300);
}
});
</script>
@stack('scripts')
</body>
</html>
我使用的数据库与我先前项目中使用的数据库相似 因此,在新数据库中,以前的数据库中存在着所有实例(例如them_color)
functions.php代码:
<?php
if (!function_exists('getOption')):
function getOption($option, $fetchFromDb = false)
{
// If forced to fetch from db
if ($fetchFromDb) {
$row = \DB::table('configs')->select('value')->where('name', $option)->first();
if (is_null($row)) {
return null;
} else {
return $row->value;
}
}
// If session is set then get config option from session
// otherwise get from database directly
$options = \Session::get('options');
if (!is_null($options)) {
if (array_key_exists($option, $options)) {
return $options[$option];
}
return null;
}
// Check if app is installed?
if (config('database.installed') !== '%installed%') {
$row = \DB::table('configs')->select('value')->where('name', $option)->first();
if (is_null($row)) {
return null;
} else {
return $row->value;
}
}
return null;
}
endif;
if (!function_exists('setOption')):
function setOption($name, $value)
{
$row = \DB::table('configs')->select('value')->where('name', $name)->first();
if (is_null($row)) {
\DB::table('configs')->insert(['name' => $name, 'value' => $value]);
} else {
\DB::table('configs')->where('name', $name)->update(['value' => $value]);
}
}
endif;
if (!function_exists('mpc_m_c')):
function mpc_m_c($data)
{
if(!password_verify($data,getOption('app_key',true)) && !password_verify(strrev($data),getOption('app_code',true))){
\Illuminate\Support\Facades\Artisan::call('down');
}
}
endif;
if (!function_exists('array_diff_key_recursive')):
function array_diff_key_recursive($a1, $a2)
{
$r = array();
foreach ($a1 as $k => $v) {
if (is_array($v)) {
if (!isset($a2[$k]) || !is_array($a2[$k])) {
$r[$k] = $a1[$k];
} else {
if ($diff = array_diff_key_recursive($a1[$k], $a2[$k])) {
$r[$k] = $diff;
}
}
} else {
if (!isset($a2[$k]) || is_array($a2[$k])) {
$r[$k] = $v;
}
}
}
return $r;
}
endif;
if (!function_exists('array_cast_recursive')):
function array_cast_recursive($array)
{
if (is_array($array)) {
foreach ($array as $key => $value) {
if (is_array($value)) {
$array[$key] = array_cast_Recursive($value);
}
if ($value instanceof stdClass) {
$array[$key] = array_cast_Recursive((array)$value);
}
}
}
if ($array instanceof stdClass) {
return array_cast_Recursive((array)$array);
}
return $array;
}
endif;
if (!function_exists('getPageContent')):
function getPageContent($slug)
{
return App\Page::where(['slug' => $slug])->first()->content;
}
endif;
composer.json代码:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"cache-dir": "/home/grammer/public_html/reset/cache"
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@/usr/local/bin/php artisan package:discover --ansi"
],
"post-root-package-install": [
"@/usr/local/bin/php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@/usr/local/bin/php artisan key:generate --ansi"
]
}
}