Skip to content

Commit

Permalink
merge master into caldav
Browse files Browse the repository at this point in the history
  • Loading branch information
carduz committed Dec 2, 2015
2 parents c348e1b + d442898 commit 9eac780
Show file tree
Hide file tree
Showing 22 changed files with 41 additions and 331 deletions.
14 changes: 12 additions & 2 deletions app/Employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @property-read \plunner\Company $company
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Group[] $groups
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Meeting[] $meetings
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Calendar[] $calendars
* @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Calendar[] $calendars
* @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereId($value)
* @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereName($value)
* @method static \Illuminate\Database\Query\Builder|\plunner\Employee whereEmail($value)
Expand Down Expand Up @@ -108,7 +108,17 @@ public function calendars()
*/
public function getEmailForPasswordReset()
{
return $this->email.$this->company->id;
list(, $caller) = debug_backtrace(false);
if(isset($caller['class']))
$caller = explode('\\', $caller['class']);
else
$caller = '';

//check if this function is called by email sender
if ((count($caller) && $caller[count($caller) - 1] == 'PasswordBroker') || (defined('HHVM_VERSION') && $caller == ''))
return $this->email;
//return unique identify for token repository
return $this->email . $this->company->id;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Group extends Model
/**
* @var array
*/
protected $hidden = ['planner'];
protected $hidden = ['planner', 'pivot'];

/**
* @var array
Expand All @@ -60,6 +60,7 @@ public function getPlannerNameAttribute()
{
if(is_object($this->planner) && $this->planner->exists)
return $this->planner->name;
return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Companies/Auth/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public function __construct()
{
config(['auth.model' => \plunner\Company::class]);
config(['jwt.user' => \plunner\Company::class]);
config(['auth.password.table' => 'password_resets_companies']);
config(['auth.password.table' => 'password_resets_companies', 'auth.password.email' => 'emails.companies.password']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function index()
* @var $company Company
*/
$company = \Auth::user();
return $company->employees;
return $company->employees()->with('groups.planner')->get();
}

/**
Expand All @@ -53,6 +53,8 @@ public function store(EmployeeRequest $request)
//
$company = \Auth::user();
$input = $request->all();
if(isset($input['password']))
$input['password'] = bcrypt($input['password']);
$employee = $company->employees()->create($input);
return $employee;
}
Expand All @@ -66,7 +68,7 @@ public function store(EmployeeRequest $request)
public function show($id)
{
//
$employee = Employee::findOrFail($id);
$employee = Employee::with('groups.planner')->findOrFail($id);
$this->authorize($employee);
return $employee;
}
Expand All @@ -84,6 +86,8 @@ public function update(EmployeeRequest $request, $id)
$employee = Employee::findOrFail($id);
$this->authorize($employee);
$input = $request->all();
if(isset($input['password']))
$input['password'] = bcrypt($input['password']);
$employee->update($input);
return $employee;
}
Expand Down
84 changes: 0 additions & 84 deletions app/Http/Controllers/Companies/ExampleController.php

This file was deleted.

5 changes: 3 additions & 2 deletions app/Http/Controllers/Companies/Groups/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function index()
* @var $company Company
*/
$company = \Auth::user();
return $company->groups;
$groups = $company->groups()->with('planner')->get();
return $groups;
}

/**
Expand All @@ -63,7 +64,7 @@ public function store(GroupRequest $request)
*/
public function show($id)
{
$group = Group::findOrFail($id);
$group = Group::with('planner')->findOrFail($id);
$this->authorize($group);
return $group;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Employees/Auth/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct()
{
config(['auth.model' => \plunner\Employee::class]);
config(['jwt.user' => \plunner\Employee::class]);
config(['auth.password.table' => 'password_resets_employees']);
config(['auth.password.table' => 'password_resets_employees', 'auth.password.email' => 'emails.employees.password']);
}

public function postEmail(Request $request)
Expand Down
87 changes: 0 additions & 87 deletions app/Http/Controllers/Employees/EmployeesController.php

This file was deleted.

89 changes: 0 additions & 89 deletions app/Http/Controllers/Employees/GroupsController.php

This file was deleted.

Loading

0 comments on commit 9eac780

Please sign in to comment.