本文整理汇总了PHP中app\Task::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::create方法的具体用法?PHP Task::create怎么用?PHP Task::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Task
的用法示例。
在下文中一共展示了Task::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postTask
function postTask(Request $request)
{
$task = $request->all();
Task::create($task);
$comm = Committee::where('id', $task['comm_id'])->first();
$evnt = Event::where('id', $comm['event_id'])->first();
//UPDATING WEIGHT OF COMMITTEE AND EVENT
$comm->increment('weight', $task['weight']);
$evnt->increment('weight', $task['weight']);
//UPDATING PROGRESS OF COMMITTEE
$progress = 0;
$tasks = Task::where('comm_id', $comm->id)->get();
foreach ($tasks as $task1) {
$progress += $task1->weight * $task1->progress;
}
$progress = $progress / $comm->weight;
$comm->progress = $progress;
$comm->save();
//UPDATING PROGRESS OF EVENT
$progress2 = 0;
$committees = Committee::all();
foreach ($committees as $committee) {
if ($committee->event_id == $evnt->id) {
$progress2 += $committee->weight * $committee->progress;
}
}
$progress2 = $progress2 / $evnt->weight;
$evnt->progress = $progress2;
$evnt->save();
return redirect('profile');
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
for ($i = 0; $i < 10; $i++) {
$j = rand(0, 1000);
Task::create(['author' => 'Testowy Autor ' . $j, 'name' => 'Testowe Zadanie ' . $j, 'category_id' => 1, 'user_id' => 1]);
}
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
foreach (range(1, 30) as $index) {
Task::create(['user_id' => '1', 'title' => $faker->sentence(4), 'content' => $faker->paragraphs(8, true), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'due_at' => $faker->dateTimeBetween('+1 days', '+2 years')->format('m/d/Y')]);
}
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$arrRet = array('success' => false);
if (empty($request->get('title'))) {
$arrRet['errors'][] = "The title cannot be empty.";
}
if (empty($request->get('description'))) {
$arrRet['errors'][] = "The description cannot be empty.";
}
if (empty($request->get('categoryId'))) {
$arrRet['errors'][] = "Please select a category.";
}
if (empty($request->get('userId'))) {
$arrRet['errors'][] = "Please assign the task to a user.";
}
if (empty($arrRet['errors'])) {
// We are good no errors
$task = new Task();
$created = $task->create(['title' => $request->get('title'), 'description' => $request->get('description'), 'category_id' => $request->get('categoryId'), 'user_id' => $request->get('userId')]);
if ($created) {
$arrRet['success'] = true;
$arrRet['task'] = $created;
}
}
return response()->json($arrRet);
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Project $project)
{
$input = Input::all();
$input['project_id'] = $project->id;
Task::create($input);
return Redirect::route('projects.show', $project->slug)->with('message', 'Task created.');
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
foreach (range(1, 20) as $index) {
Task::create(['user_id' => rand(1, 4), 'title' => implode($faker->sentences(2)), 'priority_id' => rand(1, 4), 'notes' => implode($faker->paragraphs(4))]);
}
}
示例7: store
public function store(CreateTaskRequest $request)
{
$data = ['work' => Input::get('workName'), 'status' => 'Incomplete'];
$response = Task::create($data);
if ($response) {
return redirect()->back();
}
}
示例8: store
public function store(Request $request)
{
$this->validate($request, ['title' => 'required', 'description' => 'required']);
$input = $request->all();
Task::create($input);
\Session::flash('flash_message', 'Tarea agregada');
return redirect()->back();
}
示例9: store
public function store(CreateTask $request)
{
//dd($request->all());
Task::create($request->all());
return redirect('todolist');
// var_dump($request::all());
// Task::create($request::all());
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['tar_title' => 'required', 'tar_descripcion' => 'required']);
$input = $request->all();
Task::create($input);
$request->session()->flash('flash_message', 'Se agrego la Tarea!');
return redirect()->back();
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['title' => 'required', 'description' => 'required']);
$input = $request->all();
Task::create($input);
Session::flash('flash_message', 'Задача успешно добавлена!');
return redirect()->back();
}
示例12: store
/**
* Store a newly created resource in storage.
* @return \Illuminate\Http\Response
*/
public function store()
{
if (!Input::get('name') or !Input::get('done') or !Input::get('priority')) {
return $this->setStatusCode(IlluminateResponse::HTTP_UNPROCESSABLE_ENTITY)->respondWithError('Parameters failed validation for a task.');
}
Task::create(Input::all());
return $this->respondCreated('Task successfully created.');
}
示例13: postCreateTask
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function postCreateTask(Request $request)
{
$task['content'] = $request->get('content');
$task['user_id'] = Auth::user()->id;
$task['list_id'] = $request->get('list_id');
$task['complete'] = 0;
return \App\Task::create($task);
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
if ($task = Task::create($request->all())) {
return $task->toJson();
} else {
return $this->response->error('Task could not be created.', 404);
}
}
示例15: store
public function store($todolist_id)
{
$name = Input::get('name');
$completed = Input::get('completed');
Task::create(array('todolist_id' => $todolist_id, 'name' => $name, 'completed' => $completed));
$id = DB::table('tasks')->where('name', '=', $name)->pluck('id');
return Response::json(['name' => $name, 'id' => $id, 'completed' => $completed, 'todolist_id' => $todolist_id]);
}