Skip to content

Commit

Permalink
Merge pull request #10 from specialtactics/analysis-86P2nl
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
specialtactics authored Mar 21, 2019
2 parents 8bdeb31 + a501f99 commit 89ca41b
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 40 deletions.
1 change: 0 additions & 1 deletion app/Exceptions/ApiExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* This class extends the Dingo API Exception Handler, and can be used to modify it's functionality, if required
*
* Class ApiHandler
* @package App\Exceptions
*/
class ApiExceptionHandler extends RestfulApiExceptionHandler
{
Expand Down
2 changes: 1 addition & 1 deletion app/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class BaseModel extends RestfulModel
{
/**
/*
* Add your own base customisation here
*/
}
19 changes: 12 additions & 7 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class User extends BaseModel implements
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'primary_role'
'name', 'email', 'password', 'primary_role',
];

/**
Expand Down Expand Up @@ -69,7 +69,8 @@ public static function boot()
*
* @return array Rules
*/
public function getValidationRules() {
public function getValidationRules()
{
return [
'email' => 'email|max:255|unique:users',
'name' => 'required|min:3',
Expand All @@ -82,7 +83,8 @@ public function getValidationRules() {
*
* @return \Illuminate\Database\Eloquent\Relations\belongsTo
*/
public function primaryRole() {
public function primaryRole()
{
return $this->belongsTo(Role::class, 'primary_role');
}

Expand All @@ -91,14 +93,16 @@ public function primaryRole() {
*
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
*/
public function roles() {
public function roles()
{
return $this->belongsToMany(Role::class, 'user_roles', 'user_id', 'role_id');
}

/**
* Get all user's roles
*/
public function getRoles() {
public function getRoles()
{
$allRoles = array_merge(
[
$this->primaryRole->name,
Expand All @@ -114,7 +118,8 @@ public function getRoles() {
*
* @return bool
*/
public function isAdmin() {
public function isAdmin()
{
return $this->primaryRole->name == Role::ROLE_ADMIN;
}

Expand Down Expand Up @@ -142,7 +147,7 @@ public function getJWTCustomClaims()
'id' => $this->getKey(),
'name' => $this->name,
'primaryRole' => $this->primaryRole->name,
]
],
];
}

Expand Down
7 changes: 2 additions & 5 deletions app/Services/RestfulService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace App\Services;

use \Specialtactics\L5Api\Services\RestfulService as VendorRestfulService;
use Specialtactics\L5Api\Services\RestfulService as VendorRestfulService;

/**
* Class RestfulService
*
* Your can extend the RestfulService functionality here
*
* @package App\Services
*/
class RestfulService extends VendorRestfulService
{

}
}
3 changes: 1 addition & 2 deletions app/Transformers/BaseTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

class BaseTransformer extends RestfulTransformer
{

}
}
2 changes: 1 addition & 1 deletion config/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
'indent_style' => env('API_JSON_FORMAT_INDENT_STYLE', 'space'),
'indent_size' => env('API_JSON_FORMAT_INDENT_SIZE', 2),
],
'caseType' => env ('API_CASE_TYPE', 'camel-case'),
'caseType' => env('API_CASE_TYPE', 'camel-case'),
],

];
18 changes: 12 additions & 6 deletions database/seeds/BaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

use Illuminate\Database\Seeder;

class BaseSeeder extends Seeder {
class BaseSeeder extends Seeder
{
/**
* @var null Faker instance
*/
Expand Down Expand Up @@ -41,38 +42,43 @@ public function run()
*
* @return void
*/
public function runFake() {
public function runFake()
{
}

/**
* Run seeds to be ran only on production environments
*
* @return void
*/
public function runProduction() {
public function runProduction()
{
}

/**
* Run seeds to be ran on every environment (including production)
*
* @return void
*/
public function runAlways() {
public function runAlways()
{
}

/**
* Run before all any seeding
*
* @return void
*/
public function before() {
public function before()
{
}

/**
* Run after all seeding
*
* @return void
*/
public function after() {
public function after()
{
}
}
9 changes: 6 additions & 3 deletions database/seeds/RoleTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

class RoleTableSeeder extends BaseSeeder
{
public function runAlways() {
public function runAlways()
{
Role::firstOrCreate([
'name' => 'admin',
'description' => 'Administrator Users',
]);
}

public function runFake() {
public function runFake()
{
for ($i = 0; $i < 10; ++$i) {
Role::firstOrCreate([
'name' => $this->faker->unique()->word(),
Expand All @@ -27,7 +29,8 @@ public function runFake() {
* @param $count int How many roles to get
* @return Illuminate\Support\Collection
*/
public static function getRandomRoles($count) {
public static function getRandomRoles($count)
{
$roles = Role::all();

$fakeRoles = [];
Expand Down
4 changes: 2 additions & 2 deletions database/seeds/UserStorySeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

class UserStorySeeder extends BaseSeeder
{
public function runFake() {
public function runFake()
{
// Grab all roles for reference
$roles = Role::all();

Expand All @@ -30,6 +31,5 @@ public function runFake() {
$user->roles()->save($fakeRolesToAssign->shift());
}
}

}
}
2 changes: 0 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/

define('LARAVEL_START', microtime(true));

/*
Expand Down
13 changes: 6 additions & 7 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
return $request->user();
});

/**
/*
* Welcome route - link to any public API documentation here
*/
Route::get('/', function () {
echo 'Welcome to our API';
});


/**
* @var $api \Dingo\Api\Routing\Router
*/
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', ['middleware' => ['api']], function ($api) {
/**
/*
* Authentication
*/
$api->group(['prefix' => 'auth'], function ($api) {
Expand All @@ -39,11 +38,11 @@
});
});

/**
/*
* Authenticated routes
*/
$api->group(['middleware' => ['api.auth']], function ($api) {
/**
/*
* Authentication
*/
$api->group(['prefix' => 'auth'], function ($api) {
Expand All @@ -55,7 +54,7 @@
$api->get('/me', 'App\Http\Controllers\Auth\AuthController@getUser');
});

/**
/*
* Users
*/
$api->group(['prefix' => 'users', 'middleware' => 'check_role:admin'], function ($api) {
Expand All @@ -67,7 +66,7 @@
$api->delete('/{uuid}', 'App\Http\Controllers\UserController@delete');
});

/**
/*
* Roles
*/
$api->group(['prefix' => 'roles'], function ($api) {
Expand Down
1 change: 0 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
| contains the "web" middleware group. Now create something great!
|
*/

2 changes: 0 additions & 2 deletions server.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/

$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
Expand Down

0 comments on commit 89ca41b

Please sign in to comment.