public function destroy(Todo $todo) { $todo->delete(); $activity = 'Deleted a To do'; Activity::log($activity); return redirect('/dashboard')->withSuccess(config('constants.DELETED')); }
/** * Run the database seeds. * * @return void */ public function run() { $todo = new Todo(); for ($i = 0; $i < 2500; $i++) { $todo->create(['name' => 'Todo Default ' . $i, 'done' => 0, 'due' => date("Y-m-d")]); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make(Input::all(), ['title' => 'required|max:255', 'description' => 'required']); if ($validator->fails()) { return redirect('/create')->withErrors($validator)->withInput(); } $todo = new Todo(); $todo->title = Input::get('title'); $todo->desciption = Input::get('description'); $todo->save(); return redirect('/')->with('success', 'Created Todo Successfully'); }
public function check(Request $request) { $todo = Todo::find($request->input('id')); $todo->status = $todo->status == TODO::STATUS_TODO ? TODO::STATUS_DONE : TODO::STATUS_TODO; $todo->save(); return $todo; }
public function activate($id) { $todo = Todo::find($id); $todo->isDone = !$todo->isDone; $todo->save(); return redirect('todos'); }
/** * Execute the console command. * * @return mixed */ public function handle() { $todos = Todo::all(); foreach ($todos as $todo) { $this->info($todo->title); } }
public function forUser(User $user) { // return Todo::where('user_id', $user->id) // ->orderBy('created_at', 'asc') // ->get(); return Todo::where('user_id', $user->id)->orderBy('completed', 'asc')->orderBy('created_at', 'asc')->paginate(10); }
public function update_estimate(Request $request, $id) { $todo = Todo::find($id); $todo->estimated_time = Input::get('estimate'); $todo->update(); return Redirect::back(); }
public function getApp() { //$todos = Todo::all(); $todos = Todo::whereStatus(2)->get(); //return view('app', ['todos' => $todos]); return view('app', compact('todos')); }
/** * Delete Todo * * @param $id * @return \Illuminate\Http\RedirectResponse */ public function destroy($id) { $todo = Todo::findOrFail($id); $todo->delete(); message()->error('Destroyed', 'Your ToDo has been destroyed !'); return redirect()->route('todo.index'); }
public function search(Request $request) { $keywords = $request->get('keywords'); $result = Todo::where('title', 'LIKE', '%' . $keywords . '%')->get(); //$result = Todo::like('title',$keywords)->get(); return view('todo.search')->with('todos', $result); }
/** * Run the database seeds. * * @return void */ public function run() { // DB::table('todos')->delete(); Todo::create(array( 'name' => 'Chris Sevilleja', 'website' => 'http://www.example.com/', 'description' => 'lorem ipsum ae cah cah la nggwe web angel eram hahahaha' )); Todo::create(array( 'name' => 'Chris Sevilleja1', 'website' => 'http://www.google.com/', 'description' => 'lorem ipsum ae cah cah la nggwe web angel eram hahahaha1' )); Todo::create(array( 'name' => 'Chris Sevilleja2', 'website' => 'http://www.yahoo.com/', 'description' => 'lorem ipsum ae cah cah la nggwe web angel eram hahahaha2' )); Todo::create(array( 'name' => 'Chris Sevilleja3', 'website' => 'http://www.youtube.com/', 'description' => 'lorem ipsum ae cah cah la nggwe web angel eram hahahaha3' )); Todo::create(array( 'name' => 'Chris Sevilleja4', 'website' => 'http://www.gmail.com/', 'description' => 'lorem ipsum ae cah cah la nggwe web angel eram hahahaha4' )); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function postStore() { $todo = Todo::findOrNew(1); $comment = new Comment(); $comment->body = 'xxxxxxxxxxxx'; $todo->comments()->save($comment); return; }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('todos')->delete(); $todos_entries = array(['body' => 'Learn Angular', 'completed' => 1], ['body' => 'Build Angular App', 'completed' => 0], ['body' => 'Buy Food', 'completed' => 0]); foreach ($todos_entries as $entry) { Todo::create($entry); } }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { if ($this->isUpdateRequest() or $this->isDeleteRequest()) { $id = $this->route('todo'); return Todo::where('id', $id)->where('user_id', $this->user()->id)->exists(); } return true; }
public function getTaskUndone($id) { $todo = Todo::find($id); $todo->status = 0; if ($todo->save()) { return redirect()->back()->with('msg', 'notoka'); } }
public function store(StoreTodoPostRequest $request) { $todo = Todo::findOrNew($request->id)->fill($request->all()); if (!empty($todo->text)) { $todo->save(); } return redirect()->back(); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $book = Todo::find($id); if (!$book) { return Response::json(['error' => ['message' => 'Not found!', 'status_code' => 404]], 404); } return $this->fractal->item($book, new BookTransformer()); }
public function deleteCompleted() { $todos = Todo::where('done', true)->get(); foreach ($todos as $todo) { $todo->delete(); } Event::fire(new TodoGetAllBack(Todo::where('done', false)->get(['id', 'text', 'done']))); }
public function store() { $workName = Input::get('workName'); $data = array('work' => $workName, 'status' => 'Incomplete'); $response = Todo::create($data); if ($response) { return redirect()->back(); } }
public function getDone($id) { if (Request::ajax()) { $task = Todo::find($id); $task->status = 1; $task->save(); return "OK"; } }
public function run() { $faker = Faker::create(); $users = User::lists('id'); $projects = Project::lists('id'); foreach (range(1, 50) as $index) { Todo::create(['user_id' => $faker->randomElement($users), 'project_id' => $faker->randomElement($projects), 'name' => $faker->word, 'completed' => $faker->boolean(), 'urgent' => $faker->boolean(), 'description' => $faker->sentence()]); } }
public function run() { $faker = $this->beginSeeding(new Todo()); $userIds = User::lists('id')->toArray(); foreach (range(1, 100) as $index) { Todo::create(['title' => $faker->sentence(), 'user_id' => $faker->randomElement($userIds), 'description' => $faker->randomElement([$faker->paragraph(), null]), 'done' => $faker->randomElement([0, 1])]); } $this->endSeeding(); }
public function delete($id) { try { $todo = Todo::findOrFail($id); $todo->delete(); return redirect('/')->with('deleteMessage', 'todo deleted successfully'); } catch (ModelNotFoundException $e) { return Response::json(['flag' => -1]); } }
public function delete($id) { try { $todo = Todo::findOrFail($id); $todo->delete(); return Response::json(['message' => 'todo deleted susseccfully']); } catch (ModelNotFoundException $e) { return Response::json(['flag' => -1]); } }
/** * Remove the specified resource from storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Appkr\Fractal\Response */ public function destroy(Request $request, $id) { if (!$this->model->whereId($id)->whereUserId($request->user()->id)->exists()) { return $this->respond->unauthorizedError(); } $todo = $this->model->findOrFail($id); if (!$todo->delete()) { return $this->respond->internalError(); } return $this->respond->success(strip_tags(trans('messages.deleted'))); }
public function get_labels_settings() { if (!Auth::user()) { //echo 'ingelogd'; return Redirect::route('user_login'); } $view = view::make("settings.labels"); $view->projects = Project::all(); $view->tasks = Todo::all(); return $view; }
public function destroy($id) { $user = JWTAuth::parseToken()->authenticate(); $todo = Todo::where('owner_id', $user->id)->where('id', $id)->first(); if ($todo) { Todo::destroy($todo->id); return response('Success', 200); } else { return response('Unauthoraized', 403); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { \Log::info($request->method()); $hasPermission = true; $method = $request->method(); if (strpos($request->path(), 'todo') !== false && ($method == 'PUT' || $method == 'DELETE')) { $id = $request->segment(2); $todo = Todo::find($id); $hasPermission = $todo ? Auth::user()->id == $todo->user_id : true; } return $hasPermission ? $next($request) : response('Unauthorized.', 401); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::table('todos')->delete(); Todo::create(['content' => 'buy some milk']); Todo::create(['content' => 'excercise']); Todo::create(['content' => 'leran Scheme']); Todo::create(['content' => 'configure nginx']); Todo::create(['content' => 'configure apache']); Todo::create(['content' => 'create behat test']); Model::reguard(); }