我有3张桌子,汽车,公寓和商店.每张桌子都有照片.照片存储在数据库中.我想只使用一张桌子拍照,我不想为每辆汽车,公寓和商店创建照片表.
照片表结构是这样的;
| id | photo_url | type | destination_id |
------------------------------------------------------------
1 | http://example.com/1.jpg | Cars | 1 |
2 | http://example.com/2.jpg | Flats | 1 |
3 | http://example.com/3.jpg | Flats | 2 |
4 | http://example.com/4.jpg | Shops | 1 |
5 | http://example.com/3.jpg | Shops | 2 |
Run Code Online (Sandbox Code Playgroud)
我需要在Shops,Flats和Cars模型类中定义hasMany与类型的关系.
这样做的正确方法是什么?
我想在我的应用程序中添加语音搜索功能.我正在SherlockActivity中填充SearchView.但我找不到为SearchView对象添加语音搜索功能的解决方案.
你能提出建议吗,我需要做什么?
代码如下:
public class MainActivity extends SherlockActivity {
private SlidingMenu slidingMenu;
private SlidingMenu slidingMenuRight;
private String mFilterArrays[];
public long lastScrollTime=0; /** En son kayd?rma ne zaman yap?ld?*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public boolean onCreateOptionsMenu(Menu menu) {
//Create the search view
SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
searchView.setQueryHint("Search...");
menu.add("Search")
.setIcon(R.drawable.ic_search_inverse)
.setActionView(searchView)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
Mainfest
<activity
android:name="com.paea.bcp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.paea.bcp.MainActivity" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud) 我Sensor.TYPE_ORIENTATION用来确定设备的当前角度,但TYPE_ORIENTATION在API版本8上已弃用.在SensorManager手册中,它指的是使用getOrientation()功能TYPE_ORIENTATION.
这是我的旧代码:
public void onSensorChanged(SensorEvent event) {
Log.d("debug","Sensor Changed");
if (event.sensor.getType()==Sensor.TYPE_ORIENTATION) {
Log.d("debug",Float.toString(event.values[0]));
float mAzimuth = event.values[0];
float mPitch = event.values[1];
float mRoll = event.values[2];
Log.d("debug","mAzimuth :"+Float.toString(mAzimuth));
Log.d("debug","mPitch :"+Float.toString(mPitch));
Log.d("debug","mRoll :"+Float.toString(mRoll));
}
}
Run Code Online (Sandbox Code Playgroud)
我对使用getOrientation()功能感到困惑,有人能告诉我一个如何获得角度的例子吗?
当我改变左右变量时,我有一个需要从左到右和从右到左移动的元素.
这是一个jsfiddle示例,我正在研究它.它从左到右,从右到左移动,但没有动画.
我做错了什么?
CSS:
div
{
width:100px;
height:100px;
background:red;
transition-property: right, left;
transition-duration: 2s;
-webkit-transition-property: right, left; /* Safari */
-webkit-transition-duration: 2s; /* Safari */
position:absolute;
}
div:hover
{
right:0px;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<body>
<p><b>Note:</b> This example does not work in Internet Explorer 9 and earlier versions.</p>
<div></div>
<p>Hover over the div element above, to see the transition effect.</p>
</body>
Run Code Online (Sandbox Code Playgroud) 我需要一个可以适应宽度自动的星级评分栏.当我尝试在设计屏幕上调整大小时; 如果屏幕很小,一些星星会消失(在第5或第6之后),如果屏幕很大,所有星星都可见.
我该怎么做?
这是我有什么
<RatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="10"
android:rating="7" />
Run Code Online (Sandbox Code Playgroud) 我想在下一个项目中使用Google云存储。我的目的是跟踪各种网站并收集一些照片。作为,我阅读了gsutil的文档;我可以将文件手动下载到我的服务器,然后使用gsutil将其上传到Google云存储中。
下载和上传文件会在我的服务器中产生大量流量。有没有办法让Google Cloud直接从http下载文件?
我正在尝试连接4 mp4文件.我正在使用下面的命令,但无法连接
ffmpeg -i new1.mp4 -i new2.mp4 -i new3.mp4 -i new4.mp4 -filter_complex concat=n=4:v=1:a=1 output.mp4
Run Code Online (Sandbox Code Playgroud)
得到此错误:
Input link in1:v0 parameters (size 640x640, SAR 16:9) do not match the corresponding output link in0:v0 parameters (640x640, SAR 427:240)
Run Code Online (Sandbox Code Playgroud)
所有四个视频具有相同的编解码器和相同的大小(640x640)和相同的比特率(30)
我做错了什么?
我正在尝试为基于 XMC1100 的开发板编码。我正在尝试本教程:http : //eleceng.dit.ie/frank/arm/BareMetalXMC2Go/index.html
我已经下载了blinky.tar.gz 文件并解压了。当我尝试“制作”时,我收到此错误:arm-none-eabi-ld:找不到 -lc
这是“make”的输出
arm-none-eabi-gcc -c -mcpu=cortex-m0 -mthumb -g init.c -o init.o
arm-none-eabi-gcc -c -mcpu=cortex-m0 -mthumb -g main.c -o main.o
arm-none-eabi-ld init.o main.o -L /usr/lib/gcc/arm-none-eabi/4.8.2/armv6-m -T linker_script.ld -lc --cref -Map main.map -nostartfiles -o main.elf
arm-none-eabi-ld: cannot find -lc
make: *** [main.elf] Error 1
Run Code Online (Sandbox Code Playgroud)
我正在使用 Linux Mint 17 Qiana
我缺少什么?
这是我的makefile:
LIBSPEC=-L /usr/lib/gcc/arm-none-eabi/4.8.2/armv6-m
# Specify the compiler to use
CC=arm-none-eabi-gcc
# Specify the assembler to use
AS=arm-none-eabi-as
# Specity the linker to use
LD=arm-none-eabi-ld
CCFLAGS=-mcpu=cortex-m0 …Run Code Online (Sandbox Code Playgroud) 我知道这个问题以前被问过,但解决方案并不能解决我的问题。
所以我才想再问一遍。因为我尝试过 ES5、ES6、ES2018、ES2015、ES2015.promise 等。
背景.js
async function run() {
setInterval(()=>{
console.log("Hello world");
},3000);
}
async function getTab() {
const tabs = await chrome.tabs.query({});
return tabs[0];
}
setInterval(async function(){
const tab = await getTab();
console.log(tab);
chrome.scripting.executeScript(
{
target: {tabId: tab.id, allFrames: true},
func: run,
},
(injectionResults) => {
console.log("what is happening here",injectionResults);
});
},5000);
Run Code Online (Sandbox Code Playgroud)
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"outDir": "out",
"lib": [ "es2018", "dom" ]
}
}
Run Code Online (Sandbox Code Playgroud)
tsc 背景.ts
出现此错误
error TS2468: Cannot find global …Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel框架,我在controllers/admin/PlacesController.php下创建了一个类
我把它放在名字空间控制器/管理员;
但正如你在下面看到的,我不能使用没有"\"的标准Laravel课程.请参阅\ View
class PlacesController extends \BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$places=\Place::all();
return \View::make('admin.places.index',compact('places'));
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
return \View::make('admin.places.createOrEdit');
}
}
Run Code Online (Sandbox Code Playgroud)
但我想用它作为View而不用"\"我怎么能这样做?将所有视图修复为\ View确实是一个问题
谢谢大家.
我正在使用Web Api和Entity Framework,我有一个名为Gift的控制器,当客户端GET是API时,我通过使用实体框架从DB获取所有礼物并将其作为JSON返回
这是我的控制器功能
public List<Gift> Get()
{
return GiftService.GetIncludeAndActive();
}
Run Code Online (Sandbox Code Playgroud)
这是服务功能
public List<Gift> GetIncludeAndActive()
{
return dbSet.Include("GiftCategory").Where(x => x.Status == Model.Enums.GiftStatus.Active).OrderByDescending(x => x.Featured).ThenBy(x => x.Price).ToList();
}
Run Code Online (Sandbox Code Playgroud)
这是礼物模特
public class Gift
{
public Gift()
{
this.CartItems = new List<CartItem>();
}
public int ID { get; set; }
public string GiftName { get; set; }
public string Image { get; set; }
public int Stock { get; set; }
public int Price { get; set; }
public string Description { get; …Run Code Online (Sandbox Code Playgroud) 我有一个表,将标签名称存储为“标签”
标签
id->Integer(unique)
title->String;
url->string;(unique)
Run Code Online (Sandbox Code Playgroud)
我还有一张表来存储名为 place 的地方
地方
id->Integer(unique)
title->string
latitude->string
longtitue->string
Run Code Online (Sandbox Code Playgroud)
一个地方可能有很多标签,这是我的 place_tag 表
地点标签
id->Integer(unique)
tag_id->Integer
place_id->Integer
Run Code Online (Sandbox Code Playgroud)
当我尝试更新地点时,我需要这样做
1- 检查发布的所有标签。2- 如果之前未创建,则将它们添加到“标记”数据库中 3- 写入与标记和位置的关系
但我认为 Laravels ORM 可以处理它,我四处走动但找不到好的解决方案。
请查看我的更新程序,我做错了什么。
public function update($id)
{
$place=Place::findOrFail($id);
$place->fill(Input::all());
$place->save();
$tags=explode(',',Input::get('tags'));
$tags_data=array();
foreach($tags as $tag) {
$tags_data[]=new Tag(array('title'=>$tag,'url'=>$tag));
}
$place->tags()->detach();
$place->tags()->saveMany($tags_data);
return Redirect::to('admin/places');
}
Run Code Online (Sandbox Code Playgroud) 我有运行我的应用程序的设置和 docker 机器。在这个 docker 机器中,xdebug 是通过这些 xdebug.ini 设置启用的。
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=10.5.0.1
Run Code Online (Sandbox Code Playgroud)
我的本地机器 IP 是 10.5.0.1
当我尝试在命令行上运行我的应用程序时,它会连接回 PhpStorm 调试器。但是由于没有路径映射,它停在脚本的第一行,断点不起作用。断点光标不可见,我无法F8按键跟踪代码。
此外,它必须显示某种路径映射错误 Debugger->Variables 窗口,但它不显示任何错误。
如何解决这个问题?
android ×3
laravel ×3
eloquent ×2
orm ×2
php ×2
asp.net ×1
c ×1
c# ×1
css ×1
ecmascript-6 ×1
embedded ×1
es6-promise ×1
ffmpeg ×1
gcc ×1
gsutil ×1
html ×1
json ×1
laravel-4 ×1
mpu ×1
namespaces ×1
orientation ×1
phpstorm ×1
promise ×1
ratingbar ×1
searchview ×1
sensor ×1
typescript ×1
xdebug ×1