本文整理汇总了PHP中Batch::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Batch::create方法的具体用法?PHP Batch::create怎么用?PHP Batch::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Batch
的用法示例。
在下文中一共展示了Batch::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* create new batch task
* @return mixed
*/
public function create()
{
$data = Input::all();
$batchData = [];
$dataTypeValidator = Validator::make(Input::all(), ['dataType' => 'required']);
if ($dataTypeValidator->fails()) {
return Redirect::back()->withInput()->with('alert-danger', 'Data type is missing!');
}
$dataType = $data['dataType'];
$rules = ['startDateTime', 'endDateTime'];
if ($dataType == "WATER") {
$rules[] = 'waterProblemType';
} elseif ($dataType == "RAIN") {
$rules[] = 'rainProblemType';
}
if (!isset($data['allStation'])) {
$rules[] = 'stations';
}
foreach ($rules as $r) {
if (!isset($data[$r])) {
return Redirect::back()->withInput()->with('alert-danger', $r . ' is incomplete!');
}
}
if ($data['startDateTime'] == "" or $data['endDateTime'] == "") {
return Redirect::back()->withInput()->with('alert-danger', 'Date is incomplete!');
}
$batchData['data_type'] = $data['dataType'];
if ($batchData['data_type'] == "WATER") {
$batchData['problem_type'] = $data['waterProblemType'];
} elseif ($batchData['data_type'] == "RAIN") {
$batchData['problem_type'] = $data['rainProblemType'];
}
if (isset($data['allStation'])) {
$batchData['all_station'] = true;
} else {
$batchData['all_station'] = false;
$batchData['stations'] = $data['stations'];
}
$batchData['start_datetime'] = Date($data['startDateTime']);
$batchData['end_datetime'] = Date($data['endDateTime']);
$batchData['add_datetime'] = Date('Y-m-d H:i:s');
$batch = Batch::create($batchData);
Queue::push('BatchController', ['id' => $batch->id]);
return Redirect::to('batch')->with('alert-success', 'Task #' . $batch->id . ' Added Successfully.');
}
示例2: start_test_handler
/**
* @param integer $number_of_batches
* @return string
* @throws BaseUserAccessDeniedException
* @throws BaseBatchInvalidArgumentException
*/
public static function start_test_handler($number_of_batches)
{
global $user;
if ($user->is_admin()) {
if (is_numeric($number_of_batches) and $number_of_batches >= 1) {
for ($i = 1; $i <= $number_of_batches; $i++) {
$batch = new Batch(null);
$batch->create(1);
}
return "1";
} else {
throw new BaseBatchInvalidArgumentException();
}
} else {
throw new BaseUserAccessDeniedException();
}
}
示例3: Batch
<?php
require_once "../../includes/initialize.php";
global $session;
if (!$session->is_logged_in()) {
redirect_to("../../index.php");
}
if ($_POST['oper'] == 'add') {
$batch = new Batch();
$batch->comments = $_POST['comments'];
$batch->about = $_POST['about'];
$batch->pending = $_POST['pending'];
$batch->enabled = $_POST['enabled'];
$batch->fromyear = $_POST['fromyear'];
$batch->schoolid = $_POST['schoolid'];
$batch->create();
$batchuser = new BatchUser();
$batchuser->pending = 0;
$batchuser->enabled = 1;
$batchuser->schoolid = $batch->schoolid;
$batchuser->batchid = $batch->id;
$batchuser->userid = $session->user_id;
$batchuser->level = 1;
$batchuser->create();
$folder_path = "../../public/schools/" . $batch->schoolid . "/yearbooks/" . $batch->id . "/";
mkdir($folder_path, 0700);
mkdir($folder_path . "pages", 0700);
mkdir($folder_path . "files", 0700);
copy("../../public/index.php", $folder_path . "/pages/index.php");
copy("../../public/page1.html", $folder_path . "/pages/page1.html");
$log = new Log($session->user_id, $clientip, "WEB", "CREATED BATCH: " . $_POST['id']);
示例4: Batch
if (!Batch::batch_exists($_POST['fromyear'], $school->id)) {
$object = new Batch();
$object->fromyear = $_POST['fromyear'];
$object->about = $_POST['about'];
$object->comments = $_POST['comments'];
$object->fbcomments = $_POST['fbcomments'];
$object->schoolid = $school->id;
$object->enabled = 1;
$object->pending = 0;
$object->pubdate = $_POST['pubdate'];
$object->published = 0;
$file = new File($_FILES['cover']);
if ($file->valid) {
$object->picture = $file->data;
}
$object->create();
$folder_path = "../../public/schools/" . $school->id . "/yearbooks/" . $object->id . "/";
mkdir($folder_path, 0700);
mkdir($folder_path . "pages", 0700);
mkdir($folder_path . "files", 0700);
copy("../../public/0.students.php", $folder_path . "/pages/0.students.php");
copy("../../public/0.page1.html", $folder_path . "/pages/0.page1.html");
copy("../../public/11.Vision_and-Mission-Sample.html", $folder_path . "/pages/11.Vision_and-Mission-Sample.html");
copy("../../public/12.7.The_Achievers-Sample.html", $folder_path . "/pages/12.7.The_Achievers-Sample.html");
copy("../../public/22.Core_Values-Sample.html", $folder_path . "/pages/22.Core_Values-Sample.html");
copy("../../public/33.Message_of_the_City_Mayor-Sample.html", $folder_path . "/pages/33.Message_of_the_City_Mayor-Sample.html");
copy("../../public/44.3.History-Sample.html", $folder_path . "/pages/44.3.History-Sample.html");
copy("../../public/55.5.Message_of_the_Director-Sample.html", $folder_path . "/pages/55.5.Message_of_the_Director-Sample.html");
$batchuser = new BatchUser();
$batchuser->schoolid = $school->id;
$batchuser->batchid = $object->id;
示例5: createBatch
/**
* Create a batch
*
* @param bool $stopJobOnError Should the batch be stopped on error?
* @return Batch
* @throws \Exception
*/
public function createBatch($stopJobOnError = false)
{
$batch = new Batch($this->api);
$batch->create($stopJobOnError);
return $batch;
}
示例6: store
public function store(RegisterBatch $request)
{
Batch::create($request->all());
}