0

I have the following code in a CakePHP Controller:

var $searchCondition = array(
    'Item.date >' => date('Y-m-d', strtotime("-2 weeks"))  // line 11
);

var $paginate = array(
    'conditions' => $itemCondition,
    'limit' => 25,
);


function index() {
    $this->set('applications',$this->paginate());
}

I am getting the following error:

Parse error: syntax error, unexpected '(', expecting ')' in D:\xampplite\htdocs\myApp\app\controllers\applications_controller.php on line 11

Does anyone knows what it means? I've double checked and the syntax seems to be right.

Thanks

1 Answer 1

2

You can only use constant values when initializing class properties. You cannot use functions here. You'll have to do something like this:

var $searchCondition = array(
    'Item.date >' => null
);

function beforeFilter() {   // or __construct
    $this->searchCondition['Item.date >'] = date('Y-m-d', strtotime("-2 weeks"));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.