在CentOS 7上,我安装了PHP 7.1.
然后我安装了作曲家:
cd /tmp
curl -sS https://getcomposer.org/installer | php71 --> used php71 instead of php, php didn't work
mv composer.phar /usr/local/bin/composer
Run Code Online (Sandbox Code Playgroud)
然后,在使用时composer,我得到:
/usr/bin/env: php: No such file or directory
Run Code Online (Sandbox Code Playgroud)
使用时sudo composer,我得到:
sudo: composer: command not found
Run Code Online (Sandbox Code Playgroud) 一切都很好.有些git推,没有问题.
今天我决定将我的框架更新到最新版本,所以它稍微改变了我项目的目录结构.所以在bitbucket中,我创建了一个新的存储库(dev1.project.com),并将我的项目文件夹从OldName重命名为dev1.project.com
我编辑.git/config指向我的新存储库:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[branch "master"]
[remote "origin"]
url = https://bitbucket.org/user/dev1.project.com.git
fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
当我做 git remote -v
我得到:origin ssh://git@bitbucket.org/user/dev1.project.com.git(fetch)origin ssh://git@bitbucket.org/user/dev1.project.com.git(push)
我回到我的项目文件夹,然后输入:
git init
git add .
git commit -m 'my first commit'
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
但我一直收到以下错误:
ssh: connect to host bitbucket.org port 22: Connection timed out
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)
该命令为ssh -T git@bitbucket.org我提供了与上面相同的消息.
命令:git config --get remote.origin.url …
在Laravel(我使用的是5.1版)中,在数据透视表(多对多关系)中有一个id列是否有任何优点?
带有身份证
$table->increments('id');
$table->integer('appointment_id')->unsigned();
$table->foreign('appointment_id')->references('id')->on('appointments')->onDelete('cascade');
$table->integer('client_id')->unsigned();
$table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
$table->timestamps();
Run Code Online (Sandbox Code Playgroud)
没有身份证
$table->integer('appointment_id')->unsigned();
$table->foreign('appointment_id')->references('id')->on('appointments')->onDelete('cascade');
$table->integer('client_id')->unsigned();
$table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
$table->timestamps();
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用我的Angularjs前端进行Laravel API交换日期.
它通过首先转换我的mysql datetime初始值从Laravel到JS工作:
2015-08-19 10:00:00
Run Code Online (Sandbox Code Playgroud)
使用$newdate = Carbon::parse($event['date'])->toATOMString();哪些输出:
2015-08-19T10:00:00+00:00
Run Code Online (Sandbox Code Playgroud)
,然后将其转换为javascript日期对象(Angularjs),使用event.date = new Date(event.date);哪些输出:
Date 2015-08-19T10:00:00.000Z
Run Code Online (Sandbox Code Playgroud)
问题:将更新的Javascript日期对象发布回我的PHP API以更新mysql db(datetime)中的值.Carbon不喜欢他回来的日期格式:
2015-08-19T11:00:00.000Z
Run Code Online (Sandbox Code Playgroud)
我不知道如何处理这个问题.我从Laravel日志中收到以下错误:exception 'InvalidArgumentException' with message 'Trailing data' … Carbon/Carbon.php:392
问题:如何在php中转换上述格式化日期,以便Carbon接受它?
我不需要记录秒数,因此我的Laravel模型处理日期如下:
$this->attributes['date'] = Carbon::createFromFormat('Y-m-d H:i', $date);
Run Code Online (Sandbox Code Playgroud)
到目前为止,这是我尝试过的(没有成功).我显然错过了一些东西而不确定我在做什么.
/**
* Store updates to event.
*
* @return Response
*/
public function update($id)
{
$event = Event::findOrFail($id);
$date = Request::get('jsdateobject');
// ------------------------------------------------------------
// trying to handle following format: 2015-08-19T11:00:00.000Z
// ------------------------------------------------------------
// $date = …Run Code Online (Sandbox Code Playgroud) 我已经在我的Laravel 5项目中安装了bootstrap-calendar(使用bower).Bootstrap-calendar已安装到我的laravel/vendor/bootstrap-calendar /文件夹中.
要使用bootstrap-calendar,我需要在我的视图中引用CSS/JS文件,来自:
laravel/vendor/bootstrap-calendar/css
laravel/vendor/bootstrap-calendar/js
Run Code Online (Sandbox Code Playgroud)
是否有一种简单而干净的方式在我的项目中使用这些文件而无需将它们复制到公用文件夹?
使用ui.bootstrap.typeahead,我从我的json列表中选择一个产品(通过输入'P').我的目标是自动设置总价.但我无法显示所选产品的价格(value="{{selected.price}}"),因此它可以计算总数.不知道我做错了什么.
Plunker:http://plnkr.co/edit/F9jPt7IZgsWyON2vEmic
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-animate.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.13.3/ui-bootstrap-tpls.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<script src="script.js"></script>
<script>
angular.module("app", ["ui.bootstrap.productautocomplete"]);
</script>
</head>
<body>
<div class="container" ng-app="app">
<div ng-controller="ProductAutocompleteCtrl">
<div class="col-sm-4">
<input id="product_info" name="product_info" ng-change="displayPrice()" type="text" placeholder="Autocomplete - Type 'P' to find product's name" ng-model="selected" typeahead="product as product.name for product in products | filter:$viewValue | limitTo:8" class="form-control"
autocomplete="off">
</div>
<div class="col-sm-2">
<input id="price" name="price" ng-model="prc" ng-validate="number" placeholder="Autocomplete - Price" type="text" class="form-control" value="{{selected.price}}">
</div>
<div …Run Code Online (Sandbox Code Playgroud) 我想定义一个可以被多个控制器和命令使用的“全局”方法。它应该放在Laravel 5.4中的什么位置?
假设我有以下控制器。我将如何称呼“全局”方法,以及“全局”方法的确切位置在哪里?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Flight;
class FlightsController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Index
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$flights = Flight::where('active', 1)
->orderBy('name', 'desc')
->take(10)
->get();
foreach ($flights as $flight) {
if ( $flight->price == 0 )
{
$output = "some value";
}
else
{
$output = "some other value";
}
}
return …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用withTrashed()进行急切加载.我在我的模型中创建了一个新的_withtrashed函数,但查询返回时我的客户端为NULL
客户端型号:
// Client
public function client()
{
return $this->belongsTo('App\Client');
}
// Client (withtrashed for soft deletes)
public function client_withtrashed()
{
return $this->belongsTo('App\Client')->withTrashed();
}
Run Code Online (Sandbox Code Playgroud)
订单管理员:
/**
* Show order.
*/
public function show($id)
{
$order = Order::with('client_withtrashed') ---> it works normally with: Order::with('client') , except I don't get the soft deleted rows
->where('id', '=', $id)
->firstOrFail();
Run Code Online (Sandbox Code Playgroud)
DD($顺序); 显示一个空客户端
#relations: array:1 [
"client_withtrashed" => null
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我决定使用上面的解决方案因为我无法使用toTrashed()来处理我的急切查询 $order = Order::with('client_withtrashed')->withTrashed()
使用 Eloquent,试图找到一种方法来获取按以下方式分组的每一行的最新行:exchange、base、quote
数据
exchange base quote price value created_at
bittrex BTC USD 10000 10000 2018-01-05
bittrex BTC USD 9000 9000 2018-01-01
poloniex BTC USD 10001 10001 2018-01-05
poloniex BTC USD 9000 9000 2018-01-01
binance BTC USD 10002 10002 2018-01-05
binance BTC USD 9000 9000 2018-01-01
binance ETH USD 800 800 2018-01-05
binance ETH USD 700 700 2018-01-01
Run Code Online (Sandbox Code Playgroud)
结果:
bittrex BTC USD 10000 10000 2018-01-05
poloniex BTC USD 10001 10001 2018-01-05
binance BTC USD 10002 10002 2018-01-05
binance ETH USD 800 …Run Code Online (Sandbox Code Playgroud) laravel ×6
laravel-5 ×6
eloquent ×2
laravel-4 ×2
php ×2
angularjs ×1
bitbucket ×1
centos ×1
centos7 ×1
composer-php ×1
datetime ×1
git ×1
iptables ×1
javascript ×1
laravel-5.4 ×1
php-carbon ×1
plunker ×1
ssh ×1