小编kyo*_*kyo的帖子

确定Laravel 5中是否存在文件

目标:如果文件存在,请加载文件,否则加载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存在.

如何正确检查该文件是否存在?

php laravel laravel-5 laravel-5.1

14
推荐指数
5
解决办法
6万
查看次数

Laravel 5 Session Lifetime

根据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分钟?

任何人都可以对此有所了解吗?

php session laravel-5

14
推荐指数
2
解决办法
3万
查看次数

如何正确构建优化Angular 5项目?

我是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)

javascript webpack angular-cli angular angular5

14
推荐指数
4
解决办法
2万
查看次数

何时在Laravel中生成新的应用程序密钥?

因为它.env在我创建应用程序时自动在我的文件中为我设置它,我不确定何时应该运行它.

除此之外,如果第二个开发人员进来并克隆应用程序,他/她是否需要运行php artisan key:generate

我们怎么知道何时运行php artisan key:generate

php console laravel laravel-5 laravel-5.1

13
推荐指数
3
解决办法
1万
查看次数

DataTable固定标头不起作用

我有一个使用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)

如何进行调试?


我现在正在接受任何建议.

任何提示/建议/帮助将非常感谢!

javascript jquery html-table datatables

13
推荐指数
2
解决办法
3万
查看次数

通过Code Not Working调用Artisan命令

描述

在我的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文件生成了.


如何通过代码进行并调用工匠命令?

php laravel laravel-5

13
推荐指数
3
解决办法
2697
查看次数

通过cURL远程执行Bash脚本

我有一个简单的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时,不确定为什么输入提示永远不会启动.

我错过了什么吗?


问题

如何进行并进一步调试?


我现在对任何建议持开放态度.

任何提示/建议/帮助将非常感谢!

linux bash shell curl

13
推荐指数
2
解决办法
1727
查看次数

在 Laravel 中从数据库存储和加载 JSON 的最佳方法

我正在尝试将 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


尝试#2

如果我这样做

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)

但浏览器将其检测为文本,而不是响应 …

php json laravel laravel-schema-builder laravel-8

13
推荐指数
1
解决办法
3万
查看次数

在Laravel 4上不推荐使用函数mcrypt_get_iv_size()

我在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)

php laravel laravel-4

12
推荐指数
1
解决办法
2万
查看次数

通过AngularJS将多个文件上传到Laravel Controller


我有

在此输入图像描述

浏览文件按钮

<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)

发布数据和选定的文件. …

javascript php laravel angularjs laravel-5

12
推荐指数
1
解决办法
1135
查看次数