Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some refactoring to accomodate new updates
- Loading branch information
1 parent
7e69f3d
commit c354dfa
Showing
25 changed files
with
615 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\UserType; | ||
use Illuminate\Http\Request; | ||
|
||
class UserTypeController extends Controller | ||
{ | ||
// | ||
|
||
public function index() | ||
{ | ||
return view('user_type.index'); | ||
} | ||
|
||
public function add(Request $request, UserType $userType) | ||
{ | ||
try | ||
{ | ||
$result = $userType->createNew($request->all()); | ||
return apiSuccess($result); | ||
} | ||
catch (\Exception $e) | ||
{ | ||
return apiFailure($e); | ||
} | ||
} | ||
|
||
|
||
public function delete(Request $request, UserType $userType) | ||
{ | ||
try | ||
{ | ||
$result = $userType->deleteRole($request->all()); | ||
return apiSuccess($result); | ||
} | ||
catch (\Exception $e) | ||
{ | ||
return apiFailure($e); | ||
} | ||
} | ||
|
||
public function viewRoles(UserType $userType) | ||
{ | ||
try | ||
{ | ||
$result = $userType->viewAll(); | ||
return apiSuccess($result); | ||
} | ||
catch (\Exception $e) | ||
{ | ||
return apiFailure($e); | ||
} | ||
} | ||
|
||
public function viewRole(Request $request, UserType $userType) | ||
{ | ||
try | ||
{ | ||
$result = $userType->view($request->all()); | ||
return apiSuccess($result); | ||
} | ||
catch (\Exception $e) | ||
{ | ||
return apiFailure($e); | ||
} | ||
} | ||
|
||
public function edit(Request $request, UserType $userType) | ||
{ | ||
try | ||
{ | ||
$result = $userType->updateRole($request->all()); | ||
return apiSuccess($result); | ||
} | ||
catch (\Exception $e) | ||
{ | ||
return apiFailure($e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class UserType extends Model | ||
{ | ||
protected $fillable = ['name', 'description', 'staff_id']; | ||
// | ||
|
||
public function createNew($data) | ||
{ | ||
isset($data['staff_id']) ? $data['staff_id'] : $data['staff_id'] = auth()->id(); | ||
return $this->create($data); | ||
} | ||
|
||
public function deleteRole($data) | ||
{ | ||
return $this->delete($data); | ||
} | ||
|
||
public function view(Array $requests) | ||
{ | ||
foreach ($requests as $request) | ||
{ | ||
$results[] = $this->where('id', $request)->get(); | ||
} | ||
|
||
return $results; | ||
} | ||
|
||
public function viewAll() | ||
{ | ||
$result = $this->all(); | ||
return $result; | ||
} | ||
|
||
public function updateRole($data) | ||
{ | ||
$data['staff_id'] = auth()->id(); | ||
return $this->where('id', $data['id']) | ||
->update([ | ||
'name' => $data['name'], | ||
'description' => $data['description'], | ||
'staff_id' => $data['staff_id'] | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class parent extends Model | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
database/migrations/2018_01_15_131540_add_staff_id_to_roles_table.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.