public function run()
 {
     $time_entries = array(['user_id' => 1, 'start_time' => '2015-02-21T18:56:48Z', 'end_time' => '2015-02-21T20:33:10Z', 'comment' => 'Initial project setup.'], ['user_id' => 1, 'start_time' => '2015-02-27T10:22:42Z', 'end_time' => '2015-02-27T14:08:10Z', 'comment' => 'Review of project requirements and notes for getting started.'], ['user_id' => 1, 'start_time' => '2015-03-03T09:55:32Z', 'end_time' => '2015-03-03T12:07:09Z', 'comment' => 'Front-end and backend setup.']);
     foreach ($time_entries as $time_entry) {
         TimeEntry::create($time_entry);
     }
 }
Exemplo n.º 2
0
 public function saveTrackerEntry(Request $request)
 {
     // return $request->all();
     $validator = Validator::make($request->all(), ['desc' => 'required|min:5', 'time' => 'required|numeric', 'tags' => 'required', 'project_id' => 'required']);
     if ($request->input('project_id') == 'Select Project') {
         Session::flash('flash_error', 'You need to select the project');
         return redirect()->back()->withInput();
     }
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     try {
         DB::beginTransaction();
         $project = Project::with('client')->find($request->input('project_id'));
         $entry = TimeEntry::create(['desc' => $request->input('desc'), 'user_id' => Auth::user()->id, 'project_id' => $project->id, 'project_name' => $project->name, 'client_name' => $project->client->name, 'time' => $request->input('time')]);
         // adding the entry of the ticket with tags mapping table
         foreach ($request->input('tags') as $key => $value) {
             DB::table('taggables')->insert(['tag_id' => $value, 'taggable_id' => $entry->id, 'taggable_type' => 'ticket', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
         }
         if ($request->input('estimate_id')) {
             DB::table('time_entry_estimates')->insert(['time_entry_id' => $entry->id, 'estimate_id' => $request->input('estimate_id'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
             DB::update("UPDATE estimates SET hours_consumed = hours_consumed + :hours WHERE id = :id", ['hours' => $request->input('time'), 'id' => $request->input('estimate_id')]);
         }
         DB::commit();
         Session::flash('flash_message', 'Entry saved');
         return redirect('time-tracker');
     } catch (\PDOException $e) {
         DB::rollBack();
         abort(403, 'Data was not saved. Try again' . $e->getMessage());
     }
 }
Exemplo n.º 3
0
 public function run()
 {
     DB::table('time_entries')->delete();
     $time_entries = array(['user_id' => 1, 'start_time' => '2015-02-21 18:56:48', 'end_time' => '2015-02-21 20:33:10', 'comment' => 'Initial project setup.'], ['user_id' => 2, 'start_time' => '2015-02-27 10:22:42', 'end_time' => '2015-02-27 14:08:10', 'comment' => 'Review of project requirements and notes for getting started.'], ['user_id' => 3, 'start_time' => '2015-03-03 09:55:32', 'end_time' => '2015-03-03 12:07:09', 'comment' => 'Front-end and backend setup.']);
     foreach ($time_entries as $time_entry) {
         TimeEntry::create($time_entry);
     }
 }
Exemplo n.º 4
0
 public function run()
 {
     DB::table('time_entries')->delete();
     $time_entries = array(['user_id' => 21, 'start_time' => '2015-02-21T18:56:48Z', 'end_time' => '2015-02-21T20:33:10Z', 'comment' => 'Comment Test 1.'], ['user_id' => 22, 'start_time' => '2015-02-27T10:22:42Z', 'end_time' => '2015-02-27T14:08:10Z', 'comment' => 'Comment Test 2.'], ['user_id' => 23, 'start_time' => '2015-03-03T09:55:32Z', 'end_time' => '2015-03-03T12:07:09Z', 'comment' => 'Comment Test 3.']);
     foreach ($time_entries as $time_entry) {
         TimeEntry::create($time_entry);
     }
 }