嗨,我正在学习laravel.我使用Eloquent ORM删除方法但我得到了不同的结果.不是true或false但是null.我设置了一个资源路由,在UsersController中有一个destroy方法.
public function destroy($id){
$res=User::find($id)->delete();
if ($res){
$data=[
'status'=>'1',
'msg'=>'success'
];
}else{
$data=[
'status'=>'0',
'msg'=>'fail'
];
return response()->json($data);
Run Code Online (Sandbox Code Playgroud)
但我总是得到一个响应{"status":"0","msg":"failed"},删除数据库中的记录.
然后我使用dd($ res).它在页面中显示为null.
但是从我学习的课程中它返回一个布尔值true或false.
我的代码中有错误吗?
你能告诉我一些其他方法,当我从数据库中删除数据时,我可以得到一个布尔结果吗?
我在OSX MAMP Pro中使用laravel / horizon
当我运行作曲家要求 laravel/horizon:~1.0
它说 -
laravel / horizon v1.0.8需要ext-pcntl *->您的系统中缺少所请求的PHP扩展pcntl。
我检查/Applications/MAMP/bin/php7.1.1/php/ext文件夹,它没有pcntl扩展名。
我该如何安装?
我现在正在学习 Laravel。我做了一个博客演示,它在我的 mac 上与 MAMP 配合得很好。
但是当我将它部署在我的远程服务器上时,它现在可以工作了!除了 500 错误之外我什么也得不到!
我搜索了很多次问题,我重新安装了我的 vps 并获得了一个新的 Laravel 项目,但问题仍然存在。
真的很郁闷!我将提供我的代码和我的配置。顺便说一句,这是使用 composer 而不是我的博客演示操作系统的全新初始 laravel 项目安装的结果:centos 6 x64 with php,mysql,nginx 这里是我解决问题的尝试,我将提供图片,但会导致声誉不佳img 不显示
如您所见,我 chmod & chown 文件和存储以及引导目录:

chmod -R 775 存储
chown -R www:www
drwxrwxr-x 5 www www 4096 May 11 20:42 storage
Run Code Online (Sandbox Code Playgroud)
我将位置添加到 nginx 配置:

location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)
fastcgi_pass 是对的
我已经运行了那里的命令 …