-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add counter optional url field * wip * enable budget upper label * fix: buget level add item * wip * feat: add decision number / date * feat: add decision authors * wip * feat: localize datepicker
- Loading branch information
Showing
32 changed files
with
767 additions
and
37 deletions.
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
app/Http/Controllers/Admin/DecisionAuthorController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Http\Requests\Admin\DecisionAuthorRequest; | ||
use App\Http\Resources\Collections\DecisionAuthorCollection; | ||
use App\Http\Resources\DecisionAuthorResource; | ||
use App\Models\DecisionAuthor; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Http\RedirectResponse; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class DecisionAuthorController extends AdminController | ||
{ | ||
public function index(): Response | ||
{ | ||
return Inertia::render('Decisions/Authors/Index', [ | ||
'collection' => new DecisionAuthorCollection( | ||
DecisionAuthor::query() | ||
->withCount([ | ||
'decisions' => function (Builder $query) { | ||
$query->withDrafted(); | ||
}, | ||
]) | ||
->sort() | ||
->filter() | ||
->paginate() | ||
), | ||
'subnav' => $this->subnav(), | ||
]); | ||
} | ||
|
||
public function create(): Response | ||
{ | ||
return Inertia::render('Decisions/Authors/Edit', [ | ||
// | ||
])->model(DecisionAuthor::class); | ||
} | ||
|
||
public function store(DecisionAuthorRequest $request): RedirectResponse | ||
{ | ||
$attributes = $request->validated(); | ||
|
||
$decisionAuthor = DecisionAuthor::create($attributes); | ||
|
||
return redirect()->route('admin.decision_authors.edit', $decisionAuthor) | ||
->with('success', __('decision_author.event.created')); | ||
} | ||
|
||
public function edit(DecisionAuthor $decisionAuthor): Response | ||
{ | ||
return Inertia::render('Decisions/Authors/Edit', [ | ||
'resource' => DecisionAuthorResource::make($decisionAuthor), | ||
'subnav' => $this->subnav(), | ||
])->model(DecisionAuthor::class); | ||
} | ||
|
||
public function update(DecisionAuthorRequest $request, DecisionAuthor $decisionAuthor): RedirectResponse | ||
{ | ||
$attributes = $request->validated(); | ||
|
||
$decisionAuthor->update($attributes); | ||
|
||
return redirect()->route('admin.decision_authors.edit', $decisionAuthor) | ||
->with('success', __('decision_author.event.updated')); | ||
} | ||
|
||
public function duplicate(DecisionAuthor $decisionAuthor): RedirectResponse | ||
{ | ||
$duplicate = $decisionAuthor->duplicate(); | ||
|
||
return redirect()->route('admin.decision_authors.edit', $duplicate) | ||
->with('success', __('decision_author.event.duplicated')); | ||
} | ||
|
||
public function destroy(DecisionAuthor $decisionAuthor): RedirectResponse | ||
{ | ||
$decisionAuthor->delete(); | ||
|
||
return redirect()->route('admin.decision_authors.index') | ||
->with('success', __('decision_author.event.deleted')); | ||
} | ||
|
||
public function restore(DecisionAuthor $decisionAuthor): RedirectResponse | ||
{ | ||
$decisionAuthor->restore(); | ||
|
||
return redirect()->route('admin.decision_authors.edit', $decisionAuthor) | ||
->with('success', __('decision_author.event.restored')); | ||
} | ||
|
||
public function forceDelete(DecisionAuthor $decisionAuthor): RedirectResponse | ||
{ | ||
$decisionAuthor->forceDelete(); | ||
|
||
return redirect()->route('admin.decision_authors.index') | ||
->with('success', __('decision_author.event.deleted')); | ||
} | ||
|
||
protected function subnav(): array | ||
{ | ||
return [ | ||
[ | ||
'label' => 'decision.subnav.decisions', | ||
'route' => 'admin.decisions.index', | ||
], | ||
[ | ||
'label' => 'decision.subnav.categories', | ||
'route' => 'admin.decision_categories.index', | ||
], | ||
[ | ||
'label' => 'decision.subnav.authors', | ||
'route' => 'admin.decision_authors.index', | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Front; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\DecisionAuthor; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\View\View; | ||
|
||
class DecisionAuthorController extends Controller | ||
{ | ||
public function index(): RedirectResponse | ||
{ | ||
return redirect()->route('front.decisions.index'); | ||
} | ||
|
||
public function show(string $locale, DecisionAuthor $decisionAuthor): View | ||
{ | ||
seo() | ||
->title($decisionAuthor->title) | ||
->description($decisionAuthor->description); | ||
|
||
return view('front.decisions.category', [ | ||
'category' => $decisionAuthor, | ||
'decisions' => $decisionAuthor | ||
->decisions() | ||
->paginate(12), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Requests\Admin; | ||
|
||
use App\Models\DecisionAuthor; | ||
use App\Services\TranslatableFormRequestRules; | ||
use Illuminate\Foundation\Http\FormRequest as BaseRequest; | ||
|
||
class DecisionAuthorRequest extends BaseRequest | ||
{ | ||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules(): array | ||
{ | ||
return TranslatableFormRequestRules::make(DecisionAuthor::class, [ | ||
'title' => ['required', 'string', 'max:200'], | ||
'slug' => ['nullable', 'string', 'max:200'], | ||
'description' => ['nullable', 'string'], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/Http/Resources/Collections/DecisionAuthorCollection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Resources\Collections; | ||
|
||
class DecisionAuthorCollection extends ResourceCollection | ||
{ | ||
/** | ||
* The default table columns. | ||
* | ||
* @var array | ||
*/ | ||
protected array $columns = [ | ||
'title', 'decisions_count', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
class DecisionAuthorResource extends Resource | ||
{ | ||
public array $routeMap = [ | ||
'admin.decision_authors.index' => 'index', | ||
'admin.decision_authors.edit' => 'edit', | ||
]; | ||
|
||
protected function index(Request $request): array | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'title' => $this->title, | ||
'slug' => $this->slug, | ||
'decisions_count' => $this->decisions_count, | ||
'trashed' => $this->trashed(), | ||
]; | ||
} | ||
|
||
protected function edit(Request $request): array | ||
{ | ||
return [ | ||
'id' => $this->id, | ||
'title' => $this->getTranslations('title'), | ||
'description' => $this->getTranslations('description'), | ||
'slug' => $this->getTranslations('slug'), | ||
]; | ||
} | ||
|
||
protected function default(Request $request): array | ||
{ | ||
$this->withoutPermissions(); | ||
|
||
return [ | ||
'id' => $this->id, | ||
'title' => $this->title, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.