目标:如果文件存在,请加载文件,否则加载default.png.
我试过了
@if(file_exists(public_path().'/images/photos/account/{{Auth::user()->account_id}}.png'))
<img src="/images/photos/account/{{Auth::user()->account_id}}.png" alt="">
@else
<img src="/images/photos/account/default.png" alt="">
@endif
Run Code Online (Sandbox Code Playgroud)
结果
它保持加载我的默认图像,而我100%确定1002.png存在.
如何正确检查该文件是否存在?
根据Laravel的说法 config/session.php
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => 120,
'expire_on_close' => true,
'expired-session-redirect' => url(env('APP_URL'))
Run Code Online (Sandbox Code Playgroud)
我已经将会话的生命周期设置为120分钟,但我感觉我的用户在120分钟之前就已经注销了.
那是一个错字吗?它们意味着120秒,这是2分钟?
任何人都可以对此有所了解吗?
我是Angular 5项目的新手.我跑去ng build --prod生成一个dist/文件夹.
我注意到构建需要相当长的时间,当我打开我的dist/文件夹时,我看到它有近98%无用的东西,比如SVG,图像等等.
我如何控制进入我的内容dist/?
.angular-cli.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "web"
},
"apps": [{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/ngx-toastr/toastr.css",
"../src/assets/css/style.css",
"../src/assets/css/colors/blue.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/jquery-slimscroll/jquery.slimscroll.min.js",
"../node_modules/pace-js/pace.min.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}],
"e2e": {
"protractor": {
"config": "./protractor.conf.js" …Run Code Online (Sandbox Code Playgroud) 因为它.env在我创建应用程序时自动在我的文件中为我设置它,我不确定何时应该运行它.
除此之外,如果第二个开发人员进来并克隆应用程序,他/她是否需要运行php artisan key:generate?
我们怎么知道何时运行php artisan key:generate?
我有一个使用datatables插件的表.
我正在尝试修复我的表头,并点击此链接:此处
$('.device-table').DataTable( {
"fixedHeader": {
header: true,
},
"bLengthChange": false,
"Filter": false,
"Info": false,
} );
Run Code Online (Sandbox Code Playgroud)
我没有看到效果.
我已经包含了数据表和fixedHeader的js文件:
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/fixedheader/3.1.2/js/dataTables.fixedHeader.min.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
如何进行调试?
我现在正在接受任何建议.
任何提示/建议/帮助将非常感谢!
在我的Laravel应用程序中,我运行
php artisan languages:export
Run Code Online (Sandbox Code Playgroud)
我有一个csv文件导出成功基于我的languages表.
但目标是利用来自Laravel的Artisan :: call,但当我在我的代码中执行此操作时
$export = Artisan::call('languages:export');
Run Code Online (Sandbox Code Playgroud)
我一直得到变量的0结果$export- 当然没有文件导出.
现在我尝试通过它来调用它 shell_exec() and exec()
$cmd = 'php '.base_path().'/artisan languages:export';
$export = shell_exec($cmd);
Run Code Online (Sandbox Code Playgroud)
我看不出任何一个都没有产生.
从命令行界面,我运行
php/Applications/MAMP/htdocs/code/artisan languages:export
我看到我的csv文件生成了.
如何通过代码进行并调用工匠命令?
我有一个简单的bash脚本,它接受输入并输出几行输入
fortinetTest.sh
read -p "Enter SSC IP: $ip " ip && ip=${ip:-1.1.1.1}
printf "\n"
#check IP validation
if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "SSC IP: $ip"
printf "\n"
else
echo "Enter a valid SSC IP address. Ex. 1.1.1.1"
exit
fi
Run Code Online (Sandbox Code Playgroud)
我试图将它们上传到我的服务器,然后尝试通过它运行它 curl
当我使用cURL/wget时,不确定为什么输入提示永远不会启动.
我错过了什么吗?
如何进行并进一步调试?
我现在对任何建议持开放态度.
任何提示/建议/帮助将非常感谢!
我正在尝试将 json 存储到数据库中并将其加载回来
我尝试存储
{name: "John", age: 31, city: "New York"}
Run Code Online (Sandbox Code Playgroud)
它存储正确。我检查了数据库,它显示正确。
{姓名:“约翰”,年龄:31,城市:“纽约”}
我不断地看到风景
"{name: \"John\", age: 31, city: \"New York\"}"
Run Code Online (Sandbox Code Playgroud)
这是我的代码。
public function store()
{
$paste = new Paste;
$paste->uuid = Str::uuid()->toString();
$paste->data = trim(Request::get('data',''));
$paste->save();
return Redirect::to('/paste/'.$paste->uuid)->with('success', 'Created');
}
public function show($uuid)
{
$paste = Paste::where('uuid',$uuid)->first();
return response()->json($paste->data);
}
Run Code Online (Sandbox Code Playgroud)
对我有什么提示吗?
可在此处重现
https://www.bunlongheng.com/paste
如果我这样做
public function show($uuid)
{
$paste = Paste::where('uuid',$uuid)->first();
return View::make('layouts.fe.pastes.show', get_defined_vars());
}
Run Code Online (Sandbox Code Playgroud)
在我看来,我只有这 1 行
{!!$paste->data!!}
Run Code Online (Sandbox Code Playgroud)
我得到的数据与我现在提交的数据相同。
{name: "John", age: 31, city: "New York"}
Run Code Online (Sandbox Code Playgroud)
但浏览器将其检测为文本,而不是响应 …
我在L4,这是我的app.php
<?php
return array(
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => true,
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. …Run Code Online (Sandbox Code Playgroud) <input type="file" upload-files multiple />
Run Code Online (Sandbox Code Playgroud)
<button class="btn btn-link" ng-click="store()" >Create</button>
Run Code Online (Sandbox Code Playgroud)
myApp.directive('uploadFiles', function () {
return {
scope: true,
link: function (scope, element, attrs) {
element.bind('change', function (event) {
var files = event.target.files;
for (var i = 0; i < files.length; i++) {
scope.$emit("seletedFile", { file: files[i] });
}
});
}
};
});
Run Code Online (Sandbox Code Playgroud)
$scope.files = [];
$scope.$on("seletedFile", function (event, args) {
console.log("event is ", event);
console.log("args is ", args);
$scope.$apply(function () {
$scope.files.push(args.file);
});
});
Run Code Online (Sandbox Code Playgroud)
php ×7
laravel ×6
laravel-5 ×5
javascript ×3
laravel-5.1 ×2
angular ×1
angular-cli ×1
angular5 ×1
angularjs ×1
bash ×1
console ×1
curl ×1
datatables ×1
html-table ×1
jquery ×1
json ×1
laravel-4 ×1
laravel-8 ×1
linux ×1
session ×1
shell ×1
webpack ×1