本文整理汇总了PHP中app\models\Task::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::find方法的具体用法?PHP Task::find怎么用?PHP Task::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Task
的用法示例。
在下文中一共展示了Task::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
public function search($params, $dueDateOperator = null, $dueDate = null, $inCompleted = false)
{
$query = Task::find();
$query->joinWith(["milestone.project", "milestone", "user"]);
if (Yii::$app->user->identity->isViewingProject) {
$query->andWhere(["project.id" => Yii::$app->user->identity->fkIDWithProjectID]);
}
if ($dueDateOperator != null && $dueDate != null) {
$query->andWhere("task.dueDate " . $dueDateOperator . " '" . $dueDate . "'");
}
if ($inCompleted) {
$query->andWhere(["task.completed" => 0]);
}
$activeDataProvider = new ActiveDataProvider(["query" => $query, "pagination" => ["pageSize" => 20]]);
$activeDataProvider->sort->attributes["userFullName"] = ["asc" => ["user.fullName" => SORT_ASC], "desc" => ["user.fullName" => SORT_DESC]];
$activeDataProvider->sort->attributes["projectName"] = ["asc" => ["project.name" => SORT_ASC], "desc" => ["project.name" => SORT_DESC]];
$activeDataProvider->sort->attributes["milestoneName"] = ["asc" => ["milestone.name" => SORT_ASC], "desc" => ["milestone.name" => SORT_DESC]];
if (!$this->load($params) || !$this->validate()) {
if (Yii::$app->user->identity->defaultTasksAssignedToMe) {
$this->userFullName = Yii::$app->user->id;
}
return $activeDataProvider;
}
$query->andFilterWhere(["like", "task.id", $this->id])->andFilterWhere(["like", "task.name", $this->name])->andFilterWhere(["like", "user.id", $this->userFullName])->andFilterWhere(["like", "project.name", $this->projectName])->andFilterWhere(["like", "milestone.name", $this->milestoneName])->andFilterWhere(["like", "task.dueDate", !empty($this->dueDate) ? Yii::$app->formatter->asDate($this->dueDate, "Y-MM-dd") : null])->andFilterWhere(["like", "task.completed", $this->completed]);
return $activeDataProvider;
}
示例2: actionView
/**
*
*/
public function actionView()
{
/** @var User[] $users */
$users = User::find()->all();
/** @var Task[] $tasks */
$tasks = Task::find()->all();
foreach ($users as $user) {
echo 'Username : ' . $user->username . "\n";
echo 'TimeZone : ' . $user->timeZone . "\n";
echo 'Tasks : ' . "\n";
foreach ($tasks as $task) {
echo "\t" . 'Task : ' . $task->title . "\n";
\Yii::$app->formatter->timeZone = 'UTC';
echo "\t" . 'Time UTC start : ' . \Yii::$app->formatter->asDatetime($task->timeStart) . "\n";
echo "\t" . 'Time UTC end : ' . \Yii::$app->formatter->asDatetime($task->timeEnd) . "\n\n";
\Yii::$app->formatter->timeZone = $user->timeZone;
echo "\t" . 'Time ' . $user->timeZone . ' start : ' . \Yii::$app->formatter->asDatetime($task->timeStart) . "\n";
echo "\t" . 'Time ' . $user->timeZone . ' end : ' . \Yii::$app->formatter->asDatetime($task->timeEnd) . "\n";
echo "\t--------\n";
// timestamp wont change if we apply timezone
// $date = new \DateTime();
// $date->setTimestamp($task->timeStart);
// $date->setTimezone(new \DateTimeZone($user->timeZone));
// echo $task->timeStart . ' => ' . $date->getTimestamp() . "\n"; // same timestamp
}
echo "=========== \n";
}
}
示例3: actionDashboard
public function actionDashboard()
{
$searchModel = new WindowSearch();
$searchModel->dateFrom = date('Y-m-d');
$searchModel->dateTo = date('Y-m-d');
$dataProvider = $searchModel->search(Yii::$app->request->post());
// eagerly load process info
$dataProvider->query->with('process');
$from = strtotime('today', $searchModel->timestampFrom);
$to = strtotime('tomorrow', $searchModel->timestampTo);
$processList = StatsHelper::getProcessList($from, $to);
$this->view->registerJs('var dashboardProcess = ' . json_encode($processList), View::POS_HEAD);
$timeline = StatsHelper::timeline($from, $to);
$this->view->registerJs('var dashboardTimeline = ' . json_encode($timeline), View::POS_HEAD);
$this->view->registerAssetBundle(ColorStripAsset::className());
// Durations split by process
$durations = StatsHelper::getProcessWindowHierarchy($from, $to);
$this->view->registerJs('var dashboardDurations = ' . json_encode($durations), View::POS_HEAD);
$this->view->registerAssetBundle(SunburstAsset::className());
// Durations split by task
$durations = StatsHelper::getTaskWindowHierarchy($from, $to);
$this->view->registerJs('var dashboardTaskDurations = ' . json_encode($durations), View::POS_HEAD);
// Keys
$keysActivity = StatsHelper::keysActivity($from, $to);
$this->view->registerJs('var dashboardKeys = ' . json_encode($keysActivity), View::POS_HEAD);
$this->view->registerAssetBundle(KeysAsset::className());
$this->view->registerAssetBundle(KeysAreaAsset::className());
$this->clusterChart($searchModel);
$tasks = array_map(function ($task) {
return ['id' => $task->id, 'name' => $task->name];
}, Task::find()->all());
$this->view->registerJs('var dashboardTasks = ' . json_encode($tasks), View::POS_HEAD);
$this->view->registerAssetBundle(DashboardAsset::className());
return $this->render('dashboard', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'totalActivity' => StatsHelper::totalActivity($from, $to)]);
}
示例4: actionIndex
public function actionIndex()
{
$user = Yii::$app->user;
$dashboard = [];
if ($user->can('partner_view')) {
$dashboard[] = ['name' => Html::tag('b', __('Partners')), 'link' => Url::to(['partner/index']), 'count' => Partner::find()->count()];
}
if ($user->can('visit_view') || $user->can('visit_view_all')) {
$dashboard[] = ['name' => __('Visits'), 'link' => Url::to(['visit/index']), 'count' => Visit::find()->count()];
}
if ($user->can('donate_view') || $user->can('donate_view_all')) {
$dashboard[] = ['name' => __('Donates'), 'link' => Url::to(['donate/index']), 'count' => Donate::find()->count()];
}
if ($user->can('task_view') || $user->can('task_view_all')) {
$dashboard[] = ['name' => __('Tasks'), 'link' => Url::to(['task/index']), 'count' => Task::find()->count()];
}
if ($user->can('newsletter_view')) {
$dashboard[] = ['name' => __('Mailing lists'), 'link' => Url::to(['mailing-list/index']), 'count' => MailingList::find()->count()];
$dashboard[] = ['name' => __('Newsletters'), 'link' => Url::to(['newsletter/index']), 'count' => Newsletter::find()->count()];
$dashboard[] = ['name' => __('Printing templates'), 'link' => Url::to(['print-template/index']), 'count' => PrintTemplate::find()->count()];
}
if ($user->can('user_manage')) {
$dashboard[] = ['name' => __('Users'), 'link' => Url::to(['user/index']), 'count' => User::find()->count()];
}
return $this->render('index', ['dashboard' => $dashboard]);
}
示例5: getTasksNearest
/**
* Returns first nearest tasks
* @param int $iTotalCount if provided total count will be returned to this value
* @return Task[]
*/
public static function getTasksNearest(&$iTotalCount = 0)
{
$query = Task::find()->where(['closed' => 0])->orderBy('date')->limit(10);
if (func_num_args()) {
$iTotalCount = $query->count();
}
return $query->andWhere('date')->all();
}
示例6: actionIndex
/**
* Lists all Task models.
* @return mixed
*/
public function actionIndex()
{
if (($role = priviledge::getRole()) == 'Admin') {
$dataProvider = new ActiveDataProvider(['query' => Task::find(), 'pagination' => ['pageSize' => 15]]);
return $this->render('index', ['dataProvider' => $dataProvider]);
} else {
throw new ForbiddenHttpException();
}
}
示例7: actionIndex
/**
* Выборка из базы данных с сортировкой и отрисовка главного view
* @return view
*/
public function actionIndex()
{
//Определение языка
SiteController::locale();
//Выборка из таблицы tasks с комментариями из comments, отсортированные по дате и активности
$data = Task::find()->with('comment')->orderBy(['status' => SORT_DESC, 'date' => SORT_DESC])->all();
//Отрисовка главного представления
return $this->render('index', ['data' => $data]);
}
示例8: destroy
public function destroy()
{
$task = Task::find(Input::get("id"));
if (!$task) {
return response()->json(['status' => 'error', 'msg' => "Invalid task!"]);
}
$task->delete();
return response()->json(['status' => 'success']);
}
示例9: actionView
/**
* Displays a single Goal model.
* @param $alias
* @return mixed
*/
public function actionView($alias)
{
$goal = $this->findModel(['alias' => $alias]);
$id = $goal->id;
$logRows = Log::find()->where(['goal_id' => $id])->orderBy('created_at DESC')->limit(5)->all();
$taskQuery = Task::find()->where(['goal_id' => $id, 'closed' => 0])->orderBy('date')->limit(5);
$taskRows = $taskQuery->all();
$taskCount = $taskQuery->count();
return $this->render('view', ['goal' => $goal, 'logRows' => $logRows, 'taskRows' => $taskRows, 'taskCount' => $taskCount, 'logModel' => new Log(['goal_id' => $id])]);
}
示例10: actionUpdate
/**
* Updates an existing Report model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$tasks = Task::find(['deleted' => '0'])->all();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', ['model' => $model, 'tasks' => $tasks]);
}
}
示例11: find
public function find()
{
if ($this->ids) {
return TaskModel::find()->where(['id' => $this->ids])->orderBy(['created_at' => SORT_DESC]);
} else {
$search = new TaskSearch();
$dataProvider = $search->search($this->queryParams);
$dataProvider->pagination = false;
return $dataProvider->query;
}
}
示例12: exposeData
/**
* Expose data to Javascript
* @throws \yii\base\InvalidConfigException
*/
public function exposeData()
{
$searchModel = new WindowSearch();
$searchModel->date = date('Y-m-d');
$dataProvider = $searchModel->search(Yii::$app->request->post());
// eagerly load process info
$dataProvider->query->with('process');
$from = strtotime('today', $searchModel->timestamp);
$to = strtotime('tomorrow', $searchModel->timestamp);
$processList = StatsHelper::getProcessList($from, $to);
$this->exposeToJs('dashboardProcess', $processList);
$timeline = StatsHelper::timeline($from, $to);
$this->exposeToJs('dashboardTimeline', $timeline);
// $this->view->registerAssetBundle(ColorStripAsset::className());
// Durations split by process
$durations = StatsHelper::getProcessWindowHierarchy($from, $to);
$this->exposeToJs('dashboardDurations', $durations);
// $this->view->registerAssetBundle(SunburstAsset::className());
// Durations split by task
$durations = StatsHelper::getTaskWindowHierarchy($from, $to);
$this->exposeToJs('dashboardTaskDurations', $durations);
// Keys
$keysActivity = StatsHelper::keysActivity($from, $to);
$this->exposeToJs('dashboardKeys', $keysActivity);
$this->view->registerAssetBundle(KeysAsset::className());
$this->view->registerAssetBundle(KeysAreaAsset::className());
$this->clusterChart($searchModel);
$tasks = array_map(function ($task) {
return ['id' => $task->id, 'name' => $task->name];
}, Task::find()->all());
$this->exposeToJs('dashboardTasks', $tasks);
$this->view->registerAssetBundle(DashboardAsset::className());
// Transition matrix
$transitionMatrix = StatsHelper::transitionMatrix($from, $to, 30000);
$windows = StatsHelper::windows($from, $to);
$windowList = StatsHelper::windowsList($windows);
$links = $transitionMatrix->flatten(Matrix::FLATTEN_MATRIX_BY_ID);
$clusters = $transitionMatrix->clusterization()->mapToClusters(array_values(ArrayHelper::map($windowList, 'id', 'id')));
foreach ($windowList as $key => &$w) {
$w['cluster'] = (int) $clusters[$key];
}
$this->exposeToJs('dashboardWindows', $windowList);
$this->exposeToJs('dashboardLinks', $links);
$this->view->registerAssetBundle(D3TipAsset::className());
// $graphJson = AlchemyHelper::buildData($transitionMatrix, $windows, $winIdCluster);
//
// $this->view->registerJs(
// 'var dashboardGraphJson = ' . json_encode($graphJson),
// View::POS_HEAD);
}
示例13: searchChild
public function searchChild($params)
{
$query = Task::find();
$query->where(['task_from' => Yii::$app->user->id]);
$query->andWhere(['parent_task_id' => $params]);
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
return $dataProvider;
}
示例14: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Task::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['task_id' => $this->task_id, 'project_id' => $this->project_id, 'user_id' => $this->user_id, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'estimated_time' => $this->estimated_time, 'operating_time' => $this->operating_time, 'regist_date' => $this->regist_date, 'update_date' => $this->update_date, 'del_chk' => $this->del_chk]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
示例15: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Task::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'start' => $this->start, 'end' => $this->end, 'family_id' => $this->family_id]);
$query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
return $dataProvider;
}