Skip to content

Commit

Permalink
Merge pull request #8 from TimothyMee/new-UI-and-some-new-features
Browse files Browse the repository at this point in the history
New ui and some new features
  • Loading branch information
Damiloju committed Apr 17, 2018
2 parents 7fdf34a + aaa01e5 commit 2152f4a
Show file tree
Hide file tree
Showing 28 changed files with 58,630 additions and 310 deletions.
9 changes: 9 additions & 0 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ protected function validator(array $data)
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
// 'image' => 'required|image64:jpeg,jpg,png',
]);
}

Expand All @@ -63,6 +64,14 @@ protected function validator(array $data)
*/
protected function create(array $data)
{
/*saving the image*/
// $imageData = $this->get('photo');
// $fileName = Carbon::now()->timestamp . '_' . uniqid() . '.' . explode('/', explode(':', substr($imageData, 0, strpos($imageData, ';')))[1])[1];
// $this->filepath = storage_path('app/public/students/' . $fileName);
// Image::make($this->get('photo'))->save($this->filepath);
// $filename = $fileName;


return User::create([
'name' => $data['name'],
'email' => $data['email'],
Expand Down
26 changes: 24 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace App\Http\Controllers;

use App\Equipments;
use App\Http\Requests;
use App\Office;
use App\Records;
use Illuminate\Http\Request;
use App\User;

Expand All @@ -23,8 +26,27 @@ public function __construct()
*
* @return \Illuminate\Http\Response
*/
public function index()
// public function index()
// {
// return view('home');
// }

public function index(Office $office, Equipments $equipments, User $user, Records $records)
{
return view('home');
$officeCount = $office->count();
$equipmentsCount = $equipments->count();
$userCount = $user->count();
$faultyCount = $records->where('active', 0)->count();
$recordsDetails = $records->with('office','user','equipments')->get();

$data = [
'officeCount' => $officeCount,
'equipmentsCount' => $equipmentsCount,
'userCount' => $userCount,
'faultyCount' => $faultyCount,
'records' => $recordsDetails
];

return view('home')->with('data', $data);
}
}
19 changes: 13 additions & 6 deletions app/Http/Controllers/OfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function index ()
return view('Office.index');
}

public function getOffices()
{
return $offices = Office::all();
}

/**
* @param Office $office
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
Expand All @@ -41,12 +46,14 @@ public function show (Office $office)
Eager Loads the office table with the records and equipments relationship
**/
$office->load('records.equipments');

JavaScript::put([
'office' => $office,
]);

return view('Office.show', compact('office'));
//
// JavaScript::put([
// 'office' => $office,
// ]);
//
// return view('Office.show', compact('office'));

return $office;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/RecordsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public function store (Office $office)
$messages = [
'name.required' => 'The equipment needs to have a name!',
'name.min:3' => 'The name of the equipment must have at least 3 characters',
'euipment.required' => 'Kindly state the amount to add!',
'euipment.numeric' => 'The amount should be a number',
'equipments.required' => 'Kindly state the amount to add!',
'equipments.numeric' => 'The amount should be a number',
];

$this->validate(request(), [
'name' => 'required|min:3',
'euipment_amount' => 'required|numeric',
'equipments_amount' => 'required|numeric',
],$messages);

$record = new Records;
Expand All @@ -87,13 +87,13 @@ public function store (Office $office)
$record->equipments_id = $equipment[0]->id;

$record->office_id = $office->id;
$record->euipments_amount = request()->euipment_amount;
$record->equipments_amount = request()->equipments_amount;
$record->user_id = Auth::user()->id;

$record->save();

flash()->custom('Sweet!', 'You Have Added An Equipment Successfully');
return redirect("office/$office->id");
return redirect("office");
}

public function show(Records $record)
Expand Down
7 changes: 4 additions & 3 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

Route::group(['middleware' => 'auth'], function () {
Route::get('office', 'OfficeController@index')->name('office');
Route::get('offices', 'OfficeController@getOffices');
Route::get('office/{office}', 'OfficeController@show');
Route::get('add/office', 'OfficeController@add');

Expand All @@ -29,10 +30,10 @@
Route::post('records/{office}/add', 'RecordsController@store');
Route::get('records/{record}', 'RecordsController@show');

Route::get('equipment/new', 'EquipmentController@add');
Route::get('equipment/new', 'EquipmentController@add')->name('equipment');
Route::post('equipment/new', 'EquipmentController@store');
});


Route::get('/', 'HomeController@index');
Route::get('/', 'HomeController@index')->name('home');
Route::get('/test', 'HomeController@test');

0 comments on commit 2152f4a

Please sign in to comment.