Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2531404
Added datatable
nasrulhazim Feb 21, 2018
6ac4a57
Added Datatable
nasrulhazim Feb 21, 2018
407a7a0
Added Tab Component
nasrulhazim Feb 21, 2018
60316f7
Added Modal Component
nasrulhazim Feb 21, 2018
05ff17a
Added Avatar Component
nasrulhazim Feb 21, 2018
b7f135d
Added Yajra Datatable
nasrulhazim Feb 21, 2018
3926385
Update dependencies
nasrulhazim Apr 24, 2018
f5ea6f3
Upgrade Front End Assets
nasrulhazim Apr 24, 2018
98a4313
Setup Passport
nasrulhazim Apr 24, 2018
2b4486b
Done Setup Laravel Passport
nasrulhazim Apr 24, 2018
a9824a1
Refactor Components - Card, Datatable, Table and Tooltip.
nasrulhazim Apr 24, 2018
014c92b
Added Datatable Route
nasrulhazim Apr 24, 2018
bbfde75
Ignore all .md files except README.md
nasrulhazim Apr 24, 2018
e0da637
Update ACL Setup to have developer roles, added permissions and actions.
nasrulhazim Apr 24, 2018
a95f3c7
Added storage:link, passport:install and added option -d for developm…
nasrulhazim Apr 24, 2018
15ea1d7
Added Development Seeder
nasrulhazim Apr 24, 2018
74b89c6
Display app name if not login in navbar.
nasrulhazim Apr 24, 2018
4b46304
Added user() helper
nasrulhazim Apr 24, 2018
32dfbc9
Create Developer Menu
nasrulhazim Apr 24, 2018
ec37ccc
Only Allow Passport for Developer
nasrulhazim Apr 24, 2018
96ea280
Added Laravel Debug Bar
nasrulhazim Apr 24, 2018
fb9fdd1
Added role & permission middleware
nasrulhazim Apr 24, 2018
10d819c
Update PHP Code Fixer Config
nasrulhazim Apr 24, 2018
4ae7420
Apply PHP CS Fixer
nasrulhazim Apr 24, 2018
87f360f
Remove todo
nasrulhazim Apr 24, 2018
1daa1e5
Update README
nasrulhazim Apr 24, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ Homestead.yaml
npm-debug.log
yarn-error.log
.env
*.md
!README.md
15 changes: 13 additions & 2 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $finder = PhpCsFixer\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->notPath('node_modules')
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
Expand All @@ -13,12 +14,22 @@ $finder = PhpCsFixer\Finder::create()
return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'binary_operator_spaces' => ['default' => 'align'],
'class_definition' => [
'multiLineExtendsEachSingleLine' => true,
],
'ordered_class_elements' => [
'use_trait', 'constant_public', 'constant_protected', 'constant_private',
'property_public', 'property_protected', 'property_private', 'construct',
'destruct', 'magic', 'phpunit', 'method_public', 'method_protected',
'method_private'
],
'binary_operator_spaces' => ['default' => 'align_single_space_minimal'],
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'blank_line_after_namespace' => true,
'linebreak_after_opening_tag' => true,
'not_operator_with_successor_space' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
))
->setFinder($finder);
->setFinder($finder);
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,35 @@ Create [Google Service Account Credentials](https://console.developers.google.co

## Usage

### User Accounts

By default, there's no users created. But you can run `php artisan db:seed DevelopmentSeeder` to run create 3 main users - Developer, Administrator and User.

Login details for default users:

1. E-mail : **developer@app.com** Password: `developer`
2. E-mail : **administrator@app.com** Password: `administrator`
3. 1. E-mail : **user@app.com** Password: `user`

By default, all newly registered user will be assign role as `user`.

### Access Control

Access control for the application can be configure from `config/acl.php`. It consist of `roles`, `permissions` and `actions`. Default seeder for ACL is in `database/seeds/RolesAndPermissionsSeeder.php`. You may overwrite this as you please.

Seeded roles and permissions based on `database/seeds/RolesAndPermissionsSeeder.php` will have all guards specify in `config/auth.php`.

### Commands

There's some commands area ready built-in. Others, may refer to respective packages.

- `reload:db` - Run `migrate:fresh --seed` with `profile:seed`. You may extend the usage.
- `reload:cache` - Recache everything
- `reload:all` - Run above two commands. Passing `-d` will seed `DevelopementSeeder` - useful for development setup.

### API

This boilerplate make use of Laravel Passport. Managing passport only allowed in for role developer. You can overwrite this behaviour in `routes/web.php`.

### Helpers

Expand Down Expand Up @@ -192,6 +215,10 @@ Simply record audit trail on given `$model`, with proper `$message`. You can opt
]
```

**user()**

The `user()` helper simply return the current logged in user object. The helper will take care your guard.

## Test

To run the test, type `vendor/bin/phpunit` in your terminal.
Expand Down
13 changes: 12 additions & 1 deletion app/Console/Commands/ReloadAllCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class ReloadAllCommand extends Command
*
* @var string
*/
protected $signature = 'reload:all';
protected $signature = 'reload:all
{--d|dev : Seed development data}';

/**
* The console command description.
Expand All @@ -37,5 +38,15 @@ public function handle()
{
$this->call('reload:cache');
$this->call('reload:db');
$this->call('storage:link');
$this->call('passport:install', [
'--force' => true,
]);

if ($this->option('dev')) {
$this->call('db:seed', [
'--class' => 'DevelopmentSeeder',
]);
}
}
}
2 changes: 2 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@ class Kernel extends HttpKernel
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
];
}
3 changes: 2 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable implements HasMediaConversions
{
use HasProfile, HasMediaExtended, HasThumbnail, HasRoles, HasSlugExtended, LogsActivityExtended, Notifiable, SoftDeletes;
use HasApiTokens, HasProfile, HasMediaExtended, HasThumbnail, HasRoles, HasSlugExtended, LogsActivityExtended, Notifiable, SoftDeletes;

/**
* Guarded Field.
Expand Down
2 changes: 1 addition & 1 deletion app/Observers/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Kernel
protected $observeBy = [
\App\Observers\ReferenceObserver::class => [
],
\App\Observers\HashidsObserver::class => [
\App\Observers\HashidsObserver::class => [
\App\Models\User::class,
\Spatie\MediaLibrary\Media::class,
],
Expand Down
14 changes: 7 additions & 7 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public function boot()
$this->bootProviders();
}

/**
* Register any application services.
*/
public function register()
{
}

/**
* Boot Providers Based On Environments.
*/
Expand All @@ -26,11 +33,4 @@ private function bootProviders()
$this->app->register($provider);
});
}

/**
* Register any application services.
*/
public function register()
{
}
}
3 changes: 3 additions & 0 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Laravel\Passport\Passport;

class AuthServiceProvider extends ServiceProvider
{
Expand All @@ -21,5 +22,7 @@ class AuthServiceProvider extends ServiceProvider
public function boot()
{
$this->registerPolicies();

Passport::routes();
}
}
8 changes: 4 additions & 4 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $listen = [
'Illuminate\Auth\Events\Registered' => [
'Illuminate\Auth\Events\Registered' => [
'App\Listeners\AssignDefaultRole',
],
'Illuminate\Auth\Events\Login' => [
'Illuminate\Auth\Events\Login' => [
'App\Listeners\LogSuccessfulLogin',
],
'Illuminate\Auth\Events\Failed' => [
'Illuminate\Auth\Events\Failed' => [
'App\Listeners\LogFailedLogin',
],
'Illuminate\Auth\Events\Logout' => [
'Illuminate\Auth\Events\Logout' => [
'App\Listeners\LogSuccessfulLogout',
],
'Illuminate\Auth\Events\PasswordReset' => [
Expand Down
15 changes: 14 additions & 1 deletion app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,20 @@ protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->namespace($this->namespace . '\Api')
->group(base_path('routes/api.php'));
}

/**
* Define the "datatable" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapDatatableRoutes()
{
Route::prefix('datatable')
->middleware('api')
->namespace($this->namespace . '\Api\Datatable')
->group(base_path('routes/datatable.php'));
}
}
16 changes: 16 additions & 0 deletions app/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,19 @@ function audit($model, $message, $causedBy = null)
}
}
}

/*
* user() helper
*/
if (! function_exists('user')) {
function user()
{
foreach (config('auth.guards') as $key => $value) {
if (Auth::guard($key)->check()) {
return Auth::guard($key)->user();
}
}

return null;
}
}
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
"cleaniquecoders/blueprint-macro": "^1.0",
"cleaniquecoders/profile": "^1.0",
"davejamesmiller/laravel-breadcrumbs": "^5.0",
"doctrine/dbal": "^2.7",
"fideloper/proxy": "~4.0",
"hashids/hashids": "^2.0",
"laravel/framework": "5.6.*",
"laravel/passport": "^6.0",
"laravel/tinker": "~1.0",
"predis/predis": "^1.1",
"softon/sweetalert": "^1.0",
Expand All @@ -27,9 +29,11 @@
"spatie/laravel-permission": "^2.7",
"spatie/laravel-referer": "^1.3",
"spatie/laravel-responsecache": "^4.1",
"spatie/laravel-sluggable": "^2.1"
"spatie/laravel-sluggable": "^2.1",
"yajra/laravel-datatables": "^1.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.1",
"codedungeon/phpunit-result-printer": "^0.6.0",
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
Expand Down
Loading