本文整理汇总了PHP中Task::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::create方法的具体用法?PHP Task::create怎么用?PHP Task::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$input = Input::all();
$validation = Validator::make($input, Task::$rules);
if ($validation->passes()) {
$this->task->create($input);
Queue::push(function ($job) {
Log::info('Do something when task is created.');
$job->delete();
});
return Redirect::route('tasks.index');
}
return Redirect::route('tasks.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
}
示例2: handleRequest
protected function handleRequest(array $request)
{
$listId = $request[self::FIELD_LIST_ID];
$title = $request[self::FIELD_TITLE];
$description = $request[self::FIELD_DESCRIPTION];
$beforeId = $request[self::FIELD_BEFORE_TASK_ID];
if (isset($request[self::FIELD_AFTER_LAST_OPEN])) {
if ($request[self::FIELD_AFTER_LAST_OPEN]) {
$beforeId = Task::findNextTaskIdAfterLastOpenTask($listId);
}
}
TasksList::lock($listId);
$ord = null;
if ($beforeId) {
$beforeTask = Task::fetch($beforeId);
if ($beforeTask->getListId() !== $listId) {
throw new Exception("Insertion point for a new task is in another list", EndPoint::STATUS_BAD_REQUEST);
}
$ord = $beforeTask->getOrd();
Task::shiftRight($listId, $ord);
} else {
$ord = Task::getNextOrd($listId);
}
$taskId = Task::create($listId, $ord, $title, $description);
return array(self::FIELD_TASK_ID => $taskId);
}
示例3: saveItem
/**
* (non-PHPdoc)
* @see DetailsPageAbstract::saveItem()
*/
public function saveItem($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
$task = null;
if (isset($param->CallbackParameter->id) && !($task = Task::get(trim($param->CallbackParameter->id))) instanceof Task) {
throw new Exception('Invalid Task passed in!');
}
if (!isset($param->CallbackParameter->instructions) || ($instructions = trim($param->CallbackParameter->instructions)) === '') {
throw new Exception('Instructions are required!');
}
if (!isset($param->CallbackParameter->customerId) || !($customer = Customer::get(trim($param->CallbackParameter->customerId))) instanceof Customer) {
throw new Exception('Invalid Customer Passed in!');
}
$tech = isset($param->CallbackParameter->techId) ? UserAccount::get(trim($param->CallbackParameter->techId)) : null;
$order = isset($param->CallbackParameter->orderId) ? Order::get(trim($param->CallbackParameter->orderId)) : null;
$dueDate = new UDate(trim($param->CallbackParameter->dueDate));
$status = isset($param->CallbackParameter->statusId) ? TaskStatus::get(trim($param->CallbackParameter->statusId)) : null;
if (!$task instanceof Task) {
$task = Task::create($customer, $dueDate, $instructions, $tech, $order);
} else {
$task->setCustomer($customer)->setDueDate($dueDate)->setInstructions($instructions)->setTechnician($tech)->setFromEntityId($order instanceof Order ? $order->getId() : '')->setFromEntityName($order instanceof Order ? get_class($order) : '')->setStatus($status)->save();
}
// $results['url'] = '/task/' . $task->getId() . '.html?' . $_SERVER['QUERY_STRING'];
$results['item'] = $task->getJson();
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
$errors[] = $ex->getMessage();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例4: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Task::create([]);
}
}
示例5: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 100) as $index) {
Task::create(['name' => $faker->text(10, 20), 'description' => $faker->text(140)]);
}
}
示例6: handleRequest
protected function handleRequest(array $request)
{
$version = $request[self::FIELD_PROTOCOL_VERSION];
$projectTitle = $request[self::FIELD_TITLE];
$projectDescription = $request[self::FIELD_DESCRIPTION];
$projectId = Project::create(Project::getNextOrd(), $projectTitle, $projectDescription);
$listsRep = $request[self::FIELD_LISTS];
$listOrd = 0;
foreach ($listsRep as $listRep) {
$listTitle = $listRep[self::FIELD_TITLE];
$listId = TasksList::create($projectId, ++$listOrd, $listTitle);
$tasksRep = $listRep[self::FIELD_TASKS];
$taskOrd = 0;
foreach ($tasksRep as $taskRep) {
$taskTitle = $taskRep[self::FIELD_TITLE];
$taskDescription = $taskRep[self::FIELD_DESCRIPTION];
$taskId = Task::create($listId, ++$taskOrd, $taskTitle, $taskDescription);
if ($version > 1) {
$taskStatus = $taskRep[self::FIELD_TASK_STATUS];
Task::updateStatus($taskId, $taskStatus);
}
}
}
return array(self::FIELD_PROJECT_ID => $projectId);
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Project $project, Request $request)
{
$this->validate($request, $this->rules);
$input = Input::all();
$input['project_id'] = $project->id;
Task::create($input);
return Redirect::route('projects.show', $project->slug)->with('message', 'Task created.');
}
示例8: store
public function store(Request $request)
{
$this->validate($request, ['title' => 'required', 'description' => 'required']);
$input = $request->all();
Task::create($input);
Session::flash('flash_message', 'Task successfully added!');
return redirect()->back();
}
示例9: run
public function run()
{
Model::unguard();
$times = 5;
for ($i = 0; $i < $times; $i++) {
Task::create(array('name' => Str::random(), 'active' => rand(0, 1)));
}
}
示例10: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
// $this->call('UserTableSeeder');
DB::table('users')->truncate();
User::create(['username' => 'Sampler', 'email' => 'sample@kanban.list', 'password' => 'sample', 'password_confirmation' => 'sample', 'confirmed' => true]);
DB::table('tasks')->truncate();
Task::create(['user_id' => 1, 'book_id' => 1, 'order_no' => 1, 'status' => 1, 'name' => 'sample_name', 'message' => 'sample_message', 'doing_at' => 'now()', 'pomo' => 1]);
}
示例11: create
public function create()
{
Log::debug(__METHOD__);
// Log::debug(print_r(Input::all(), true));
$task = Task::create(['user_id' => Auth::user()->id, 'book_id' => Book::getIdInMessage(Auth::user(), Input::get('message')), 'status' => Task::$status_table[Input::get('priority', 'todo_m')], 'name' => Auth::user()->username, 'message' => Input::get('message')]);
$moveId = $this->isMovedFromBook($task) ? $task->id : 0;
$taskHtml = View::make('tasks._task')->with(['task' => $task, 'display' => 'none', 'done' => false])->render();
return Response::json(['id' => $task->id, 'status' => $task->statusSymbol(), 'li_html' => $taskHtml, 'move_task_id' => $moveId, 'task_counts' => $this->getTaskCounts(), 'all_books' => $this->getAllBookCounts()])->setCallback('addTodoResponse');
}
示例12: store
/**
* Store a newly created resource in storage.
* POST /tasks
*
* @return Response
*/
public function store()
{
$tasks = Task::create(Input::all());
if ($tasks) {
return ['status' => true, 'data' => $tasks];
} else {
return ['status' => false];
}
}
示例13: store
public function store()
{
//add the task
if (!Task::taskIsValid(Input::all())) {
return Redirect::back()->withInput()->withErrors(Task::$errors);
}
$addTasks = Task::create(Input::all());
$addTasks->complaint = 'No complaints so far.';
$addTasks->save();
return Redirect::route('tasks.index');
}
示例14: index
public function index()
{
$task = new Task();
$task->text = 'Tar';
$task->duedate = new Date();
$task->checkb = '0';
$result = $task->create();
if (!$result) {
throw new Exception('Error al insertar registro.');
}
}
示例15: run
public function run()
{
Task::truncate();
$faker = Faker::create();
foreach (range(1, 100) as $index) {
$numb = array(1, 2, 3, 4);
$numbs = array(1, 2);
$nums = $numbs[array_rand($numbs)];
$num = $numb[array_rand($numb)];
Task::create(['title' => $faker->sentence, 'description' => $faker->paragraph(3), 'category_id' => $nums, 'employee_id' => $num, 'complaint' => 'No complaints so far.']);
}
}