示例#1
0
 /**
  * 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)]);
     }
 }
示例#3
0
 /**
  * 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;
     }
 }
示例#4
0
 public function testNotValidWhenNameMissing()
 {
     $t = new Todolist();
     $this->assertFalse($t->validate());
 }
示例#5
0
 /**
  * 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');
 }
示例#7
0
 /**
  * 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!');
 }
示例#8
0
 public function testTodolistRecordCount()
 {
     $listFactory = factory('todoparrot\\Todolist')->create();
     $lists = Todolist::all();
     $this->assertEquals($lists->count(), 1);
 }
示例#9
0
 /**
  * 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!');
 }
示例#10
0
 /**
  * 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();
 }