Skip to content

Commit

Permalink
trackings controller modified to enable adding initial shipment histo…
Browse files Browse the repository at this point in the history
…ry to database
  • Loading branch information
iamwebwiz committed Dec 13, 2017
1 parent c36abd1 commit 00d62da
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 62 deletions.
8 changes: 8 additions & 0 deletions app/Http/Controllers/TrackingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\ShipmentHistory;
use Illuminate\Http\Request;

class TrackingsController extends Controller
Expand Down Expand Up @@ -55,6 +56,13 @@ public function addNewTracking(Request $request)
$tracking->shipment_status = $request->shipment_status;

if ($tracking->save()) {
$history = new ShipmentHistory;
$history->location = $request->shipping_location;
$history->date = $request->shipping_date;
$history->time = $request->shipping_time;
$history->status = $request->shipping_status;
$tracking->shipmentHistories()->save($history);

return redirect()->route('showAllTrackings')->with('success', 'Tracking Added Successfully!');
}
return back()->with('err', 'Oops, An Error Occured!');
Expand Down
10 changes: 8 additions & 2 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
Expand All @@ -21,6 +22,11 @@ public function up()
$table->rememberToken();
$table->timestamps();
});

DB::table('users')->insert([
'name' => 'Administrator',
'email' => '[email protected]',
'password' => bcrypt('control')]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function up()
$table->unsignedInteger('tracking_id');
$table->string('location');
$table->timestamp('date');
$table->timestamp('time');
$table->time('time');
$table->string('status');
$table->timestamps();
});
Expand Down
4 changes: 2 additions & 2 deletions database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
$this->call(UsersTableSeeder::class);
$this->call(TrackingsTableSeeder::class);
// $this->call(UsersTableSeeder::class);
// $this->call(TrackingsTableSeeder::class);
}
}
37 changes: 0 additions & 37 deletions database/seeds/TrackingsTableSeeder.php

This file was deleted.

20 changes: 0 additions & 20 deletions database/seeds/UsersTableSeeder.php

This file was deleted.

0 comments on commit 00d62da

Please sign in to comment.