我是 laravel 和 php 的新手,我的控制器中有这个函数,它给我错误 致命错误类名必须是有效的对象或字符串
public function getIndex () {
$categories = array();
foreach ( $Category::all() as $key=> $category) {
$categories[$category->id] = $category->name ;
}
Run Code Online (Sandbox Code Playgroud)
这是我的整个控制器
<?php
class ProductsController extends BaseController {
public function __construct(){
$this->beforeFilter('csrf' , array('on'=>'post')) ;
}
public function getIndex () {
$categories = array();
foreach ( $Category::all() as $key=> $category) {
$categories[$category->id] = $category->name ;
}
return View::make('products.index')
->with('products' , Product::all())
->with('categories' , $categories);
}
public function postCreate(){
$validator = Validator::make(Input::all() , Product::$rules);
if ($validator->passes()){ …Run Code Online (Sandbox Code Playgroud) 我有一个基于本教程的项目,其中用户旋转一个轮子,一个数字的值int days根据轮子的当前位置而改变,现在我想ImageView circle根据这个数字的值显示或隐藏另一个图像,但是它抛出NullPointerException
这是我的onTouch事,抱歉我的英语不好
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// reset the touched quadrants
for (int i = 0; i < quadrantTouched.length; i++) {
quadrantTouched[i] = false;
}
allowRotating = false;
startAngle = getAngle(event.getX(), event.getY());
break;
case MotionEvent.ACTION_MOVE:
double currentAngle = getAngle(event.getX(), event.getY());
rotateDialer((float) (startAngle - currentAngle));
startAngle = currentAngle;
days = ((int) currentAngle / 12) + 1;
String test = Integer.toString(days);
tvnumber.setText(test); …Run Code Online (Sandbox Code Playgroud)