我正在使用AngularJS来构建与传统Flex应用程序交互的HTML控件.Flex应用程序中的所有回调都必须附加到DOM窗口.
例如(在AS3中)
ExternalInterface.call("save", data);
Run Code Online (Sandbox Code Playgroud)
将会通知
window.save = function(data){
// want to update a service
// or dispatch an event here...
}
Run Code Online (Sandbox Code Playgroud)
在JS resize函数中,我想发送一个控制器可以听到的事件.似乎创建服务是最佳选择.你能从AngularJS外部更新服务吗?控制器可以监听服务中的事件吗?在一个实验(点击小提琴)我做了似乎我可以访问服务,但更新服务的数据不会反映在视图中(在示例中<option>应该添加到<select>).
谢谢!
我需要找到某个特定客户之前曾与该商店做过生意。
为了实现这一目标,我需要找到给定客户的订单数量。
我怎样才能做到这一点?
我尝试谷歌搜索,但没有找到任何解决方案。
我Newtonsoft.Json在我的项目中使用.我JObject喜欢这个:
{
"4781":"Name 1",
"1577":"Name 2",
"9973":"Name 3"
}
Run Code Online (Sandbox Code Playgroud)
我成功解析了它JObject.Parse().我需要从这个JObject("4781")获得第一个密钥.我怎么得到它?
我用passport包的时候遇到这个错误
在 null 上调用成员函数 createToken()
为什么我会收到这个错误?
这是我的代码:
$users = Users::where('Email' , $username)
->where( 'Password' , $password)
->where('UserStatus' , config('global.active'))
->first();
if($users) {
$success['token'] = $users->createToken('MyApp')->accessToken;
return response()->json(['success' => $success], $this->successStatus);
} else {
return response()->json(['error'=>'Unauthorised'], 401);
}
Run Code Online (Sandbox Code Playgroud) 我一直在为我的项目使用查询生成器,并想使用查询生成器恢复软删除的记录。
根据https://laravel.com/docs/5.6/eloquent-serialization,可以setAppends在模型实例上使用以动态地向模型添加任何可用的额外属性。但是,除了遍历集合之外,我还没有找到对模型集合执行此操作的方法。
有没有更聪明的方法来做到这一点?像这样:
$facilities = Facility:all();
$facilities->setAppends();
Run Code Online (Sandbox Code Playgroud)
目前唯一的选择是:
foreach ($facilities as $facility) {
$facility->setAppends([
'your_attribute_here'
]);
}
Run Code Online (Sandbox Code Playgroud)
编辑:澄清一下,我想在运行时动态地做到这一点。我定义的额外属性在获取模型的任何地方都不需要,并且可能会导致大量额外开销。
我是PHP / Laravel的新手。
我的模型扩展了默认的Model类。
class LobModel extends Model
class AlarmActions extends LobModel
Run Code Online (Sandbox Code Playgroud)
当我尝试更新AlarmActions表中的一行时;我越来越
SQLSTATE[42S22]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Invalid column name 'updated_at'. (SQL: update [AlarmActions] set [AlarmActionDescription] = sdsf, [UTCDateTimeUpdated] = 2017-08-11 00:42:05.000, [updated_at] = 2017-08-11 00:42:05.000 where [AlarmActionId] = 19621)
Run Code Online (Sandbox Code Playgroud)
updated_at我的AlarmActions表中没有定义列。
但是我看到,在默认的Model类中,定义了以下列。如何跳过这两列?
const UPDATED_AT = 'updated_at';
const CREATED_AT = 'created_at';
Run Code Online (Sandbox Code Playgroud)
我正在调用save更新行的方法。
$alarmAction->save();
Run Code Online (Sandbox Code Playgroud) 我DateTime在数据库中有一个对象mysql,例如包含此datetime "2017-08-14 18:06:40"对象,server/mysql默认时区是美国,因此当我插入它时,datetime它会进入美国时区。
我的问题是,当来自欧洲的用户选择该日期时间时,由于时间差异,它会有所不同,不是吗?
我该如何解决这个问题。我希望欧洲的用户获得相对于他们的时区的日期时间
我通过搜索发现
CONVERT_TZ(`comment_date`,@@global.time_zone,@@session.time_zone) AS comment_date,
Run Code Online (Sandbox Code Playgroud)
然后我发现需要设置@@session.time_zone不自动检测
那么我们如何解决这个问题?有哪些选项和技术apps可以用于datetime跨国家统一?
我有一个有2个功能的模型.让我们说模型的名字是Cars.我试图调用一个brand返回数组的函数,以便我可以在其他getBrand函数中使用它.
public static function getBrand($data) {
$brandVariable = $this->brand();
for ($i=1; $i < count($brandVariable ) ; $i++) {
//do something
}
}
public static function brand() {
$arrayValues = array(
1 => 'Brand A',
2 => 'Brand B',
);
return arrayValues;
}
Run Code Online (Sandbox Code Playgroud)
由于值是在brand函数中,我需要将其传递到内部getBrand.
我在for循环中遇到错误.我尝试了另一个文件(本地PHP而不是Laravel),它运行正常.但在Laravel,它没有得到预期的结果.
以下是我直接在路线中致电我的控制器的路线。
如何传递Request $request给我的getBlog函数。或者有什么方法可以直接$request在getblog控制器的函数中获取对象?
$artObj = App::make('App\Http\Controllers\Front\ArticleController');
return $artObj->getBlog($id);
Run Code Online (Sandbox Code Playgroud)
路线代码:
Route::get('/{slug}', function($slug) {
// Get Id and Type depending on url
$resultarray = App\Model\UrlAlias::getTypefromUrl($slug);
if(!empty($resultarray)) {
if($resultarray[0]['type'] == 'article') {
$id = $resultarray[0]['ref_id'] ;
$artObj = App::make('App\Http\Controllers\Front\ArticleController');
return $artObj->getBlog($id);
} else {
return Response::view("errors.404", $msg, 400);
}
} else {
return Response::view("errors.404", array(), 400);
}
});
Run Code Online (Sandbox Code Playgroud) 我使用的是 Laravel 5.5,我需要动态更改数据库,
例如,有两个数据库,db1每个数据库中db2有一个表articles。
现在我想将文章从 复制db1到db2,
在.env文件中,当前数据库是db1:
DB_DATABASE=db1
Run Code Online (Sandbox Code Playgroud)
我想在复制记录时动态更改它,我尝试这样做:
public function test()
{
$articles=Article::all();
Config::set("database.connections.mysql", [
"host" => "127.0.0.1",
"database" => "db2",
"username" => "root",
"password" => ""
]);
//DB::purge('mysql'); //this line exists or not,it has the same error.
DB::table('articles')->insert($articles);
dd('ok');
}
Run Code Online (Sandbox Code Playgroud)
但有一个错误:
未定义索引:驱动程序
我有很多数据库,所以我不想在.env文件中更改它。
我应该怎么办?
更新:
其中config/database.php有两项:
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' …Run Code Online (Sandbox Code Playgroud) 我正在尝试更新数据透视表中的现有记录,以便与 laravel 建立多对多的关系。
我有商店功能可以工作:
public function store(Request $request)
{
$produk = new product($request->input()) ;
$feat = (boolean)$request->input('featured');
$input = $request->all();
$input['featured'] = $feat;
$inputproduk = product::create($input);
$inputproduk->categories()->attach($request->input('kat_id'));
return redirect()->back()->with('message', 'Memasukkan Data Produk Berhasil');
}
Run Code Online (Sandbox Code Playgroud)
但是为什么我的更新功能不起作用???
public function update(Request $request, $id)
{
$produk = Product::FindorFail($id);
$produk = new product($request->input()) ;
$input = $request->except('_method', '_token', 'picture', 'kat_id');
$inputproduk = product::whereId($id)->update($input);
$inputproduk->categories()->sync($request->input('kat_id'));
return redirect()->back()->with('message', 'Mengedit Data Produk Berhasil');
}
Run Code Online (Sandbox Code Playgroud)
错误是:
在整数上调用成员函数 category()
那什么意识?请帮我。
看法 :
<div class="form-group">
<label for="KategoriProduk">Kategori Produk</label>
<select class="form-control" name="kat_id[]" …Run Code Online (Sandbox Code Playgroud) 我写了一个Laravel查询.我使用whereBetween,并orWhereBetween伴随着一个where名为"共享"列上声明,应返回一行.
但是这个查询没有考虑where条件.它只花了whereBetween和orWhereBetween.可能是什么原因.
我的查询
$childs = Program::whereIn('id', $programs_by_date)
->where('shareable', '=','1')
->wherebetween('starting_date', [$new_start_date,$new_end_date])
->orwherebetween('ending_date', [$new_start_date,$new_end_date])
->orderBy('starting_date')
->get();
Run Code Online (Sandbox Code Playgroud)
->where('shareable', '=','1')返回0行.可能是什么原因.
shareable 类型是枚举
laravel ×7
php ×6
laravel-5 ×5
mysql ×3
eloquent ×2
angularjs ×1
javascript ×1
json.net ×1
laravel-4 ×1
many-to-many ×1
request ×1
timezone ×1
woocommerce ×1
wordpress ×1
wpf ×1