public function store() { $name = Input::get('name'); $color = Input::get('color'); $user_id = Auth::id(); $todolist = new Todolist(array('user_id' => $user_id, 'name' => $name, 'color' => $color)); $todolist->save(); $addedListId = DB::table('todolists')->where('name', '=', $name)->value('id'); return Response::json(['name' => $name, 'color' => $color, 'id' => $addedListId]); }
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)]); } }
/** * Run the database seeds. * * @return void */ public function run() { $faker = \Faker\Factory::create(); Todolist::truncate(); // delete all previous records, reset AI to 1 foreach (range(1, 50) as $index) { Todolist::create(['name' => $faker->sentence(2), 'description' => $faker->sentence(4)]); } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $user = User::create(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'email' => $data['email'], 'dob' => $data['dob'], 'gender' => $data['gender'], 'password' => bcrypt($data['password'])]); $name = $data['first_name']; $email = $data['email']; $user_id = $user->id; Calendar::create(array('name' => $name, 'color' => '51, 153, 255', 'user_id' => $user_id)); Todolist::create(array('name' => 'To Do', 'color' => '0, 0, 102', 'user_id' => $user_id)); Style::create(array('theme_name' => 'default', 'body_backgroundColor' => '218, 173, 134', 'buttons_backgroundColor' => '117, 168, 202', 'buttons_borderColor' => '89, 105, 114', 'navBar_backgroundColor' => '201, 216, 197', 'menuModal_backgroundColor' => '255, 246, 253', 'user_id' => $user_id)); $emaildata = array('name' => $name); Mail::send('emails.welcome', $emaildata, function ($message) use($email) { $message->from('*****@*****.**', 'gmPlanner'); $message->to($email)->subject('Welcome to gmPlanner'); }); return $user; }
/** * Run the database seeds. * * @return void */ public function run() { Todolist::create(['name' => 'Penang Vacation', 'description' => 'Things to do before leave']); Todolist::create(['name' => 'KL Vacation', 'description' => 'Things to do before leave']); Todolist::create(['name' => 'Mersing Vacation', 'description' => 'Things to do before leave']); }
public function getIndex() { $lists = Todolist::all(); return view('lists.index')->with('lists', $lists); }
/** * Run the database seeds. * * @return void */ public function run() { Todolist::create(array('user_id' => '1', 'name' => 'To Do', 'color' => '0, 153, 255')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // dd('destory method'); $list = Todolist::destroy($id); return \Redirect::route('viewlist')->with('message', 'Your list is deleted'); }
public function delete($id) { $list = Todolist::findOrFail($id); $list->delete(); return redirect(route('lists.index'))->with('flash_success', 'List deleted successfully.'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // return 'test'; Todolist::destroy($id); return \Redirect::route('lists.index'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(ListFormRequest $request, $id) { $list = Todolist::find($id); $list->update(['name' => $request->get('name'), 'description' => $request->get('description')]); return \Redirect::route('lists.edit', array($list->id))->with('message', 'Your list has been updated!'); }