所以,我从Laravel收到以下错误:
SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'participants' (SQL: select `participants`.*, `participants`.`message_id` as `pivot_message_id`, `participants`.`user_id` as `pivot_user_id`, `participants`.`created_at` as `pivot_created_at`, `participants`.`updated_at` as `pivot_updated_at` from `participants` inner join `participants` on `participants`.`id` = `participants`.`user_id` where `participants`.`deleted_at` is null and `participants`.`message_id` in (2))
Run Code Online (Sandbox Code Playgroud)
我的留言/参与者关系如下:
public function participants()
{
return $this->belongsToMany('Namespace\Modules\Email\Models\Participant', 'participants', 'message_id', 'user_id')->withTimestamps();
}
Run Code Online (Sandbox Code Playgroud)
而我试图这样称呼它:
public function getAllMessages()
{
return Message::with('user')->with('participants')->get();
}
Run Code Online (Sandbox Code Playgroud)
为什么我收到此错误?到底是怎么回事?
编辑:包含完整模型
消息 类消息扩展Eloquent {使用PublishedTrait; 使用SoftDeletingTrait;
class Message extends Eloquent
{
use PublishedTrait;
use SoftDeletingTrait;
/**
* …Run Code Online (Sandbox Code Playgroud) 所以我有2个模型,User & Profile,关系设置如下:
/**
* User belongs to many Profile
*
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
*/
public function profiles()
{
return $this->belongsToMany('App\Models\Profile', 'user_profiles');
}
Run Code Online (Sandbox Code Playgroud)
我有 3 个表、用户、配置文件和 user_profiles(数据透视表)
我的用户表中有一个名为的列,active_profile其中填充了配置文件 ID。
我如何建立关系,以便我可以调用以下内容:
$user->active_profile
以便它将返回active_profile中设置的id的所有配置文件信息?
我需要一个Spherical Panorama查看器来放入一个Webb应用程序,最好是HTML5或jQuery.用户必须能够使用手指在Panorama周围移动.
是否有人知道这样的任何可用的东西,只需少量费用或免费更好?
我正在尝试为我的users表创建一个新的迁移,我有以下架构:
Schema::create('users', function($t) {
$t->increments('id');
$t->string('username', 16);
$t->string('password', 64);
$t->integer('role', 64);
$t->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
当我尝试从终端运行php artisan migrate时,我收到以下错误:
[例外]
SQLSTATE [42000]:语法错误或访问冲突:1075表定义不正确; 只能有一个自动列,必须将其定义为键(SQL:create tableusers(idint unsigne d not null auto_increment primary key,usernamevarchar(16)not null,passwordvarchar(64)no t null,roleint not null auto_increment primary key,created_attimestamp default 0 not null,updated_attimestamp default 0 not null))(Bindings:array(
))
该错误与"角色"字段有关,因为当删除它时,它似乎运行正常.
在此先感谢任何帮助或见解.
我正在使用@ngrx/entity,这会创建一个如下所示的状态:
{
ids: [1, 2, 3],
entities: [
1: {id:1, title: "Some title", likes: {count: 1}},
2: {id:2, title: "Some title", likes: {count: 1}},
3: {id:3, title: "Some title", likes: {count: 1}}
]
}
Run Code Online (Sandbox Code Playgroud)
@ngrx/entity 确实为我们提供了一些更新项目的酷帮手,但似乎(从我在文档中看到的)仅限于更新整个实体。
但是,当用户切换“喜欢”按钮时,我希望在我的减速器中仅state.entities[2].likes使用响应更新该属性。
关于如何解决这个问题的任何想法?
在我的角度项目中,用户接受EULA,然后自动重定向到他们的仪表板,但是,在此重定向上,DashboardController似乎被调用了两次,DashboardController正在路由本身被调用,我已经检查过我是否有意外在模板中再次调用它,但我没有.以下是我的路线和控制器.如果我直接或通过EULA控制器上的重定向访问URL似乎没有关系,我得到相同的结果.
路线
.config(function($httpProvider, $stateProvider, $urlRouterProvider) {
$httpProvider.interceptors.push('httpRequestInterceptor');
$urlRouterProvider.otherwise('/');
$stateProvider
.state('login', {
url: '/',
templateUrl: 'templates/login.html',
data: {
requireLogin: false
}
})
.state('eula', {
url: '/eula',
templateUrl: 'templates/eula.html',
data: {
requireLogin: true
}
})
.state('dashboard', {
url: '/groups',
templateUrl: 'templates/dashboard.html',
data: {
requireLogin: true
}
})
});
Run Code Online (Sandbox Code Playgroud)
控制器:
App.controller('DashboardController', ['$scope', 'RequestService', '$state', '$rootScope', function($scope, RequestService, $state, $rootScope){
alert('test');
}]);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
根据评论添加我的HTML
的index.html
<body ng-app="App">
<ion-nav-bar class="bar-positive nav-title-slide-ios7" align-title="center">
<ion-nav-back-button class="button-icon ion-arrow-left-c"></ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view class="slide-left-right"></ion-nav-view>
<ui-view></ui-view>
</body>
Run Code Online (Sandbox Code Playgroud)
dashboard.html
<div class="groups" ng-controller="DashboardController">
<ion-view …Run Code Online (Sandbox Code Playgroud) javascript angularjs angularjs-routing angularjs-controller ionic-framework
我收到以下错误:
Call to undefined method Laravel\Socialite\One\TwitterProvider::stateless()
Run Code Online (Sandbox Code Playgroud)
抛出此错误的行是:
$userData = Socialite::driver($provider)->stateless()->user();
Run Code Online (Sandbox Code Playgroud)
以上适用于Facebook登录.
有任何想法吗?
我目前有以下代码,在单击缩略图时替换大图像:
使用Javascript:
img1 = new Image();
img1.src = '{$smarty.const.dir_images}/l_{$this_page.image1}';
img2 = new Image();
img2.src = '{$smarty.const.dir_images}/l_{$this_page.image2}';
Run Code Online (Sandbox Code Playgroud)
缩略图HTML:
<a href="javascript:document['mainimage'].src = img1.src; javascript:void(0);"><img src="{$smarty.const.dir_images}/t_{$this_page.image1}" title="" alt=""/></a>
<a href="javascript:document['mainimage'].src = img2.src; javascript:void(0);"><img src="{$smarty.const.dir_images}/t_{$this_page.image2}" title="" alt=""/></a>
Run Code Online (Sandbox Code Playgroud)
大图像HTML:
<img id="mainimage" name="mainimage" src="{$smarty.const.dir_images}/l_{$this_page.image1}" title="{$this_page.image1text}" alt="{$this_page.image1text}" />
Run Code Online (Sandbox Code Playgroud)
我想要做的不仅是在点击缩略图时更改大图像源,还要更改alt和标题标签.
提前致谢
好的,所以我用我的PHP脚本构建了这个查询:
SELECT *
FROM sale_properties
WHERE advert_heading LIKE '%harnham%'
OR main_advert LIKE '%harnham%'
OR advert2 LIKE '%harnham%'
OR advert3 LIKE '%harnham%'
OR street LIKE '%harnham%'
OR district LIKE '%harnham%'
OR town LIKE '%harnham%'
OR county LIKE '%harnham%'
OR area LIKE '%harnham%'
OR postcode LIKE '%harnham%'
AND numeric_price >= 150000.00
AND numeric_price <= 152000.00
Run Code Online (Sandbox Code Playgroud)
现在,这确实给了我一些结果,但是,我希望基本上在数据库中搜索关键字并在价格范围内。上面的查询确实为我提供了关键字,但似乎忽略了大部分价格范围。
这看起来正确吗?还是可以更好地建造?
运行以下查询时,我得到非常奇怪的结果:
select * from "statuses" where "created_at" > '2015-04-26 02:04:24';
Run Code Online (Sandbox Code Playgroud)
这似乎返回以下日期:
2015-04-26 10:44:04
2015-04-26 12:19:47
2015-04-26 12:20:12
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,这些实际上低于我输入的指定日期/时间。我认为这与日期的格式有关?
我的查询应该如何才能获得准确的结果?
这里总共有一个Redux noob,我在将数据从商店中取出以便在我的视图中使用时遇到了一些困难.这是我的行动,减速器等.
genre.model.ts
export interface Genre {
id: string;
title: string;
description: string;
slug: string;
error: string;
}
export const initialState: Genre = {
id: '',
title: '',
description: '',
slug: '',
error: null
};
Run Code Online (Sandbox Code Playgroud)
genre.service.ts
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Http } from '@angular/http';
import {environment} from "../../../environments/environment";
import {Genre} from "./genre.model";
@Injectable()
export class GenreService {
apiUrl = environment.apiUrl + environment.apiVersion + '/';
constructor(private http: Http) { }
/** …Run Code Online (Sandbox Code Playgroud) laravel ×4
php ×4
mysql ×3
angular ×2
eloquent ×2
javascript ×2
ngrx ×2
ngrx-store ×2
relationship ×2
angularjs ×1
datetime ×1
html ×1
html5 ×1
image ×1
jquery ×1
laravel-4 ×1
laravel-5.2 ×1
ngrx-effects ×1
ngrx-entity ×1
sql ×1