@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\V1\Notifications\Notification::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
4 | + return [ |
|
5 | 5 | 'type' => '', |
6 | 6 | 'notifiable_type' => '', |
7 | 7 | 'notifiable_id' => '', |
@@ -9,5 +9,5 @@ discard block |
||
9 | 9 | 'read_at' => null, |
10 | 10 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
11 | 11 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
12 | - ]; |
|
12 | + ]; |
|
13 | 13 | }); |
14 | 14 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\V1\Notifications\Notification::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\V1\Notifications\Notification::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'type' => '', |
6 | 6 | 'notifiable_type' => '', |
@@ -6,30 +6,30 @@ |
||
6 | 6 | |
7 | 7 | class Notifications extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('notifications', function (Blueprint $table) { |
|
17 | - $table->uuid('id')->primary(); |
|
18 | - $table->string('type'); |
|
19 | - $table->morphs('notifiable'); |
|
20 | - $table->text('data'); |
|
21 | - $table->timestamp('read_at')->nullable(); |
|
22 | - $table->timestamps(); |
|
23 | - }); |
|
24 | - } |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('notifications', function (Blueprint $table) { |
|
17 | + $table->uuid('id')->primary(); |
|
18 | + $table->string('type'); |
|
19 | + $table->morphs('notifiable'); |
|
20 | + $table->text('data'); |
|
21 | + $table->timestamp('read_at')->nullable(); |
|
22 | + $table->timestamps(); |
|
23 | + }); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Reverse the migrations. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function down() |
|
32 | - { |
|
33 | - Schema::dropIfExists('notifications'); |
|
34 | - } |
|
26 | + /** |
|
27 | + * Reverse the migrations. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function down() |
|
32 | + { |
|
33 | + Schema::dropIfExists('notifications'); |
|
34 | + } |
|
35 | 35 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('notifications', function (Blueprint $table) { |
|
16 | + Schema::create('notifications', function(Blueprint $table) { |
|
17 | 17 | $table->uuid('id')->primary(); |
18 | 18 | $table->string('type'); |
19 | 19 | $table->morphs('notifiable'); |
@@ -6,30 +6,30 @@ |
||
6 | 6 | |
7 | 7 | class CreateFailedJobsTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('failed_jobs', function (Blueprint $table) { |
|
17 | - $table->bigIncrements('id'); |
|
18 | - $table->text('connection'); |
|
19 | - $table->text('queue'); |
|
20 | - $table->longText('payload'); |
|
21 | - $table->longText('exception'); |
|
22 | - $table->timestamp('failed_at')->useCurrent(); |
|
23 | - }); |
|
24 | - } |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('failed_jobs', function (Blueprint $table) { |
|
17 | + $table->bigIncrements('id'); |
|
18 | + $table->text('connection'); |
|
19 | + $table->text('queue'); |
|
20 | + $table->longText('payload'); |
|
21 | + $table->longText('exception'); |
|
22 | + $table->timestamp('failed_at')->useCurrent(); |
|
23 | + }); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Reverse the migrations. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function down() |
|
32 | - { |
|
33 | - Schema::dropIfExists('failed_jobs'); |
|
34 | - } |
|
26 | + /** |
|
27 | + * Reverse the migrations. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function down() |
|
32 | + { |
|
33 | + Schema::dropIfExists('failed_jobs'); |
|
34 | + } |
|
35 | 35 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('failed_jobs', function (Blueprint $table) { |
|
16 | + Schema::create('failed_jobs', function(Blueprint $table) { |
|
17 | 17 | $table->bigIncrements('id'); |
18 | 18 | $table->text('connection'); |
19 | 19 | $table->text('queue'); |
@@ -6,94 +6,94 @@ |
||
6 | 6 | |
7 | 7 | class GroupsTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to groups table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * Groups model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'save', |
|
26 | - 'model' => 'groups', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'delete', |
|
32 | - 'model' => 'groups', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'find', |
|
38 | - 'model' => 'groups', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'search', |
|
44 | - 'model' => 'groups', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'list', |
|
50 | - 'model' => 'groups', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'findby', |
|
56 | - 'model' => 'groups', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'first', |
|
62 | - 'model' => 'groups', |
|
63 | - 'created_at' => \DB::raw('NOW()'), |
|
64 | - 'updated_at' => \DB::raw('NOW()') |
|
65 | - ], |
|
66 | - [ |
|
67 | - 'name' => 'paginate', |
|
68 | - 'model' => 'groups', |
|
69 | - 'created_at' => \DB::raw('NOW()'), |
|
70 | - 'updated_at' => \DB::raw('NOW()') |
|
71 | - ], |
|
72 | - [ |
|
73 | - 'name' => 'paginateby', |
|
74 | - 'model' => 'groups', |
|
75 | - 'created_at' => \DB::raw('NOW()'), |
|
76 | - 'updated_at' => \DB::raw('NOW()') |
|
77 | - ], |
|
78 | - [ |
|
79 | - 'name' => 'assignpermissions', |
|
80 | - 'model' => 'groups', |
|
81 | - 'created_at' => \DB::raw('NOW()'), |
|
82 | - 'updated_at' => \DB::raw('NOW()') |
|
83 | - ], |
|
84 | - [ |
|
85 | - 'name' => 'deleted', |
|
86 | - 'model' => 'groups', |
|
87 | - 'created_at' => \DB::raw('NOW()'), |
|
88 | - 'updated_at' => \DB::raw('NOW()') |
|
89 | - ], |
|
90 | - [ |
|
91 | - 'name' => 'restore', |
|
92 | - 'model' => 'groups', |
|
93 | - 'created_at' => \DB::raw('NOW()'), |
|
94 | - 'updated_at' => \DB::raw('NOW()') |
|
95 | - ] |
|
96 | - ] |
|
97 | - ); |
|
98 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to groups table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * Groups model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'save', |
|
26 | + 'model' => 'groups', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'delete', |
|
32 | + 'model' => 'groups', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'find', |
|
38 | + 'model' => 'groups', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'search', |
|
44 | + 'model' => 'groups', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'list', |
|
50 | + 'model' => 'groups', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'findby', |
|
56 | + 'model' => 'groups', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'first', |
|
62 | + 'model' => 'groups', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ], |
|
66 | + [ |
|
67 | + 'name' => 'paginate', |
|
68 | + 'model' => 'groups', |
|
69 | + 'created_at' => \DB::raw('NOW()'), |
|
70 | + 'updated_at' => \DB::raw('NOW()') |
|
71 | + ], |
|
72 | + [ |
|
73 | + 'name' => 'paginateby', |
|
74 | + 'model' => 'groups', |
|
75 | + 'created_at' => \DB::raw('NOW()'), |
|
76 | + 'updated_at' => \DB::raw('NOW()') |
|
77 | + ], |
|
78 | + [ |
|
79 | + 'name' => 'assignpermissions', |
|
80 | + 'model' => 'groups', |
|
81 | + 'created_at' => \DB::raw('NOW()'), |
|
82 | + 'updated_at' => \DB::raw('NOW()') |
|
83 | + ], |
|
84 | + [ |
|
85 | + 'name' => 'deleted', |
|
86 | + 'model' => 'groups', |
|
87 | + 'created_at' => \DB::raw('NOW()'), |
|
88 | + 'updated_at' => \DB::raw('NOW()') |
|
89 | + ], |
|
90 | + [ |
|
91 | + 'name' => 'restore', |
|
92 | + 'model' => 'groups', |
|
93 | + 'created_at' => \DB::raw('NOW()'), |
|
94 | + 'updated_at' => \DB::raw('NOW()') |
|
95 | + ] |
|
96 | + ] |
|
97 | + ); |
|
98 | + } |
|
99 | 99 | } |
@@ -6,112 +6,112 @@ |
||
6 | 6 | |
7 | 7 | class UsersTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to users table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * Users model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'save', |
|
26 | - 'model' => 'users', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'delete', |
|
32 | - 'model' => 'users', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'find', |
|
38 | - 'model' => 'users', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'list', |
|
44 | - 'model' => 'users', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'search', |
|
50 | - 'model' => 'users', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'findby', |
|
56 | - 'model' => 'users', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'first', |
|
62 | - 'model' => 'users', |
|
63 | - 'created_at' => \DB::raw('NOW()'), |
|
64 | - 'updated_at' => \DB::raw('NOW()') |
|
65 | - ], |
|
66 | - [ |
|
67 | - 'name' => 'paginate', |
|
68 | - 'model' => 'users', |
|
69 | - 'created_at' => \DB::raw('NOW()'), |
|
70 | - 'updated_at' => \DB::raw('NOW()') |
|
71 | - ], |
|
72 | - [ |
|
73 | - 'name' => 'paginateby', |
|
74 | - 'model' => 'users', |
|
75 | - 'created_at' => \DB::raw('NOW()'), |
|
76 | - 'updated_at' => \DB::raw('NOW()') |
|
77 | - ], |
|
78 | - [ |
|
79 | - 'name' => 'assigngroups', |
|
80 | - 'model' => 'users', |
|
81 | - 'created_at' => \DB::raw('NOW()'), |
|
82 | - 'updated_at' => \DB::raw('NOW()') |
|
83 | - ], |
|
84 | - [ |
|
85 | - 'name' => 'block', |
|
86 | - 'model' => 'users', |
|
87 | - 'created_at' => \DB::raw('NOW()'), |
|
88 | - 'updated_at' => \DB::raw('NOW()') |
|
89 | - ], |
|
90 | - [ |
|
91 | - 'name' => 'unblock', |
|
92 | - 'model' => 'users', |
|
93 | - 'created_at' => \DB::raw('NOW()'), |
|
94 | - 'updated_at' => \DB::raw('NOW()') |
|
95 | - ], |
|
96 | - [ |
|
97 | - 'name' => 'group', |
|
98 | - 'model' => 'users', |
|
99 | - 'created_at' => \DB::raw('NOW()'), |
|
100 | - 'updated_at' => \DB::raw('NOW()') |
|
101 | - ], |
|
102 | - [ |
|
103 | - 'name' => 'deleted', |
|
104 | - 'model' => 'users', |
|
105 | - 'created_at' => \DB::raw('NOW()'), |
|
106 | - 'updated_at' => \DB::raw('NOW()') |
|
107 | - ], |
|
108 | - [ |
|
109 | - 'name' => 'restore', |
|
110 | - 'model' => 'users', |
|
111 | - 'created_at' => \DB::raw('NOW()'), |
|
112 | - 'updated_at' => \DB::raw('NOW()') |
|
113 | - ] |
|
114 | - ] |
|
115 | - ); |
|
116 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to users table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * Users model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'save', |
|
26 | + 'model' => 'users', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'delete', |
|
32 | + 'model' => 'users', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'find', |
|
38 | + 'model' => 'users', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'list', |
|
44 | + 'model' => 'users', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'search', |
|
50 | + 'model' => 'users', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'findby', |
|
56 | + 'model' => 'users', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'first', |
|
62 | + 'model' => 'users', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ], |
|
66 | + [ |
|
67 | + 'name' => 'paginate', |
|
68 | + 'model' => 'users', |
|
69 | + 'created_at' => \DB::raw('NOW()'), |
|
70 | + 'updated_at' => \DB::raw('NOW()') |
|
71 | + ], |
|
72 | + [ |
|
73 | + 'name' => 'paginateby', |
|
74 | + 'model' => 'users', |
|
75 | + 'created_at' => \DB::raw('NOW()'), |
|
76 | + 'updated_at' => \DB::raw('NOW()') |
|
77 | + ], |
|
78 | + [ |
|
79 | + 'name' => 'assigngroups', |
|
80 | + 'model' => 'users', |
|
81 | + 'created_at' => \DB::raw('NOW()'), |
|
82 | + 'updated_at' => \DB::raw('NOW()') |
|
83 | + ], |
|
84 | + [ |
|
85 | + 'name' => 'block', |
|
86 | + 'model' => 'users', |
|
87 | + 'created_at' => \DB::raw('NOW()'), |
|
88 | + 'updated_at' => \DB::raw('NOW()') |
|
89 | + ], |
|
90 | + [ |
|
91 | + 'name' => 'unblock', |
|
92 | + 'model' => 'users', |
|
93 | + 'created_at' => \DB::raw('NOW()'), |
|
94 | + 'updated_at' => \DB::raw('NOW()') |
|
95 | + ], |
|
96 | + [ |
|
97 | + 'name' => 'group', |
|
98 | + 'model' => 'users', |
|
99 | + 'created_at' => \DB::raw('NOW()'), |
|
100 | + 'updated_at' => \DB::raw('NOW()') |
|
101 | + ], |
|
102 | + [ |
|
103 | + 'name' => 'deleted', |
|
104 | + 'model' => 'users', |
|
105 | + 'created_at' => \DB::raw('NOW()'), |
|
106 | + 'updated_at' => \DB::raw('NOW()') |
|
107 | + ], |
|
108 | + [ |
|
109 | + 'name' => 'restore', |
|
110 | + 'model' => 'users', |
|
111 | + 'created_at' => \DB::raw('NOW()'), |
|
112 | + 'updated_at' => \DB::raw('NOW()') |
|
113 | + ] |
|
114 | + ] |
|
115 | + ); |
|
116 | + } |
|
117 | 117 | } |
@@ -6,20 +6,20 @@ discard block |
||
6 | 6 | |
7 | 7 | class AssignRelationsSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
17 | 17 | |
18 | - /** |
|
18 | + /** |
|
19 | 19 | * Assign the permissions to the admin group. |
20 | 20 | */ |
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['users', 'permissions', 'groups', 'oauthClients'])->each(function ($permission) use ($adminGroupId) { |
|
22 | - \DB::table('groups_permissions')->insert( |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['users', 'permissions', 'groups', 'oauthClients'])->each(function ($permission) use ($adminGroupId) { |
|
22 | + \DB::table('groups_permissions')->insert( |
|
23 | 23 | [ |
24 | 24 | 'permission_id' => $permission->id, |
25 | 25 | 'group_id' => $adminGroupId, |
@@ -27,6 +27,6 @@ discard block |
||
27 | 27 | 'updated_at' => \DB::raw('NOW()') |
28 | 28 | ] |
29 | 29 | ); |
30 | - }); |
|
31 | - } |
|
30 | + }); |
|
31 | + } |
|
32 | 32 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * Assign the permissions to the admin group. |
20 | 20 | */ |
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['users', 'permissions', 'groups', 'oauthClients'])->each(function ($permission) use ($adminGroupId) { |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['users', 'permissions', 'groups', 'oauthClients'])->each(function($permission) use ($adminGroupId) { |
|
22 | 22 | \DB::table('groups_permissions')->insert( |
23 | 23 | [ |
24 | 24 | 'permission_id' => $permission->id, |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class ClearDataSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $permissions = \DB::table('permissions')->whereIn('model', ['users', 'permissions', 'groups', 'oauthClients']); |
|
17 | - \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | - $permissions->delete(); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $permissions = \DB::table('permissions')->whereIn('model', ['users', 'permissions', 'groups', 'oauthClients']); |
|
17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -2,118 +2,118 @@ |
||
2 | 2 | |
3 | 3 | interface RepositoryInterface |
4 | 4 | { |
5 | - /** |
|
6 | - * Fetch all records with relations from the storage. |
|
7 | - * |
|
8 | - * @param array $relations |
|
9 | - * @param array $sortBy |
|
10 | - * @param array $desc |
|
11 | - * @param array $columns |
|
12 | - * @return collection |
|
13 | - */ |
|
14 | - public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
5 | + /** |
|
6 | + * Fetch all records with relations from the storage. |
|
7 | + * |
|
8 | + * @param array $relations |
|
9 | + * @param array $sortBy |
|
10 | + * @param array $desc |
|
11 | + * @param array $columns |
|
12 | + * @return collection |
|
13 | + */ |
|
14 | + public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
15 | 15 | |
16 | - /** |
|
17 | - * Fetch all records with relations from storage in pages |
|
18 | - * that matche the given query. |
|
19 | - * |
|
20 | - * @param string $query |
|
21 | - * @param integer $perPage |
|
22 | - * @param array $relations |
|
23 | - * @param array $sortBy |
|
24 | - * @param array $desc |
|
25 | - * @param array $columns |
|
26 | - * @return collection |
|
27 | - */ |
|
28 | - public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
16 | + /** |
|
17 | + * Fetch all records with relations from storage in pages |
|
18 | + * that matche the given query. |
|
19 | + * |
|
20 | + * @param string $query |
|
21 | + * @param integer $perPage |
|
22 | + * @param array $relations |
|
23 | + * @param array $sortBy |
|
24 | + * @param array $desc |
|
25 | + * @param array $columns |
|
26 | + * @return collection |
|
27 | + */ |
|
28 | + public function search($query, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
29 | 29 | |
30 | - /** |
|
31 | - * Fetch all records with relations from storage in pages. |
|
32 | - * |
|
33 | - * @param integer $perPage |
|
34 | - * @param array $relations |
|
35 | - * @param array $sortBy |
|
36 | - * @param array $desc |
|
37 | - * @param array $columns |
|
38 | - * @return collection |
|
39 | - */ |
|
40 | - public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
30 | + /** |
|
31 | + * Fetch all records with relations from storage in pages. |
|
32 | + * |
|
33 | + * @param integer $perPage |
|
34 | + * @param array $relations |
|
35 | + * @param array $sortBy |
|
36 | + * @param array $desc |
|
37 | + * @param array $columns |
|
38 | + * @return collection |
|
39 | + */ |
|
40 | + public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
41 | 41 | |
42 | - /** |
|
43 | - * Fetch all records with relations based on |
|
44 | - * the given condition from storage in pages. |
|
45 | - * |
|
46 | - * @param array $conditions array of conditions |
|
47 | - * @param integer $perPage |
|
48 | - * @param array $relations |
|
49 | - * @param array $sortBy |
|
50 | - * @param array $desc |
|
51 | - * @param array $columns |
|
52 | - * @return collection |
|
53 | - */ |
|
54 | - public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
42 | + /** |
|
43 | + * Fetch all records with relations based on |
|
44 | + * the given condition from storage in pages. |
|
45 | + * |
|
46 | + * @param array $conditions array of conditions |
|
47 | + * @param integer $perPage |
|
48 | + * @param array $relations |
|
49 | + * @param array $sortBy |
|
50 | + * @param array $desc |
|
51 | + * @param array $columns |
|
52 | + * @return collection |
|
53 | + */ |
|
54 | + public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
55 | 55 | |
56 | - /** |
|
57 | - * Save the given model/models to the storage. |
|
58 | - * |
|
59 | - * @param array $data |
|
60 | - * @return object |
|
61 | - */ |
|
62 | - public function save(array $data); |
|
56 | + /** |
|
57 | + * Save the given model/models to the storage. |
|
58 | + * |
|
59 | + * @param array $data |
|
60 | + * @return object |
|
61 | + */ |
|
62 | + public function save(array $data); |
|
63 | 63 | |
64 | - /** |
|
65 | - * Update record in the storage based on the given |
|
66 | - * condition. |
|
67 | - * |
|
68 | - * @param var $value condition value |
|
69 | - * @param array $data |
|
70 | - * @param string $attribute condition column name |
|
71 | - * @return integer affected rows |
|
72 | - */ |
|
73 | - public function update($value, array $data, $attribute = 'id'); |
|
64 | + /** |
|
65 | + * Update record in the storage based on the given |
|
66 | + * condition. |
|
67 | + * |
|
68 | + * @param var $value condition value |
|
69 | + * @param array $data |
|
70 | + * @param string $attribute condition column name |
|
71 | + * @return integer affected rows |
|
72 | + */ |
|
73 | + public function update($value, array $data, $attribute = 'id'); |
|
74 | 74 | |
75 | - /** |
|
76 | - * Delete record from the storage based on the given |
|
77 | - * condition. |
|
78 | - * |
|
79 | - * @param var $value condition value |
|
80 | - * @param string $attribute condition column name |
|
81 | - * @return integer affected rows |
|
82 | - */ |
|
83 | - public function delete($value, $attribute = 'id'); |
|
75 | + /** |
|
76 | + * Delete record from the storage based on the given |
|
77 | + * condition. |
|
78 | + * |
|
79 | + * @param var $value condition value |
|
80 | + * @param string $attribute condition column name |
|
81 | + * @return integer affected rows |
|
82 | + */ |
|
83 | + public function delete($value, $attribute = 'id'); |
|
84 | 84 | |
85 | - /** |
|
86 | - * Fetch records from the storage based on the given |
|
87 | - * id. |
|
88 | - * |
|
89 | - * @param integer $id |
|
90 | - * @param array $relations |
|
91 | - * @param array $columns |
|
92 | - * @return object |
|
93 | - */ |
|
94 | - public function find($id, $relations = [], $columns = array('*')); |
|
85 | + /** |
|
86 | + * Fetch records from the storage based on the given |
|
87 | + * id. |
|
88 | + * |
|
89 | + * @param integer $id |
|
90 | + * @param array $relations |
|
91 | + * @param array $columns |
|
92 | + * @return object |
|
93 | + */ |
|
94 | + public function find($id, $relations = [], $columns = array('*')); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Fetch records from the storage based on the given |
|
98 | - * condition. |
|
99 | - * |
|
100 | - * @param array $conditions array of conditions |
|
101 | - * @param array $relations |
|
102 | - * @param array $sortBy |
|
103 | - * @param array $desc |
|
104 | - * @param array $columns |
|
105 | - * @return collection |
|
106 | - */ |
|
107 | - public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
96 | + /** |
|
97 | + * Fetch records from the storage based on the given |
|
98 | + * condition. |
|
99 | + * |
|
100 | + * @param array $conditions array of conditions |
|
101 | + * @param array $relations |
|
102 | + * @param array $sortBy |
|
103 | + * @param array $desc |
|
104 | + * @param array $columns |
|
105 | + * @return collection |
|
106 | + */ |
|
107 | + public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = array('*')); |
|
108 | 108 | |
109 | - /** |
|
110 | - * Fetch the first record fro the storage based on the given |
|
111 | - * condition. |
|
112 | - * |
|
113 | - * @param array $conditions array of conditions |
|
114 | - * @param array $relations |
|
115 | - * @param array $columns |
|
116 | - * @return object |
|
117 | - */ |
|
118 | - public function first($conditions, $relations = [], $columns = array('*')); |
|
109 | + /** |
|
110 | + * Fetch the first record fro the storage based on the given |
|
111 | + * condition. |
|
112 | + * |
|
113 | + * @param array $conditions array of conditions |
|
114 | + * @param array $relations |
|
115 | + * @param array $columns |
|
116 | + * @return object |
|
117 | + */ |
|
118 | + public function first($conditions, $relations = [], $columns = array('*')); |
|
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -173,8 +173,7 @@ discard block |
||
173 | 173 | if ($request->has('id')) |
174 | 174 | { |
175 | 175 | $rule = str_replace('{id}', $request->get('id'), $rule); |
176 | - } |
|
177 | - else |
|
176 | + } else |
|
178 | 177 | { |
179 | 178 | $rule = str_replace(',{id}', '', $rule); |
180 | 179 | } |
@@ -252,10 +251,8 @@ discard block |
||
252 | 251 | } |
253 | 252 | |
254 | 253 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
255 | - {} |
|
256 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
257 | - {} |
|
258 | - else |
|
254 | + {} elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
255 | + {} else |
|
259 | 256 | { |
260 | 257 | |
261 | 258 | \ErrorHandler::noPermissions(); |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false; |
35 | 35 | $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : []; |
36 | 36 | $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : []; |
37 | - $route = explode('@',\Route::currentRouteAction())[1]; |
|
37 | + $route = explode('@', \Route::currentRouteAction())[1]; |
|
38 | 38 | |
39 | - $this->middleware(function ($request, $next) { |
|
39 | + $this->middleware(function($request, $next) { |
|
40 | 40 | |
41 | 41 | $this->repo = call_user_func_array("\Core::{$this->model}", []); |
42 | 42 | return $next($request); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
230 | 230 | {} |
231 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
231 | + elseif ( ! $isPasswordClient && $user->tokenCan($this->model.'-'.$permission)) |
|
232 | 232 | {} |
233 | 233 | else |
234 | 234 | { |
@@ -6,282 +6,282 @@ |
||
6 | 6 | |
7 | 7 | class BaseApiController extends Controller |
8 | 8 | { |
9 | - /** |
|
10 | - * The config implementation. |
|
11 | - * |
|
12 | - * @var array |
|
13 | - */ |
|
14 | - protected $config; |
|
9 | + /** |
|
10 | + * The config implementation. |
|
11 | + * |
|
12 | + * @var array |
|
13 | + */ |
|
14 | + protected $config; |
|
15 | 15 | |
16 | - /** |
|
17 | - * The relations implementation. |
|
18 | - * |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - protected $relations; |
|
16 | + /** |
|
17 | + * The relations implementation. |
|
18 | + * |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + protected $relations; |
|
22 | 22 | |
23 | - /** |
|
24 | - * The repo implementation. |
|
25 | - * |
|
26 | - * @var object |
|
27 | - */ |
|
28 | - protected $repo; |
|
23 | + /** |
|
24 | + * The repo implementation. |
|
25 | + * |
|
26 | + * @var object |
|
27 | + */ |
|
28 | + protected $repo; |
|
29 | 29 | |
30 | - public function __construct() |
|
31 | - { |
|
32 | - $this->config = \CoreConfig::getConfig(); |
|
33 | - $this->model = property_exists($this, 'model') ? $this->model : false; |
|
34 | - $this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false; |
|
35 | - $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : []; |
|
36 | - $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : []; |
|
37 | - $route = explode('@',\Route::currentRouteAction())[1]; |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + $this->config = \CoreConfig::getConfig(); |
|
33 | + $this->model = property_exists($this, 'model') ? $this->model : false; |
|
34 | + $this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false; |
|
35 | + $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : []; |
|
36 | + $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : []; |
|
37 | + $route = explode('@',\Route::currentRouteAction())[1]; |
|
38 | 38 | |
39 | - $this->middleware(function ($request, $next) { |
|
39 | + $this->middleware(function ($request, $next) { |
|
40 | 40 | |
41 | - $this->repo = call_user_func_array("\Core::{$this->model}", []); |
|
42 | - return $next($request); |
|
43 | - }); |
|
41 | + $this->repo = call_user_func_array("\Core::{$this->model}", []); |
|
42 | + return $next($request); |
|
43 | + }); |
|
44 | 44 | |
45 | - $this->checkPermission($route); |
|
46 | - $this->setRelations($route); |
|
47 | - $this->setSessions(); |
|
48 | - } |
|
45 | + $this->checkPermission($route); |
|
46 | + $this->setRelations($route); |
|
47 | + $this->setSessions(); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Fetch all records with relations from storage. |
|
52 | - * |
|
53 | - * @param string $sortBy The name of the column to sort by. |
|
54 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
55 | - * @return \Illuminate\Http\Response |
|
56 | - */ |
|
57 | - public function index($sortBy = 'created_at', $desc = 1) |
|
58 | - { |
|
59 | - return \Response::json($this->repo->all($this->relations, $sortBy, $desc), 200); |
|
60 | - } |
|
50 | + /** |
|
51 | + * Fetch all records with relations from storage. |
|
52 | + * |
|
53 | + * @param string $sortBy The name of the column to sort by. |
|
54 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
55 | + * @return \Illuminate\Http\Response |
|
56 | + */ |
|
57 | + public function index($sortBy = 'created_at', $desc = 1) |
|
58 | + { |
|
59 | + return \Response::json($this->repo->all($this->relations, $sortBy, $desc), 200); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Fetch the single object with relations from storage. |
|
64 | - * |
|
65 | - * @param integer $id Id of the requested model. |
|
66 | - * @return \Illuminate\Http\Response |
|
67 | - */ |
|
68 | - public function find($id) |
|
69 | - { |
|
70 | - return \Response::json($this->repo->find($id, $this->relations), 200); |
|
71 | - } |
|
62 | + /** |
|
63 | + * Fetch the single object with relations from storage. |
|
64 | + * |
|
65 | + * @param integer $id Id of the requested model. |
|
66 | + * @return \Illuminate\Http\Response |
|
67 | + */ |
|
68 | + public function find($id) |
|
69 | + { |
|
70 | + return \Response::json($this->repo->find($id, $this->relations), 200); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Paginate all records with relations from storage |
|
75 | - * that matche the given query. |
|
76 | - * |
|
77 | - * @param string $query The search text. |
|
78 | - * @param integer $perPage Number of rows per page default 15. |
|
79 | - * @param string $sortBy The name of the column to sort by. |
|
80 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
81 | - * @return \Illuminate\Http\Response |
|
82 | - */ |
|
83 | - public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
84 | - { |
|
85 | - return \Response::json($this->repo->search($query, $perPage, $this->relations, $sortBy, $desc), 200); |
|
86 | - } |
|
73 | + /** |
|
74 | + * Paginate all records with relations from storage |
|
75 | + * that matche the given query. |
|
76 | + * |
|
77 | + * @param string $query The search text. |
|
78 | + * @param integer $perPage Number of rows per page default 15. |
|
79 | + * @param string $sortBy The name of the column to sort by. |
|
80 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
81 | + * @return \Illuminate\Http\Response |
|
82 | + */ |
|
83 | + public function search($query = '', $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
84 | + { |
|
85 | + return \Response::json($this->repo->search($query, $perPage, $this->relations, $sortBy, $desc), 200); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * Fetch records from the storage based on the given |
|
90 | - * condition. |
|
91 | - * |
|
92 | - * @param \Illuminate\Http\Request $request |
|
93 | - * @param string $sortBy The name of the column to sort by. |
|
94 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
95 | - * @return \Illuminate\Http\Response |
|
96 | - */ |
|
97 | - public function findby(Request $request, $sortBy = 'created_at', $desc = 1) |
|
98 | - { |
|
99 | - return \Response::json($this->repo->findBy($request->all(), $this->relations, $sortBy, $desc), 200); |
|
100 | - } |
|
88 | + /** |
|
89 | + * Fetch records from the storage based on the given |
|
90 | + * condition. |
|
91 | + * |
|
92 | + * @param \Illuminate\Http\Request $request |
|
93 | + * @param string $sortBy The name of the column to sort by. |
|
94 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
95 | + * @return \Illuminate\Http\Response |
|
96 | + */ |
|
97 | + public function findby(Request $request, $sortBy = 'created_at', $desc = 1) |
|
98 | + { |
|
99 | + return \Response::json($this->repo->findBy($request->all(), $this->relations, $sortBy, $desc), 200); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Fetch the first record from the storage based on the given |
|
104 | - * condition. |
|
105 | - * |
|
106 | - * @param \Illuminate\Http\Request $request |
|
107 | - * @return \Illuminate\Http\Response |
|
108 | - */ |
|
109 | - public function first(Request $request) |
|
110 | - { |
|
111 | - return \Response::json($this->repo->first($request->all(), $this->relations), 200); |
|
112 | - } |
|
102 | + /** |
|
103 | + * Fetch the first record from the storage based on the given |
|
104 | + * condition. |
|
105 | + * |
|
106 | + * @param \Illuminate\Http\Request $request |
|
107 | + * @return \Illuminate\Http\Response |
|
108 | + */ |
|
109 | + public function first(Request $request) |
|
110 | + { |
|
111 | + return \Response::json($this->repo->first($request->all(), $this->relations), 200); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Paginate all records with relations from storage. |
|
116 | - * |
|
117 | - * @param integer $perPage Number of rows per page default 15. |
|
118 | - * @param string $sortBy The name of the column to sort by. |
|
119 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
120 | - * @return \Illuminate\Http\Response |
|
121 | - */ |
|
122 | - public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
123 | - { |
|
124 | - return \Response::json($this->repo->paginate($perPage, $this->relations, $sortBy, $desc), 200); |
|
125 | - } |
|
114 | + /** |
|
115 | + * Paginate all records with relations from storage. |
|
116 | + * |
|
117 | + * @param integer $perPage Number of rows per page default 15. |
|
118 | + * @param string $sortBy The name of the column to sort by. |
|
119 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
120 | + * @return \Illuminate\Http\Response |
|
121 | + */ |
|
122 | + public function paginate($perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
123 | + { |
|
124 | + return \Response::json($this->repo->paginate($perPage, $this->relations, $sortBy, $desc), 200); |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * Fetch all records with relations based on |
|
129 | - * the given condition from storage in pages. |
|
130 | - * |
|
131 | - * @param \Illuminate\Http\Request $request |
|
132 | - * @param integer $perPage Number of rows per page default 15. |
|
133 | - * @param string $sortBy The name of the column to sort by. |
|
134 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
135 | - * @return \Illuminate\Http\Response |
|
136 | - */ |
|
137 | - public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
138 | - { |
|
139 | - return \Response::json($this->repo->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200); |
|
140 | - } |
|
127 | + /** |
|
128 | + * Fetch all records with relations based on |
|
129 | + * the given condition from storage in pages. |
|
130 | + * |
|
131 | + * @param \Illuminate\Http\Request $request |
|
132 | + * @param integer $perPage Number of rows per page default 15. |
|
133 | + * @param string $sortBy The name of the column to sort by. |
|
134 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
135 | + * @return \Illuminate\Http\Response |
|
136 | + */ |
|
137 | + public function paginateby(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
138 | + { |
|
139 | + return \Response::json($this->repo->paginateBy($request->all(), $perPage, $this->relations, $sortBy, $desc), 200); |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * Save the given model to storage. |
|
144 | - * |
|
145 | - * @param \Illuminate\Http\Request $request |
|
146 | - * @return \Illuminate\Http\Response |
|
147 | - */ |
|
148 | - public function save(Request $request) |
|
149 | - { |
|
150 | - foreach ($this->validationRules as &$rule) |
|
151 | - { |
|
152 | - if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) |
|
153 | - { |
|
154 | - $rule .= ',deleted_at,NULL'; |
|
155 | - } |
|
142 | + /** |
|
143 | + * Save the given model to storage. |
|
144 | + * |
|
145 | + * @param \Illuminate\Http\Request $request |
|
146 | + * @return \Illuminate\Http\Response |
|
147 | + */ |
|
148 | + public function save(Request $request) |
|
149 | + { |
|
150 | + foreach ($this->validationRules as &$rule) |
|
151 | + { |
|
152 | + if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) |
|
153 | + { |
|
154 | + $rule .= ',deleted_at,NULL'; |
|
155 | + } |
|
156 | 156 | |
157 | - if ($request->has('id')) |
|
158 | - { |
|
159 | - $rule = str_replace('{id}', $request->get('id'), $rule); |
|
160 | - } |
|
161 | - else |
|
162 | - { |
|
163 | - $rule = str_replace(',{id}', '', $rule); |
|
164 | - } |
|
165 | - } |
|
157 | + if ($request->has('id')) |
|
158 | + { |
|
159 | + $rule = str_replace('{id}', $request->get('id'), $rule); |
|
160 | + } |
|
161 | + else |
|
162 | + { |
|
163 | + $rule = str_replace(',{id}', '', $rule); |
|
164 | + } |
|
165 | + } |
|
166 | 166 | |
167 | - $this->validate($request, $this->validationRules); |
|
167 | + $this->validate($request, $this->validationRules); |
|
168 | 168 | |
169 | - return \Response::json($this->repo->save($request->all()), 200); |
|
170 | - } |
|
169 | + return \Response::json($this->repo->save($request->all()), 200); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Delete by the given id from storage. |
|
174 | - * |
|
175 | - * @param integer $id Id of the deleted model. |
|
176 | - * @return \Illuminate\Http\Response |
|
177 | - */ |
|
178 | - public function delete($id) |
|
179 | - { |
|
180 | - return \Response::json($this->repo->delete($id), 200); |
|
181 | - } |
|
172 | + /** |
|
173 | + * Delete by the given id from storage. |
|
174 | + * |
|
175 | + * @param integer $id Id of the deleted model. |
|
176 | + * @return \Illuminate\Http\Response |
|
177 | + */ |
|
178 | + public function delete($id) |
|
179 | + { |
|
180 | + return \Response::json($this->repo->delete($id), 200); |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Return the deleted models in pages based on the given conditions. |
|
185 | - * |
|
186 | - * @param \Illuminate\Http\Request $request |
|
187 | - * @param integer $perPage Number of rows per page default 15. |
|
188 | - * @param string $sortBy The name of the column to sort by. |
|
189 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
190 | - * @return \Illuminate\Http\Response |
|
191 | - */ |
|
192 | - public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
193 | - { |
|
194 | - return \Response::json($this->repo->deleted($request->all(), $perPage, $sortBy, $desc), 200); |
|
195 | - } |
|
183 | + /** |
|
184 | + * Return the deleted models in pages based on the given conditions. |
|
185 | + * |
|
186 | + * @param \Illuminate\Http\Request $request |
|
187 | + * @param integer $perPage Number of rows per page default 15. |
|
188 | + * @param string $sortBy The name of the column to sort by. |
|
189 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
190 | + * @return \Illuminate\Http\Response |
|
191 | + */ |
|
192 | + public function deleted(Request $request, $perPage = 15, $sortBy = 'created_at', $desc = 1) |
|
193 | + { |
|
194 | + return \Response::json($this->repo->deleted($request->all(), $perPage, $sortBy, $desc), 200); |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * Restore the deleted model. |
|
199 | - * |
|
200 | - * @param integer $id Id of the restored model. |
|
201 | - * @return \Illuminate\Http\Response |
|
202 | - */ |
|
203 | - public function restore($id) |
|
204 | - { |
|
205 | - return \Response::json($this->repo->restore($id), 200); |
|
206 | - } |
|
197 | + /** |
|
198 | + * Restore the deleted model. |
|
199 | + * |
|
200 | + * @param integer $id Id of the restored model. |
|
201 | + * @return \Illuminate\Http\Response |
|
202 | + */ |
|
203 | + public function restore($id) |
|
204 | + { |
|
205 | + return \Response::json($this->repo->restore($id), 200); |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * Check if the logged in user can do the given permission. |
|
210 | - * |
|
211 | - * @param string $permission |
|
212 | - * @return void |
|
213 | - */ |
|
214 | - private function checkPermission($permission) |
|
215 | - { |
|
216 | - \Auth::shouldUse('api'); |
|
217 | - $this->middleware('auth:api', ['except' => $this->skipLoginCheck]); |
|
208 | + /** |
|
209 | + * Check if the logged in user can do the given permission. |
|
210 | + * |
|
211 | + * @param string $permission |
|
212 | + * @return void |
|
213 | + */ |
|
214 | + private function checkPermission($permission) |
|
215 | + { |
|
216 | + \Auth::shouldUse('api'); |
|
217 | + $this->middleware('auth:api', ['except' => $this->skipLoginCheck]); |
|
218 | 218 | |
219 | - if ($user = \Auth::user()) |
|
220 | - { |
|
221 | - $permission = $permission !== 'index' ? $permission : 'list'; |
|
222 | - $isPasswordClient = $user->token()->client->password_client; |
|
219 | + if ($user = \Auth::user()) |
|
220 | + { |
|
221 | + $permission = $permission !== 'index' ? $permission : 'list'; |
|
222 | + $isPasswordClient = $user->token()->client->password_client; |
|
223 | 223 | |
224 | - if ($user->blocked) |
|
225 | - { |
|
226 | - \ErrorHandler::userIsBlocked(); |
|
227 | - } |
|
224 | + if ($user->blocked) |
|
225 | + { |
|
226 | + \ErrorHandler::userIsBlocked(); |
|
227 | + } |
|
228 | 228 | |
229 | - if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
|
230 | - {} |
|
231 | - elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
232 | - {} |
|
233 | - else |
|
234 | - { |
|
229 | + if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->model))) |
|
230 | + {} |
|
231 | + elseif ( ! $isPasswordClient && $user->tokenCan($this->model . '-' . $permission)) |
|
232 | + {} |
|
233 | + else |
|
234 | + { |
|
235 | 235 | |
236 | - \ErrorHandler::noPermissions(); |
|
237 | - } |
|
238 | - } |
|
239 | - } |
|
236 | + \ErrorHandler::noPermissions(); |
|
237 | + } |
|
238 | + } |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Set sessions based on the given headers in the request. |
|
243 | - * |
|
244 | - * @return void |
|
245 | - */ |
|
246 | - private function setSessions() |
|
247 | - { |
|
248 | - \Session::put('time-zone', \Request::header('time-zone') ?: 0); |
|
241 | + /** |
|
242 | + * Set sessions based on the given headers in the request. |
|
243 | + * |
|
244 | + * @return void |
|
245 | + */ |
|
246 | + private function setSessions() |
|
247 | + { |
|
248 | + \Session::put('time-zone', \Request::header('time-zone') ?: 0); |
|
249 | 249 | |
250 | - $locale = \Request::header('locale'); |
|
251 | - switch ($locale) |
|
252 | - { |
|
253 | - case 'en': |
|
254 | - \App::setLocale('en'); |
|
255 | - \Session::put('locale', 'en'); |
|
256 | - break; |
|
250 | + $locale = \Request::header('locale'); |
|
251 | + switch ($locale) |
|
252 | + { |
|
253 | + case 'en': |
|
254 | + \App::setLocale('en'); |
|
255 | + \Session::put('locale', 'en'); |
|
256 | + break; |
|
257 | 257 | |
258 | - case 'ar': |
|
259 | - \App::setLocale('ar'); |
|
260 | - \Session::put('locale', 'ar'); |
|
261 | - break; |
|
258 | + case 'ar': |
|
259 | + \App::setLocale('ar'); |
|
260 | + \Session::put('locale', 'ar'); |
|
261 | + break; |
|
262 | 262 | |
263 | - case 'all': |
|
264 | - \App::setLocale('en'); |
|
265 | - \Session::put('locale', 'all'); |
|
266 | - break; |
|
263 | + case 'all': |
|
264 | + \App::setLocale('en'); |
|
265 | + \Session::put('locale', 'all'); |
|
266 | + break; |
|
267 | 267 | |
268 | - default: |
|
269 | - \App::setLocale('en'); |
|
270 | - \Session::put('locale', 'en'); |
|
271 | - break; |
|
272 | - } |
|
273 | - } |
|
268 | + default: |
|
269 | + \App::setLocale('en'); |
|
270 | + \Session::put('locale', 'en'); |
|
271 | + break; |
|
272 | + } |
|
273 | + } |
|
274 | 274 | |
275 | - /** |
|
276 | - * Set relation based on the called api. |
|
277 | - * |
|
278 | - * @param string $route |
|
279 | - * @return void |
|
280 | - */ |
|
281 | - private function setRelations($route) |
|
282 | - { |
|
283 | - $route = $route !== 'index' ? $route : 'list'; |
|
284 | - $relations = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false; |
|
285 | - $this->relations = $relations && isset($relations[$route]) ? $relations[$route] : []; |
|
286 | - } |
|
275 | + /** |
|
276 | + * Set relation based on the called api. |
|
277 | + * |
|
278 | + * @param string $route |
|
279 | + * @return void |
|
280 | + */ |
|
281 | + private function setRelations($route) |
|
282 | + { |
|
283 | + $route = $route !== 'index' ? $route : 'list'; |
|
284 | + $relations = array_key_exists($this->model, $this->config['relations']) ? $this->config['relations'][$this->model] : false; |
|
285 | + $this->relations = $relations && isset($relations[$route]) ? $relations[$route] : []; |
|
286 | + } |
|
287 | 287 | } |