@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class CoreDatabaseSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $this->call(ClearDataSeeder::class); |
|
17 | - $this->call(SettingsTableSeeder::class); |
|
18 | - $this->call(AssignRelationsSeeder::class); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $this->call(ClearDataSeeder::class); |
|
17 | + $this->call(SettingsTableSeeder::class); |
|
18 | + $this->call(AssignRelationsSeeder::class); |
|
19 | + } |
|
20 | 20 | } |
@@ -6,27 +6,27 @@ |
||
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 | - /** |
|
19 | - * Assign the permissions to the admin group. |
|
20 | - */ |
|
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
22 | - \DB::table('groups_permissions')->insert( |
|
23 | - [ |
|
24 | - 'permission_id' => $permission->id, |
|
25 | - 'group_id' => $adminGroupId, |
|
26 | - 'created_at' => \DB::raw('NOW()'), |
|
27 | - 'updated_at' => \DB::raw('NOW()') |
|
28 | - ] |
|
29 | - ); |
|
30 | - }); |
|
31 | - } |
|
18 | + /** |
|
19 | + * Assign the permissions to the admin group. |
|
20 | + */ |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
22 | + \DB::table('groups_permissions')->insert( |
|
23 | + [ |
|
24 | + 'permission_id' => $permission->id, |
|
25 | + 'group_id' => $adminGroupId, |
|
26 | + 'created_at' => \DB::raw('NOW()'), |
|
27 | + 'updated_at' => \DB::raw('NOW()') |
|
28 | + ] |
|
29 | + ); |
|
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', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function($permission) use ($adminGroupId) { |
|
22 | 22 | \DB::table('groups_permissions')->insert( |
23 | 23 | [ |
24 | 24 | 'permission_id' => $permission->id, |
@@ -6,76 +6,76 @@ |
||
6 | 6 | |
7 | 7 | class SettingsTableSeeder 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 settings table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * Settings model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'save', |
|
26 | - 'model' => 'settings', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'find', |
|
32 | - 'model' => 'settings', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'search', |
|
38 | - 'model' => 'settings', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'list', |
|
44 | - 'model' => 'settings', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'findby', |
|
50 | - 'model' => 'settings', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'first', |
|
56 | - 'model' => 'settings', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'paginate', |
|
62 | - 'model' => 'settings', |
|
63 | - 'created_at' => \DB::raw('NOW()'), |
|
64 | - 'updated_at' => \DB::raw('NOW()') |
|
65 | - ], |
|
66 | - [ |
|
67 | - 'name' => 'paginateby', |
|
68 | - 'model' => 'settings', |
|
69 | - 'created_at' => \DB::raw('NOW()'), |
|
70 | - 'updated_at' => \DB::raw('NOW()') |
|
71 | - ], |
|
72 | - [ |
|
73 | - 'name' => 'saveMany', |
|
74 | - 'model' => 'settings', |
|
75 | - 'created_at' => \DB::raw('NOW()'), |
|
76 | - 'updated_at' => \DB::raw('NOW()') |
|
77 | - ] |
|
78 | - ] |
|
79 | - ); |
|
80 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to settings table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * Settings model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'save', |
|
26 | + 'model' => 'settings', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'find', |
|
32 | + 'model' => 'settings', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'search', |
|
38 | + 'model' => 'settings', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'list', |
|
44 | + 'model' => 'settings', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'findby', |
|
50 | + 'model' => 'settings', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'first', |
|
56 | + 'model' => 'settings', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'paginate', |
|
62 | + 'model' => 'settings', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ], |
|
66 | + [ |
|
67 | + 'name' => 'paginateby', |
|
68 | + 'model' => 'settings', |
|
69 | + 'created_at' => \DB::raw('NOW()'), |
|
70 | + 'updated_at' => \DB::raw('NOW()') |
|
71 | + ], |
|
72 | + [ |
|
73 | + 'name' => 'saveMany', |
|
74 | + 'model' => 'settings', |
|
75 | + 'created_at' => \DB::raw('NOW()'), |
|
76 | + 'updated_at' => \DB::raw('NOW()') |
|
77 | + ] |
|
78 | + ] |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | } |
@@ -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', ['settings']); |
|
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', ['settings']); |
|
17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -5,111 +5,111 @@ |
||
5 | 5 | |
6 | 6 | class CachingDecorator |
7 | 7 | { |
8 | - /** |
|
9 | - * The repo implementation. |
|
10 | - * |
|
11 | - * @var string |
|
12 | - */ |
|
13 | - public $repo; |
|
8 | + /** |
|
9 | + * The repo implementation. |
|
10 | + * |
|
11 | + * @var string |
|
12 | + */ |
|
13 | + public $repo; |
|
14 | 14 | |
15 | - /** |
|
16 | - * The cache implementation. |
|
17 | - * |
|
18 | - * @var object |
|
19 | - */ |
|
20 | - protected $cache; |
|
15 | + /** |
|
16 | + * The cache implementation. |
|
17 | + * |
|
18 | + * @var object |
|
19 | + */ |
|
20 | + protected $cache; |
|
21 | 21 | |
22 | - /** |
|
23 | - * The modelKey implementation. |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $modelKey; |
|
22 | + /** |
|
23 | + * The modelKey implementation. |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $modelKey; |
|
28 | 28 | |
29 | - /** |
|
30 | - * The model implementation. |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - public $model; |
|
29 | + /** |
|
30 | + * The model implementation. |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + public $model; |
|
35 | 35 | |
36 | - /** |
|
37 | - * The modelClass implementation. |
|
38 | - * |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - public $modelClass; |
|
36 | + /** |
|
37 | + * The modelClass implementation. |
|
38 | + * |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + public $modelClass; |
|
42 | 42 | |
43 | - /** |
|
44 | - * The cacheConfig implementation. |
|
45 | - * |
|
46 | - * @var mixed |
|
47 | - */ |
|
48 | - public $cacheConfig; |
|
43 | + /** |
|
44 | + * The cacheConfig implementation. |
|
45 | + * |
|
46 | + * @var mixed |
|
47 | + */ |
|
48 | + public $cacheConfig; |
|
49 | 49 | |
50 | - /** |
|
51 | - * The cacheTag implementation. |
|
52 | - * |
|
53 | - * @var string |
|
54 | - */ |
|
55 | - public $cacheTag; |
|
50 | + /** |
|
51 | + * The cacheTag implementation. |
|
52 | + * |
|
53 | + * @var string |
|
54 | + */ |
|
55 | + public $cacheTag; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Create new CachingDecorator instance. |
|
59 | - */ |
|
60 | - public function __construct($repo, $cache) |
|
61 | - { |
|
62 | - $this->repo = $repo; |
|
63 | - $this->cache = $cache; |
|
64 | - $this->model = $this->repo->model; |
|
65 | - $this->modelClass = get_class($this->model); |
|
66 | - $repoClass = explode('\\', get_class($this->repo)); |
|
67 | - $repoName = end($repoClass); |
|
68 | - $this->cacheTag = Str::plural(lcfirst(substr($repoName, 0, strpos($repoName, 'Repository')))); |
|
69 | - } |
|
57 | + /** |
|
58 | + * Create new CachingDecorator instance. |
|
59 | + */ |
|
60 | + public function __construct($repo, $cache) |
|
61 | + { |
|
62 | + $this->repo = $repo; |
|
63 | + $this->cache = $cache; |
|
64 | + $this->model = $this->repo->model; |
|
65 | + $this->modelClass = get_class($this->model); |
|
66 | + $repoClass = explode('\\', get_class($this->repo)); |
|
67 | + $repoName = end($repoClass); |
|
68 | + $this->cacheTag = Str::plural(lcfirst(substr($repoName, 0, strpos($repoName, 'Repository')))); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Handle the cache mechanism for the called method |
|
73 | - * based the configurations. |
|
74 | - * |
|
75 | - * @param string $name the called method name |
|
76 | - * @param array $arguments the method arguments |
|
77 | - * @return object |
|
78 | - */ |
|
79 | - public function __call($name, $arguments) |
|
80 | - { |
|
81 | - $this->setCacheConfig($name); |
|
71 | + /** |
|
72 | + * Handle the cache mechanism for the called method |
|
73 | + * based the configurations. |
|
74 | + * |
|
75 | + * @param string $name the called method name |
|
76 | + * @param array $arguments the method arguments |
|
77 | + * @return object |
|
78 | + */ |
|
79 | + public function __call($name, $arguments) |
|
80 | + { |
|
81 | + $this->setCacheConfig($name); |
|
82 | 82 | |
83 | - if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
|
84 | - $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
85 | - $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
86 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
87 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
88 | - }); |
|
89 | - } elseif ($this->cacheConfig) { |
|
90 | - $this->cache->tags($this->cacheConfig)->flush(); |
|
91 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
92 | - } |
|
83 | + if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
|
84 | + $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
|
85 | + $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
|
86 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
87 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
88 | + }); |
|
89 | + } elseif ($this->cacheConfig) { |
|
90 | + $this->cache->tags($this->cacheConfig)->flush(); |
|
91 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
92 | + } |
|
93 | 93 | |
94 | - return call_user_func_array([$this->repo, $name], $arguments); |
|
95 | - } |
|
94 | + return call_user_func_array([$this->repo, $name], $arguments); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Set cache config based on the called method. |
|
99 | - * |
|
100 | - * @param string $name |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - private function setCacheConfig($name) |
|
104 | - { |
|
105 | - $config = \CoreConfig::getConfig(); |
|
106 | - $cacheConfig = Arr::get($config['cacheConfig'], $this->cacheTag, false); |
|
107 | - $this->cacheConfig = false; |
|
97 | + /** |
|
98 | + * Set cache config based on the called method. |
|
99 | + * |
|
100 | + * @param string $name |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + private function setCacheConfig($name) |
|
104 | + { |
|
105 | + $config = \CoreConfig::getConfig(); |
|
106 | + $cacheConfig = Arr::get($config['cacheConfig'], $this->cacheTag, false); |
|
107 | + $this->cacheConfig = false; |
|
108 | 108 | |
109 | - if ($cacheConfig && in_array($name, $cacheConfig['cache'])) { |
|
110 | - $this->cacheConfig = 'cache'; |
|
111 | - } elseif ($cacheConfig && isset($cacheConfig['clear'][$name])) { |
|
112 | - $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
113 | - } |
|
114 | - } |
|
109 | + if ($cacheConfig && in_array($name, $cacheConfig['cache'])) { |
|
110 | + $this->cacheConfig = 'cache'; |
|
111 | + } elseif ($cacheConfig && isset($cacheConfig['clear'][$name])) { |
|
112 | + $this->cacheConfig = $cacheConfig['clear'][$name]; |
|
113 | + } |
|
114 | + } |
|
115 | 115 | } |
@@ -83,7 +83,7 @@ |
||
83 | 83 | if ($this->cacheConfig && $this->cacheConfig == 'cache') { |
84 | 84 | $page = \Request::get('page') !== null ? \Request::get('page') : '1'; |
85 | 85 | $cacheKey = $name.$page.\Session::get('locale').serialize($arguments); |
86 | - return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function () use ($arguments, $name) { |
|
86 | + return $this->cache->tags([$this->cacheTag])->rememberForever($cacheKey, function() use ($arguments, $name) { |
|
87 | 87 | return call_user_func_array([$this->repo, $name], $arguments); |
88 | 88 | }); |
89 | 89 | } elseif ($this->cacheConfig) { |
@@ -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 mixed |
|
61 | - */ |
|
62 | - public function save(array $data); |
|
56 | + /** |
|
57 | + * Save the given model/models to the storage. |
|
58 | + * |
|
59 | + * @param array $data |
|
60 | + * @return mixed |
|
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 | } |
@@ -2,15 +2,15 @@ |
||
2 | 2 | |
3 | 3 | interface RepositoryContainerInterface |
4 | 4 | { |
5 | - /** |
|
6 | - * Construct the repository class name based on |
|
7 | - * the method name called, search in the |
|
8 | - * given namespaces for the class and |
|
9 | - * return an instance. |
|
10 | - * |
|
11 | - * @param string $name the called method name |
|
12 | - * @param array $arguments the method arguments |
|
13 | - * @return object |
|
14 | - */ |
|
15 | - public function __call($name, $arguments); |
|
5 | + /** |
|
6 | + * Construct the repository class name based on |
|
7 | + * the method name called, search in the |
|
8 | + * given namespaces for the class and |
|
9 | + * return an instance. |
|
10 | + * |
|
11 | + * @param string $name the called method name |
|
12 | + * @param array $arguments the method arguments |
|
13 | + * @return object |
|
14 | + */ |
|
15 | + public function __call($name, $arguments); |
|
16 | 16 | } |
@@ -7,31 +7,31 @@ |
||
7 | 7 | |
8 | 8 | class SettingsController extends BaseApiController |
9 | 9 | { |
10 | - /** |
|
11 | - * The name of the model that is used by the base api controller |
|
12 | - * to preform actions like (add, edit ... etc). |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $model = 'settings'; |
|
10 | + /** |
|
11 | + * The name of the model that is used by the base api controller |
|
12 | + * to preform actions like (add, edit ... etc). |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $model = 'settings'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * The validations rules used by the base api controller |
|
19 | - * to check before add. |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $validationRules = [ |
|
23 | - 'id' => 'required|exists:settings,id', |
|
24 | - 'value' => 'required|string' |
|
25 | - ]; |
|
17 | + /** |
|
18 | + * The validations rules used by the base api controller |
|
19 | + * to check before add. |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $validationRules = [ |
|
23 | + 'id' => 'required|exists:settings,id', |
|
24 | + 'value' => 'required|string' |
|
25 | + ]; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Save list of settings. |
|
29 | - * |
|
30 | - * @param \Illuminate\Http\Request $request |
|
31 | - * @return \Illuminate\Http\Response |
|
32 | - */ |
|
33 | - public function saveMany(Request $request) |
|
34 | - { |
|
35 | - return \Response::json($this->repo->saveMany($request->all()), 200); |
|
36 | - } |
|
27 | + /** |
|
28 | + * Save list of settings. |
|
29 | + * |
|
30 | + * @param \Illuminate\Http\Request $request |
|
31 | + * @return \Illuminate\Http\Response |
|
32 | + */ |
|
33 | + public function saveMany(Request $request) |
|
34 | + { |
|
35 | + return \Response::json($this->repo->saveMany($request->all()), 200); |
|
36 | + } |
|
37 | 37 | } |
@@ -5,70 +5,70 @@ |
||
5 | 5 | |
6 | 6 | class ApiDocumentController extends Controller |
7 | 7 | { |
8 | - public function index() |
|
9 | - { |
|
10 | - $jsonDoc = json_decode(file_get_contents(app_path('Modules/Core/Resources/api.json')), true); |
|
11 | - $modules = $jsonDoc['modules']; |
|
12 | - $reports = $jsonDoc['reports']; |
|
13 | - $errors = $jsonDoc['errors']; |
|
14 | - $models = $jsonDoc['models']; |
|
15 | - $conditions = [ |
|
16 | - [ |
|
17 | - 'title' => 'email equal [email protected]:', |
|
18 | - 'content' => ['email' => '[email protected]'] |
|
19 | - ], |
|
20 | - [ |
|
21 | - 'title' => 'email equal [email protected] and user is blocked:', |
|
22 | - 'content' => ['and' => ['email' => '[email protected]', 'blocked' => 1]] |
|
23 | - ], |
|
24 | - [ |
|
25 | - 'title' => 'email equal [email protected] or user is blocked:', |
|
26 | - 'content' => ['or' => ['email' => '[email protected]', 'blocked' => 1]] |
|
27 | - ], |
|
28 | - [ |
|
29 | - 'title' => 'email contain John:', |
|
30 | - 'content' => ['email' => ['op' => 'like', 'val' => '%John%']] |
|
31 | - ], |
|
32 | - [ |
|
33 | - 'title' => 'user created after 2016-10-25:', |
|
34 | - 'content' => ['created_at' => ['op' => '>', 'val' => '2016-10-25']] |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'title' => 'user created between 2016-10-20 and 2016-10-25:', |
|
38 | - 'content' => ['created_at' => ['op' => 'between', 'val1' => '2016-10-20', 'val2' => '2016-10-25']] |
|
39 | - ], |
|
40 | - [ |
|
41 | - 'title' => 'user id in 1,2,3:', |
|
42 | - 'content' => ['id' => ['op' => 'in', 'val' => [1, 2, 3]]] |
|
43 | - ], |
|
44 | - [ |
|
45 | - 'title' => 'user name is null:', |
|
46 | - 'content' => ['name' => ['op' => 'null']] |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'title' => 'user name is not null:', |
|
50 | - 'content' => ['name' => ['op' => 'not null']] |
|
51 | - ], |
|
52 | - [ |
|
53 | - 'title' => 'user has group admin:', |
|
54 | - 'content' => ['groups' => ['op' => 'has', 'val' => ['name' => 'Admin']]] |
|
55 | - ] |
|
56 | - ]; |
|
8 | + public function index() |
|
9 | + { |
|
10 | + $jsonDoc = json_decode(file_get_contents(app_path('Modules/Core/Resources/api.json')), true); |
|
11 | + $modules = $jsonDoc['modules']; |
|
12 | + $reports = $jsonDoc['reports']; |
|
13 | + $errors = $jsonDoc['errors']; |
|
14 | + $models = $jsonDoc['models']; |
|
15 | + $conditions = [ |
|
16 | + [ |
|
17 | + 'title' => 'email equal [email protected]:', |
|
18 | + 'content' => ['email' => '[email protected]'] |
|
19 | + ], |
|
20 | + [ |
|
21 | + 'title' => 'email equal [email protected] and user is blocked:', |
|
22 | + 'content' => ['and' => ['email' => '[email protected]', 'blocked' => 1]] |
|
23 | + ], |
|
24 | + [ |
|
25 | + 'title' => 'email equal [email protected] or user is blocked:', |
|
26 | + 'content' => ['or' => ['email' => '[email protected]', 'blocked' => 1]] |
|
27 | + ], |
|
28 | + [ |
|
29 | + 'title' => 'email contain John:', |
|
30 | + 'content' => ['email' => ['op' => 'like', 'val' => '%John%']] |
|
31 | + ], |
|
32 | + [ |
|
33 | + 'title' => 'user created after 2016-10-25:', |
|
34 | + 'content' => ['created_at' => ['op' => '>', 'val' => '2016-10-25']] |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'title' => 'user created between 2016-10-20 and 2016-10-25:', |
|
38 | + 'content' => ['created_at' => ['op' => 'between', 'val1' => '2016-10-20', 'val2' => '2016-10-25']] |
|
39 | + ], |
|
40 | + [ |
|
41 | + 'title' => 'user id in 1,2,3:', |
|
42 | + 'content' => ['id' => ['op' => 'in', 'val' => [1, 2, 3]]] |
|
43 | + ], |
|
44 | + [ |
|
45 | + 'title' => 'user name is null:', |
|
46 | + 'content' => ['name' => ['op' => 'null']] |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'title' => 'user name is not null:', |
|
50 | + 'content' => ['name' => ['op' => 'not null']] |
|
51 | + ], |
|
52 | + [ |
|
53 | + 'title' => 'user has group admin:', |
|
54 | + 'content' => ['groups' => ['op' => 'has', 'val' => ['name' => 'Admin']]] |
|
55 | + ] |
|
56 | + ]; |
|
57 | 57 | |
58 | - $paginateObject = [ |
|
59 | - 'total' => 50, |
|
60 | - 'per_page' => 15, |
|
61 | - 'current_page' => 1, |
|
62 | - 'last_page' => 4, |
|
63 | - 'next_page_url' => 'apiUrl?page=2', |
|
64 | - 'prev_page_url' => null, |
|
65 | - 'from' => 1, |
|
66 | - 'to' => 15, |
|
67 | - 'data' => ['The model object'] |
|
68 | - ]; |
|
58 | + $paginateObject = [ |
|
59 | + 'total' => 50, |
|
60 | + 'per_page' => 15, |
|
61 | + 'current_page' => 1, |
|
62 | + 'last_page' => 4, |
|
63 | + 'next_page_url' => 'apiUrl?page=2', |
|
64 | + 'prev_page_url' => null, |
|
65 | + 'from' => 1, |
|
66 | + 'to' => 15, |
|
67 | + 'data' => ['The model object'] |
|
68 | + ]; |
|
69 | 69 | |
70 | - $avaialableReports = \Core::reports()->all(); |
|
70 | + $avaialableReports = \Core::reports()->all(); |
|
71 | 71 | |
72 | - return view('core::doc', ['modules' => $modules, 'reports' => $reports, 'errors' => $errors, 'conditions' => $conditions, 'models' => $models, 'paginateObject' => json_encode($paginateObject, JSON_PRETTY_PRINT), 'avaialableReports' => $avaialableReports]); |
|
73 | - } |
|
72 | + return view('core::doc', ['modules' => $modules, 'reports' => $reports, 'errors' => $errors, 'conditions' => $conditions, 'models' => $models, 'paginateObject' => json_encode($paginateObject, JSON_PRETTY_PRINT), 'avaialableReports' => $avaialableReports]); |
|
73 | + } |
|
74 | 74 | } |