/** * Run the migrations. * * @return void */ public function up() { $tasks = \App\Models\Task::all(); foreach ($tasks as $task) { $startTime = strtotime($task->start_time); if (!$task->time_log || !count(json_decode($task->time_log))) { $task->time_log = json_encode([[$startTime, $startTime + $task->duration]]); $task->save(); } elseif ($task->getDuration() != intval($task->duration)) { $task->time_log = json_encode([[$startTime, $startTime + $task->duration]]); $task->save(); } } Schema::table('tasks', function ($table) { $table->dropColumn('start_time'); $table->dropColumn('duration'); $table->dropColumn('break_duration'); $table->dropColumn('resume_time'); }); Schema::table('users', function ($table) { $table->boolean('dark_mode')->default(false)->nullable(); }); Schema::table('users', function ($table) { $table->dropColumn('theme_id'); }); }
/* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('home.index'); }); // collection.fetch() Route::get('tasks', function () { $fetchTasks = Task::all(); return $fetchTasks; }); // model.fetch() Route::get('tasks/{id}', function ($id) { $tasks = Task::find($id); if ($tasks) { return json_encode($tasks); } else { abort(404); } }); // model.save() - if id exist Route::put('tasks/{id}', function ($id) { $input = Input::all(); $task = Task::find($id);
/** * @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response */ public function index() { $tasks = Task::all(); $response = ['code' => 200, 'message' => 'OK', 'data' => $tasks]; return response()->json($response, $response['code']); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $data['colors'] = array('red', 'yellow', 'aqua', 'blue', 'light-blue', 'green', 'navy', 'teal', 'olive', 'lime', 'orange', 'fuchsia', 'purple', 'maroon', 'black', 'red-active', 'yellow-active', 'aqua-active', 'blue-active', 'light-blue-active', 'green-active', 'navy-active', 'teal-active', 'olive-active', 'lime-active', 'orange-active', 'fuchsia-active', 'purple-active', 'maroon-active', 'black-active'); $data['card'] = $card = Card::get_card_result($id); if ($card) { $data['project'] = Project::find($card->project_id); $data['goals'] = Project::get_goals($card->project_id); $data['campgoals'] = Card::get_campgoals($id); $data['plannedcampgoals'] = Card::get_panned_campgoals($id); $data['partner'] = Card::get_partner($id, $card->sector_id); $data['partners'] = Card::get_partners($id, $card->sector_id); $data['camps'] = Camp::where('card_id', $id)->get()->toArray(); $data['selectedpartner'] = PartnerCards::where('card_id', $id)->first(); $data['cardtimelines'] = Timeline::getFinalCardTimeline($id, 2); $data['campcreatebtn'] = Permission::hasPermission('camps.create'); $data['campeditbtn'] = Permission::hasPermission('camps.edit'); $data['campdeletebtn'] = Permission::hasPermission('camps.delete'); $data['campimportbtn'] = Permission::hasPermission('camps.import'); $data['taskimportbtn'] = Permission::hasPermission('tasks.import'); $data['taskeditbtn'] = Permission::hasPermission('tasks.edit'); $data['taskcreatebtn'] = Permission::hasPermission('tasks.create'); $data['taskdeletebtn'] = Permission::hasPermission('tasks.delete'); $data['tasklistbtn'] = Permission::hasPermission('tasks.index'); $data['campviewbtn'] = Permission::hasPermission('camps.show'); $data['tasks'] = Task::all(); return view('cards.view', $data); } else { Session::flash('danger', Lang::get('ruban.card.notfound')); return Redirect::route('ruban.cards.index'); } }
public function index() { $tasks = Task::all(); return response()->json(['status' => 'success', 'data' => $tasks]); }