Skip to content

Commit d59f39a

Browse files
committed
akaunting 3.0 compatibility
1 parent df3eac3 commit d59f39a

Some content is hidden

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

59 files changed

+17162
-1102
lines changed

.gitignore

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/.idea
2-
/.vscode
3-
/.vagrant
4-
/node_modules
5-
/Resources/assets/js/*.min.js
6-
/storage/*.keyr
7-
/vendor
1+
/.idea
2+
/.vscode
3+
/.vagrant
4+
/node_modules
5+
/Resources/assets/js/*.min.js
6+
/storage/*.keyr
7+
/vendor

BulkActions/Comments.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ class Comments extends BulkAction
1111
{
1212
public $model = Comment::class;
1313

14+
public $text = 'my-blog::general.comments';
15+
16+
public $path = [
17+
'group' => 'my-blog',
18+
'type' => 'comments',
19+
];
20+
1421
public $actions = [
1522
'delete' => [
1623
'name' => 'general.delete',

BulkActions/Posts.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ class Posts extends BulkAction
1111
{
1212
public $model = Post::class;
1313

14+
public $text = 'my-blog::general.posts';
15+
16+
public $path = [
17+
'group' => 'my-blog',
18+
'type' => 'posts',
19+
];
20+
1421
public $actions = [
1522
'enable' => [
1623
'name' => 'general.enable',

Database/Seeds/Categories.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
namespace Modules\MyBlog\Database\Seeds;
44

55
use App\Abstracts\Model;
6-
use App\Models\Setting\Category;
6+
use App\Jobs\Setting\CreateCategory;
7+
use App\Traits\Jobs;
78
use Illuminate\Database\Seeder;
89

910
class Categories extends Seeder
1011
{
12+
use Jobs;
13+
1114
public function run()
1215
{
1316
Model::unguard();
@@ -39,7 +42,9 @@ private function create()
3942
];
4043

4144
foreach ($categories as $category) {
42-
Category::firstOrCreate($category);
45+
$category['created_from'] = 'my-blog::seed';
46+
47+
$this->dispatch(new CreateCategory($category));
4348
}
4449
}
4550
}

Database/Seeds/Dashboards.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ private function create()
3434
'name' => trans('my-blog::general.name'),
3535
'all_users' => true,
3636
'default_widgets' => 'my-blog',
37+
'created_from' => 'my-blog::seed',
3738
]));
3839
}
3940
}

Database/Seeds/EmailTemplates.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
namespace Modules\MyBlog\Database\Seeds;
44

55
use App\Abstracts\Model;
6-
use App\Models\Common\EmailTemplate;
6+
use App\Traits\Jobs;
77
use Illuminate\Database\Seeder;
8+
use App\Jobs\Setting\CreateEmailTemplate;
89

910
class EmailTemplates extends Seeder
1011
{
12+
use Jobs;
13+
1114
public function run()
1215
{
1316
Model::unguard();
@@ -35,14 +38,15 @@ private function create()
3538
];
3639

3740
foreach ($templates as $template) {
38-
EmailTemplate::firstOrCreate([
39-
'company_id' => $company_id,
40-
'alias' => $template['alias'],
41-
'class' => $template['class'],
42-
'name' => $template['name'],
43-
'subject' => trans('my-blog::email_templates.' . $template['alias'] . '.subject'),
44-
'body' => trans('my-blog::email_templates.' . $template['alias'] . '.body'),
45-
]);
41+
$this->dispatch(new CreateEmailTemplate([
42+
'company_id' => $company_id,
43+
'alias' => $template['alias'],
44+
'class' => $template['class'],
45+
'name' => $template['name'],
46+
'subject' => trans('my-blog::email_templates.' . $template['alias'] . '.subject'),
47+
'body' => trans('my-blog::email_templates.' . $template['alias'] . '.body'),
48+
'created_from' => 'my-blog::seed',
49+
]));
4650
}
4751
}
4852
}

Database/Seeds/Reports.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
namespace Modules\MyBlog\Database\Seeds;
44

55
use App\Abstracts\Model;
6-
use App\Models\Common\Report;
6+
use App\Jobs\Common\CreateReport;
7+
use App\Traits\Jobs;
78
use Illuminate\Database\Seeder;
89

910
class Reports extends Seeder
1011
{
12+
use Jobs;
13+
1114
/**
1215
* Run the database seeds.
1316
*
@@ -32,19 +35,21 @@ private function create()
3235
'class' => 'Modules\MyBlog\Reports\PostSummary',
3336
'name' => trans('my-blog::reports.post_name'),
3437
'description' => trans('my-blog::reports.post_description'),
35-
'settings' => ['group' => 'category', 'period' => 'monthly', 'chart' => 'line'],
38+
'settings' => ['group' => 'category', 'period' => 'monthly'],
3639
],
3740
[
3841
'company_id' => $company_id,
3942
'class' => 'Modules\MyBlog\Reports\CommentSummary',
4043
'name' => trans('my-blog::reports.comment_name'),
4144
'description' => trans('my-blog::reports.comment_description'),
42-
'settings' => ['group' => 'post', 'period' => 'monthly', 'chart' => 'line'],
45+
'settings' => ['group' => 'post', 'period' => 'monthly'],
4346
],
4447
];
4548

4649
foreach ($rows as $row) {
47-
Report::create($row);
50+
$row['created_from'] = 'core::seed';
51+
52+
$this->dispatch(new CreateReport($row));
4853
}
4954
}
5055
}

Http/Controllers/Api/Comments.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,78 @@
44

55
use App\Abstracts\Http\ApiController;
66
use Modules\MyBlog\Http\Requests\Comment as Request;
7+
use Modules\MyBlog\Http\Resources\Comment as Resource;
78
use Modules\MyBlog\Jobs\CreateComment;
89
use Modules\MyBlog\Jobs\DeleteComment;
910
use Modules\MyBlog\Jobs\UpdateComment;
1011
use Modules\MyBlog\Models\Comment;
11-
use Modules\MyBlog\Transformers\Comment as Transformer;
1212

1313
class Comments extends ApiController
1414
{
1515
/**
1616
* Display a listing of the resource.
1717
*
18-
* @return \Dingo\Api\Http\Response
18+
* @return \Illuminate\Http\JsonResponse
1919
*/
2020
public function index()
2121
{
2222
$comments = Comment::collect();
2323

24-
return $this->response->paginator($comments, new Transformer());
24+
return Resource::collection($comments);
2525
}
2626

2727
/**
2828
* Display the specified resource.
2929
*
3030
* @param int|string $id
31-
* @return \Dingo\Api\Http\Response
31+
* @return \Illuminate\Http\JsonResponse
3232
*/
3333
public function show(Comment $comment)
3434
{
35-
return $this->item($comment, new Transformer());
35+
return new Resource($comment);
3636
}
3737

3838
/**
3939
* Store a newly created resource in storage.
4040
*
4141
* @param $request
42-
* @return \Dingo\Api\Http\Response
42+
* @return \Illuminate\Http\JsonResponse
4343
*/
4444
public function store(Request $request)
4545
{
4646
$comment = $this->dispatch(new CreateComment($request));
4747

48-
return $this->response->created(route('api.my-blog.comments.show', $comment->id), $this->item($comment, new Transformer()));
48+
return $this->created(route('api.my-blog.comments.show', $comment->id), new Resource($comment));
4949
}
5050

5151
/**
5252
* Update the specified resource in storage.
5353
*
5454
* @param $comment
5555
* @param $request
56-
* @return \Dingo\Api\Http\Response
56+
* @return \Illuminate\Http\JsonResponse
5757
*/
5858
public function update(Comment $comment, Request $request)
5959
{
6060
$comment = $this->dispatch(new UpdateComment($comment, $request));
6161

62-
return $this->item($comment->fresh(), new Transformer());
62+
return new Resource($comment->fresh());
6363
}
6464

6565
/**
6666
* Remove the specified resource from storage.
6767
*
6868
* @param Comment $comment
69-
* @return \Dingo\Api\Http\Response
69+
* @return \Illuminate\Http\Response
7070
*/
7171
public function destroy(Comment $comment)
7272
{
7373
try {
7474
$this->dispatch(new DeleteComment($comment));
7575

76-
return $this->response->noContent();
76+
return $this->noContent();
7777
} catch(\Exception $e) {
78-
$this->response->errorUnauthorized($e->getMessage());
78+
$this->errorUnauthorized($e->getMessage());
7979
}
8080
}
8181
}

Http/Controllers/Api/Posts.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,97 +4,97 @@
44

55
use App\Abstracts\Http\ApiController;
66
use Modules\MyBlog\Http\Requests\Post as Request;
7+
use Modules\MyBlog\Http\Resources\Post as Resource;
78
use Modules\MyBlog\Jobs\CreatePost;
89
use Modules\MyBlog\Jobs\DeletePost;
910
use Modules\MyBlog\Jobs\UpdatePost;
1011
use Modules\MyBlog\Models\Post;
11-
use Modules\MyBlog\Transformers\Post as Transformer;
1212

1313
class Posts extends ApiController
1414
{
1515
/**
1616
* Display a listing of the resource.
1717
*
18-
* @return \Dingo\Api\Http\Response
18+
* @return \Illuminate\Http\JsonResponse
1919
*/
2020
public function index()
2121
{
2222
$posts = Post::with('category', 'comments')->collect();
2323

24-
return $this->response->paginator($posts, new Transformer());
24+
return Resource::collection($posts);
2525
}
2626

2727
/**
2828
* Display the specified resource.
2929
*
3030
* @param int $id
31-
* @return \Dingo\Api\Http\Response
31+
* @return \Illuminate\Http\JsonResponse
3232
*/
3333
public function show($id)
3434
{
3535
$post = Post::with('category', 'comments')->find($id);
3636

37-
return $this->item($post, new Transformer());
37+
return new Resource($post);
3838
}
3939

4040
/**
4141
* Store a newly created resource in storage.
4242
*
4343
* @param $request
44-
* @return \Dingo\Api\Http\Response
44+
* @return \Illuminate\Http\JsonResponse
4545
*/
4646
public function store(Request $request)
4747
{
4848
$post = $this->dispatch(new CreatePost($request));
4949

50-
return $this->response->created(route('api.my-blog.posts.show', $post->id), $this->item($post, new Transformer()));
50+
return $this->created(route('api.my-blog.posts.show', $post->id), new Resource($post));
5151
}
5252

5353
/**
5454
* Update the specified resource in storage.
5555
*
5656
* @param $post
5757
* @param $request
58-
* @return \Dingo\Api\Http\Response
58+
* @return \Illuminate\Http\JsonResponse
5959
*/
6060
public function update(Post $post, Request $request)
6161
{
6262
$post = $this->dispatch(new UpdatePost($post, $request));
6363

64-
return $this->item($post->fresh(), new Transformer());
64+
return new Resource($post->fresh());
6565
}
6666

6767
/**
6868
* Enable the specified resource in storage.
6969
*
7070
* @param Post $post
71-
* @return \Dingo\Api\Http\Response
71+
* @return \Illuminate\Http\JsonResponse
7272
*/
7373
public function enable(Post $post)
7474
{
7575
$post = $this->dispatch(new UpdatePost($post, request()->merge(['enabled' => 1])));
7676

77-
return $this->item($post->fresh(), new Transformer());
77+
return new Resource($post->fresh());
7878
}
7979

8080
/**
8181
* Disable the specified resource in storage.
8282
*
8383
* @param Post $post
84-
* @return \Dingo\Api\Http\Response
84+
* @return \Illuminate\Http\JsonResponse
8585
*/
8686
public function disable(Post $post)
8787
{
8888
$post = $this->dispatch(new UpdatePost($post, request()->merge(['enabled' => 0])));
8989

90-
return $this->item($post->fresh(), new Transformer());
90+
return new Resource($post->fresh());
9191
}
9292

9393
/**
9494
* Remove the specified resource from storage.
9595
*
9696
* @param int $id
97-
* @return \Dingo\Api\Http\Response
97+
* @return \Illuminate\Http\Response
9898
*/
9999
public function destroy($id)
100100
{
@@ -103,9 +103,9 @@ public function destroy($id)
103103
try {
104104
$this->dispatch(new DeletePost($post));
105105

106-
return $this->response->noContent();
106+
return $this->noContent();
107107
} catch(\Exception $e) {
108-
$this->response->errorUnauthorized($e->getMessage());
108+
$this->errorUnauthorized($e->getMessage());
109109
}
110110
}
111111
}

0 commit comments

Comments
 (0)