小编ses*_*360的帖子

创建时的Laravel模型错误处理

我想使用Eloquent创建这样的数据库条目:

   MFUser::create(array(
        'user_reference' => $this->userReference,
        'first_name' => $this->firstName,
        'last_name' => $this->lastName,
        'user_type_id' => $this->userTypeId,
        'email' => $this->email,
        'password' => $this->password
    ));
Run Code Online (Sandbox Code Playgroud)

除了将完全相同的数据放入字段中(这是预期的,因为不应有重复项)的情况之外,它工作得很好。然后我得到了QueryExecption。

但是,如何在此处正确执行错误处理以检查是否发生此查询异常,以便随后可以通过json将服务器的响应返回给客户端?

php laravel

5
推荐指数
2
解决办法
8342
查看次数

laravel 的 nginx 配置

我为 nginx 创建了这个配置文件来访问我的 Laravel 页面:

server {
    listen 80;
    listen [::]:80;

    root /var/www/mfserver/public;
    index index.php index.html index.htm;

    server_name dispo.medifaktor.de;

    location / {
        try_files $uri $uri/ /index.php?is_args$args;
    }

    error_page 404 /index.php;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /var/www/mfserver/public;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我调用页面 dispo.medifaktor.de 时,我看到了主页。但是当我调用http://dispo.medifaktor.de/v1/incidents 时,我收到了一个服务器错误 500。为什么我不能访问这些页面?

路由文件正在工作:

Route::group(['domain' …
Run Code Online (Sandbox Code Playgroud)

php nginx laravel

5
推荐指数
1
解决办法
1833
查看次数

Swift中的calloc

如何将以下ObjectiveC语句转换为SWIFT:

UInt32 *pixels;
pixels = (UInt32 *) calloc(height * width, sizeof(UInt32));
Run Code Online (Sandbox Code Playgroud)

我试着做以下事情:

var pixels: UInt32
pixels = (UInt32)calloc(height * width, sizeof(UInt32))
Run Code Online (Sandbox Code Playgroud)

我收到错误消息:

Int不可转换为UInt

并且(UInt32)Casting也不起作用.有人可以给我一些建议吗?我还在与SWIFT苦苦挣扎.谢谢.

objective-c swift

4
推荐指数
1
解决办法
1964
查看次数

循环显示图片中的像素

我写了以下函数:

    class func convertImageToBlackAndWhite(#data:UnsafeMutablePointer<UInt32>, inputWidth:UInt32, inputHeight:UInt32) -> UnsafeMutablePointer<UInt32> {
    var currentPixel = UnsafeMutablePointer<UInt32>()
    currentPixel = data

    for (var i = 0; i < Int(inputHeight); i++) {
        for (var j = 0; j < Int(inputWidth); j++) {
            var color:UInt32 = currentPixel.memory

            // Average of RGB = greyscale
            var averageColor:UInt32 = (R(color) + G(color) + B(color)) / 3
            var updatedColor:UInt32 = RGBAMake(averageColor, g: averageColor, b: averageColor, a: A(color))
            currentPixel.memory = updatedColor
            currentPixel++
        }
    }

    var outputData = UnsafeMutablePointer<UInt32>((calloc(UInt(inputHeight*inputWidth), UInt(sizeof(UInt32)))))
    outputData = currentPixel …
Run Code Online (Sandbox Code Playgroud)

c arrays swift

4
推荐指数
1
解决办法
1894
查看次数

VueJS 多个混合

我的脚本中有一个错误,我不知道要修复。我想导入我创建的多个 mixin。

import GoogleMaps from '../mixins/GoogleMaps.js';
import MFApi from '../mixins/MFApi.js';

    export default {
        template: require('../templates/map.html'),
        mixins: [GoogleMaps, MFApi],
(...)
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用。如果 mixins 变量不止一个,我该如何正确设置它?

一旦我将新的 mixin 添加到变量中,第一个就不再被识别。

javascript vue.js

4
推荐指数
1
解决办法
5703
查看次数

Laravel 502 Bad Gateway错误

我将Laravel 5.3与最新的Homestead安装程序一起使用。向API发出POST请求时,根据日志文件出现此错误:

2016/10/29 12:44:34 [错误] 776#0:* 28 recv()失败(104:对等连接重置),同时从上游读取响应标头,客户端:192.168.10.1,服务器:loc.medifaktor,请求:“ POST / api / v1 / mfusers HTTP / 1.1”,上游:“ fastcgi:// unix:/var/run/php5-fpm.sock$

我使用POSTMAN发出POST请求,将其发送到URL: http://loc.medifaktor/api/v1/mfusers

这是一个家庭安装,可以在我的计算机上本地运行。

此错误中提到的客户端地址是192.168.10.1,实际上不正确,因为我使用的是192.168.10.10。这可能是错误,我该如何解决?

[![在此处输入图片描述] [1]] [1]

我正在使用全新安装的Laravel,并且尝试了其他类似GET的请求,这些请求都可以正常工作。仅POST请求会引发此错误。

php-fpm.log显示:

[29-Oct-2016 13:47:15] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful
Run Code Online (Sandbox Code Playgroud)

这是nginx配置的输出:

server {
    listen 80;
    listen 443 ssl;
    server_name loc.medifaktor;
    root "/home/vagrant/Development/Source/MFServer/public";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found …
Run Code Online (Sandbox Code Playgroud)

php laravel

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

如何使用Carbon从"created_at"中提取时间

我仍在努力解决Laravel框架内的碳功能问题.我创建了我的模型中使用的这些函数来提取表格中"created_at"字段的日期:

public function getCreatedAtAttribute($date) {
    return Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('d.m.Y');
}
Run Code Online (Sandbox Code Playgroud)

这适用于日期,但是我如何在此模型中编写一个函数,它只会在created_at字段中提取时间?

php laravel php-carbon

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

VueJS 事件处理

我正在使用 VueJS 测试发射和监听方法以了解如何使用它。我得到了一些奇怪的结果,我不明白。我希望我的函数 initMap() 被调用并且控制台正在记录日志,它确实如此,但错误出现在顶部。

Uncaught TypeError: Cannot read property 'apply' of undefined
    at Vue$3.Vue.$emit (vue.js:2186)
    at Vue$3.emit (main.js:131)
    at Vue$3.boundFn [as emit] (vue.js:167)
    at Vue$3.fire (main.js:146)
    at Vue$3.boundFn [as fire] (vue.js:167)
    at Vue$3.initMap (main.js:93)
    at Vue$3.boundFn [as initMap] (vue.js:168)
    at js?key=AIzaSyBWZxmn3CYyhAT2vnv9tOBgQSGzrSBzCsM&libraries=places,geometry&callback=App.initMap:98
    at js?key=AIzaSyBWZxmn3CYyhAT2vnv9tOBgQSGzrSBzCsM&libraries=places,geometry&callback=App.initMap:56
    at js?key=AIzaSyBWZxmn3CYyhAT2vnv9tOBgQSGzrSBzCsM&libraries=places,geometry&callback=App.initMap:53
Vue.$emit @ vue.js:2186
emit @ main.js:131
boundFn @ vue.js:167
fire @ main.js:146
boundFn @ vue.js:167
initMap @ main.js:93
boundFn @ vue.js:168
(anonymous) @ js?key=AIzaSyBWZxmn3CYyhAT2vnv9tOBgQSGzrSBzCsM&libraries=places,geometry&callback=App.initMap:98
(anonymous) @ js?key=AIzaSyBWZxmn3CYyhAT2vnv9tOBgQSGzrSBzCsM&libraries=places,geometry&callback=App.initMap:56
(anonymous) @ js?key=AIzaSyBWZxmn3CYyhAT2vnv9tOBgQSGzrSBzCsM&libraries=places,geometry&callback=App.initMap:53
(anonymous) @ js?key=AIzaSyBWZxmn3CYyhAT2vnv9tOBgQSGzrSBzCsM&libraries=places,geometry&callback=App.initMap:56
(anonymous) …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js

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

Laravel中数组到字符串的转换错误

我想在Laravel中使用Queue将消息推送到Queue。因此,我想先尝试基本流程,此刻会引发错误。

在Laravel中使用CommandBus时,我创建了一个侦听器:

侦听器-IncidentNotifier.php

<?php

namespace App\Listeners;


use App\Events\Incident\IncidentWasPosted;
use App\Events\EventListener;
use App\Http\Traits\SearchResponder;
use App\Jobs\SendAlarmToResponder;
use Illuminate\Foundation\Bus\DispatchesJobs;

class IncidentNotifier extends EventListener {

    use DispatchesJobs, SearchResponder;

    public function whenIncidentWasPosted(IncidentWasPosted $event) {
        $responders = $this->getResponderInRange($event);
        $this->dispatch(new SendAlarmToResponder($responders));
    }
}
Run Code Online (Sandbox Code Playgroud)

该侦听器应将作业(尚未完成)排队以使用推送通知服务,因为这将在当前不使用Queue的情况下阻塞我的系统。

职位-SendToAlarmResponder.php

<?php

namespace App\Jobs;

use App\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendAlarmToResponder extends Job implements SelfHandling, ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    protected $responders = array();

    public function __construct($responders)
    {
        $this->$responders = $responders;
    }

    public function handle($responders)
    {
        var_dump($responders);
    } …
Run Code Online (Sandbox Code Playgroud)

php queue laravel

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

VueJS 访问 JSON 数据

我正在通过希望显示在列表中的 API 访问数据。我现在正在测试 VueJS,但无法正确显示它。

数据是:

{

  "data": [
    {
      "userReference": "R100",
      "responderStatus": 0,
      "location": {
        "latitude": 100,
        "longitude": 100,
        "distance": null
      },
      "featureTypeId": 1
    }
  ],
  "pagination": {
    "total": 1,
    "perPage": 10,
    "lastPage": 1,
    "nextPageUrl": null,
    "prevPageUrl": null,
    "from": 1,
    "to": 1,
    "totalPages": 1,
    "currentPage": 1,
    "hasMorePages": false
  }
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<div class="wrapper wrapper-content animated fadeInRight">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="text-center m-t-lg">
                            <h1>MEDIFAKTOR server</h1>
                        </div>

                        <div id="app">
                            <ul class="list-group">
                                <li v-for="responder in responders">@{{ responder[0] }}</li>
                            </ul>
                        </div>
                    </div>
                </div> …
Run Code Online (Sandbox Code Playgroud)

json laravel vue.js vuejs2

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

标题标记显示在正文中

我编写了以下基本HTML代码,包括bootstrap 3.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0"
        <title>Title</title>

        <!-- Bootstrap Core CSS -->
        <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">

        <!-- Custom Style for this page -->
        <link href="css/custom.css" rel="stylesheet">
    </head>

    <body>
        <div id="site-wrapper">
            <!-- Navigation -->
            <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <a class="navbar-brand" href="index.php">MEDIFAKTOR server</a>
                </div> <!-- Navbar Header -->
            </nav>
        </div> <!-- Site Wrapper -->
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

但无论我改变什么,标题也会显示在文档的正文中.我检查了丢失的标签.我还想念别的吗?

html twitter-bootstrap-3

0
推荐指数
1
解决办法
127
查看次数

VueJS Mixins方法

我想在我的VUEJS模块中使用mixin:

<script>
    var GoogleMaps = require('../mixins/GoogleMaps');

    export default {
        mixins: [GoogleMaps],
        events: {
            MapsApiLoaded: function(data) {
                GoogleMaps.initGISMap(data);
            }
        },
}
</script>
Run Code Online (Sandbox Code Playgroud)

混入

export default {
    methods: {
        initGISMap(selector) {
            map = new google.maps.Map(selector, {
                zoom: 10,
                mapTypeId: google.maps.MapTypeId.ROADMAP,
            });

            // Set initial Location and center map to this location
            initialLocation = new google.maps.LatLng(48.184845, 11.252553);
            map.setCenter(initialLocation);

            // Create a searchmarker
            searchMarker = createMarker();

            // Init Autocomplete for GIS
            initAutoComplete();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误,GoogleMaps.initGISMap不是一个函数.如何在组件中使用mixin方法?

javascript vue.js

0
推荐指数
1
解决办法
1927
查看次数

在Laravel中更改用户类的路径

我将laravel安装中的User.php移到了另一个文件夹,并相应地调整了名称空间。但是,当我登录页面时,laravel无法找到该类并引发错误。

在此处输入图片说明

我跑了composer clear-cashcomposer dump-autoload但仍然不能正常工作,因为Laravel仍在搜寻App/User.php而不是App/Classes/User/User.php

User.php看起来像这样:

namespace App\Classes\User;

use App\Events\EventGenerator;
use App\Events\User\UserRegistered;

use App\Permission;
use App\Role;
use Laratrust\Traits\LaratrustUserTrait;

use \Illuminate\Contracts\Auth\Authenticatable as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Console\Command;


class User extends Model implements Authenticatable {
    use EventGenerator;
    (...)
Run Code Online (Sandbox Code Playgroud)

php laravel

0
推荐指数
1
解决办法
781
查看次数