Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit ed6969b

Browse files
authored
Merge pull request #9 from cleaniquecoders/develop
Major updates
2 parents 295f33c + 1daa1e5 commit ed6969b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+6657
-2856
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ Homestead.yaml
1010
npm-debug.log
1111
yarn-error.log
1212
.env
13+
*.md
14+
!README.md

.php_cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ $finder = PhpCsFixer\Finder::create()
33
->notPath('bootstrap/cache')
44
->notPath('storage')
55
->notPath('vendor')
6+
->notPath('node_modules')
67
->in(__DIR__)
78
->name('*.php')
89
->notName('*.blade.php')
@@ -13,12 +14,22 @@ $finder = PhpCsFixer\Finder::create()
1314
return PhpCsFixer\Config::create()
1415
->setRules(array(
1516
'@Symfony' => true,
16-
'binary_operator_spaces' => ['default' => 'align'],
17+
'class_definition' => [
18+
'multiLineExtendsEachSingleLine' => true,
19+
],
20+
'ordered_class_elements' => [
21+
'use_trait', 'constant_public', 'constant_protected', 'constant_private',
22+
'property_public', 'property_protected', 'property_private', 'construct',
23+
'destruct', 'magic', 'phpunit', 'method_public', 'method_protected',
24+
'method_private'
25+
],
26+
'binary_operator_spaces' => ['default' => 'align_single_space_minimal'],
1727
'array_syntax' => ['syntax' => 'short'],
1828
'concat_space' => ['spacing' => 'one'],
29+
'blank_line_after_namespace' => true,
1930
'linebreak_after_opening_tag' => true,
2031
'not_operator_with_successor_space' => true,
2132
'ordered_imports' => true,
2233
'phpdoc_order' => true,
2334
))
24-
->setFinder($finder);
35+
->setFinder($finder);

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,35 @@ Create [Google Service Account Credentials](https://console.developers.google.co
5353

5454
## Usage
5555

56+
### User Accounts
57+
58+
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.
59+
60+
Login details for default users:
61+
62+
1. E-mail : **[email protected]** Password: `developer`
63+
2. E-mail : **[email protected]** Password: `administrator`
64+
3. 1. E-mail : **[email protected]** Password: `user`
65+
66+
By default, all newly registered user will be assign role as `user`.
67+
68+
### Access Control
69+
70+
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.
71+
72+
Seeded roles and permissions based on `database/seeds/RolesAndPermissionsSeeder.php` will have all guards specify in `config/auth.php`.
73+
5674
### Commands
5775

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

6078
- `reload:db` - Run `migrate:fresh --seed` with `profile:seed`. You may extend the usage.
6179
- `reload:cache` - Recache everything
80+
- `reload:all` - Run above two commands. Passing `-d` will seed `DevelopementSeeder` - useful for development setup.
81+
82+
### API
83+
84+
This boilerplate make use of Laravel Passport. Managing passport only allowed in for role developer. You can overwrite this behaviour in `routes/web.php`.
6285

6386
### Helpers
6487

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

218+
**user()**
219+
220+
The `user()` helper simply return the current logged in user object. The helper will take care your guard.
221+
195222
## Test
196223

197224
To run the test, type `vendor/bin/phpunit` in your terminal.

app/Console/Commands/ReloadAllCommand.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class ReloadAllCommand extends Command
1111
*
1212
* @var string
1313
*/
14-
protected $signature = 'reload:all';
14+
protected $signature = 'reload:all
15+
{--d|dev : Seed development data}';
1516

1617
/**
1718
* The console command description.
@@ -37,5 +38,15 @@ public function handle()
3738
{
3839
$this->call('reload:cache');
3940
$this->call('reload:db');
41+
$this->call('storage:link');
42+
$this->call('passport:install', [
43+
'--force' => true,
44+
]);
45+
46+
if ($this->option('dev')) {
47+
$this->call('db:seed', [
48+
'--class' => 'DevelopmentSeeder',
49+
]);
50+
}
4051
}
4152
}

app/Http/Kernel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ class Kernel extends HttpKernel
5858
'can' => \Illuminate\Auth\Middleware\Authorize::class,
5959
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
6060
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
61+
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
62+
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
6163
];
6264
}

app/Models/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
use Illuminate\Database\Eloquent\SoftDeletes;
1111
use Illuminate\Foundation\Auth\User as Authenticatable;
1212
use Illuminate\Notifications\Notifiable;
13+
use Laravel\Passport\HasApiTokens;
1314
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;
1415
use Spatie\Permission\Traits\HasRoles;
1516

1617
class User extends Authenticatable implements HasMediaConversions
1718
{
18-
use HasProfile, HasMediaExtended, HasThumbnail, HasRoles, HasSlugExtended, LogsActivityExtended, Notifiable, SoftDeletes;
19+
use HasApiTokens, HasProfile, HasMediaExtended, HasThumbnail, HasRoles, HasSlugExtended, LogsActivityExtended, Notifiable, SoftDeletes;
1920

2021
/**
2122
* Guarded Field.

app/Observers/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Kernel
2121
protected $observeBy = [
2222
\App\Observers\ReferenceObserver::class => [
2323
],
24-
\App\Observers\HashidsObserver::class => [
24+
\App\Observers\HashidsObserver::class => [
2525
\App\Models\User::class,
2626
\Spatie\MediaLibrary\Media::class,
2727
],

app/Providers/AppServiceProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ public function boot()
1515
$this->bootProviders();
1616
}
1717

18+
/**
19+
* Register any application services.
20+
*/
21+
public function register()
22+
{
23+
}
24+
1825
/**
1926
* Boot Providers Based On Environments.
2027
*/
@@ -26,11 +33,4 @@ private function bootProviders()
2633
$this->app->register($provider);
2734
});
2835
}
29-
30-
/**
31-
* Register any application services.
32-
*/
33-
public function register()
34-
{
35-
}
3636
}

app/Providers/AuthServiceProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Providers;
44

55
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
6+
use Laravel\Passport\Passport;
67

78
class AuthServiceProvider extends ServiceProvider
89
{
@@ -21,5 +22,7 @@ class AuthServiceProvider extends ServiceProvider
2122
public function boot()
2223
{
2324
$this->registerPolicies();
25+
26+
Passport::routes();
2427
}
2528
}

app/Providers/EventServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ class EventServiceProvider extends ServiceProvider
1313
* @var array
1414
*/
1515
protected $listen = [
16-
'Illuminate\Auth\Events\Registered' => [
16+
'Illuminate\Auth\Events\Registered' => [
1717
'App\Listeners\AssignDefaultRole',
1818
],
19-
'Illuminate\Auth\Events\Login' => [
19+
'Illuminate\Auth\Events\Login' => [
2020
'App\Listeners\LogSuccessfulLogin',
2121
],
22-
'Illuminate\Auth\Events\Failed' => [
22+
'Illuminate\Auth\Events\Failed' => [
2323
'App\Listeners\LogFailedLogin',
2424
],
25-
'Illuminate\Auth\Events\Logout' => [
25+
'Illuminate\Auth\Events\Logout' => [
2626
'App\Listeners\LogSuccessfulLogout',
2727
],
2828
'Illuminate\Auth\Events\PasswordReset' => [

0 commit comments

Comments
 (0)