/** * Execute the console command. * * @return mixed */ public function handle() { $lists = Todolist::all(); foreach ($lists as $list) { $list->resluggify(); $list->save(); } }
public function run() { $faker = \Faker\Factory::create(); Todolist::truncate(); foreach (range(1, 50) as $index) { Todolist::create(['name' => $faker->sentence(2), 'description' => $faker->sentence(4)]); } }
/** * Determines if the user owns a particular list * @param integer $listId * @return Boolean */ public function owns($listId) { $list = Todolist::find($listId); if ($list->user_id == $this->id) { return true; } else { return false; } }
public function testNotValidWhenNameMissing() { $t = new Todolist(); $this->assertFalse($t->validate()); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { //$list = Todolist::findOrFail($id); $list = Todolist::findBySlug($id); return view('lists.show')->with('list', $list); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Todolist::destroy($id); return \Redirect::route('lists.index'); }
/** * Delete a list * @param integer $id The list ID * @return Response */ public function destroy($id) { $user = \Auth::user(); $list = Todolist::findOrFail($id); $list->delete(); return \Redirect::route('lists.index')->with('message', 'Task deleted!'); }
public function testTodolistRecordCount() { $listFactory = factory('todoparrot\\Todolist')->create(); $lists = Todolist::all(); $this->assertEquals($lists->count(), 1); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Todolist::destroy($id); return \Redirect::route('lists.index')->with('message', 'The list has been deleted!'); }
/** * Toggle task completion * * @param integer $listId The list ID * @param integer $taskId The task ID * @return Response * */ public function complete($listId, $taskId) { $user = User::find(\Auth::id()); $list = Todolist::findOrFail($listId); if ($user->owns($listId)) { $task = $list->tasks()->where('id', '=', $taskId)->first(); if ($task->done == true) { $task->done = false; } else { $task->done = true; } $task->save(); return \Redirect::route('lists.show', [$list->id])->with('message', 'Task updated!'); } else { return \Redirect::route('home')->with('message', 'Authorization error: you do not own this list.'); } }
/** * Run the database seeds. * * @return void */ public function run() { Todolist::truncate(); factory(Todolist::class, 20)->create(); }