-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Migration * Models * Factory * New menu and fix bug * Awesome FE * language APIz * translationGroups APIz * translations APIz * translations APIz * Language Test * Translation Group Tests * Added tests * Languages Console UI * Languages Console UI * Translation Group Console UI * Create Translation UI * Create Translation UI * Update Translation UI * Update Translation UI * new metadata language * pivot for template and translation group * pivot for template and translation group * language renderer * Translations tests * UI fix * reverted changes
- Loading branch information
1 parent
17686fd
commit e1b0673
Showing
62 changed files
with
3,056 additions
and
70 deletions.
There are no files selected for viewing
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,56 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\LanguageIndexRequest; | ||
use App\Http\Requests\LanguageStoreRequest; | ||
use App\Http\Requests\LanguageUpdateRequest; | ||
use App\Http\Resources\LanguageResource; | ||
use App\Models\Language; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class LanguageController extends Controller | ||
{ | ||
public function index(LanguageIndexRequest $request): JsonResponse | ||
{ | ||
$fonts = $request->buildQueryBuilder() | ||
->get(); | ||
|
||
return LanguageResource::collection($fonts)->response(); | ||
} | ||
|
||
public function show(Language $language): JsonResponse | ||
{ | ||
return LanguageResource::make($language)->response(); | ||
} | ||
|
||
public function store(LanguageStoreRequest $request): JsonResponse | ||
{ | ||
$language = Language::create($request->validated()); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $language->uuid, | ||
'created' => $language->wasRecentlyCreated, | ||
]); | ||
} | ||
|
||
public function update(LanguageUpdateRequest $request, Language $language): JsonResponse | ||
{ | ||
$updateStatus = $language->update($request->validated()); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $language->uuid, | ||
'updated' => $updateStatus, | ||
]); | ||
} | ||
|
||
public function destroy(Language $language): JsonResponse | ||
{ | ||
$deleteResult = $language->delete(); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $language->uuid, | ||
'deleted' => $deleteResult, | ||
]); | ||
} | ||
} |
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,67 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\TranslationIndexRequest; | ||
use App\Http\Requests\TranslationStoreRequest; | ||
use App\Http\Requests\TranslationUpdateRequest; | ||
use App\Http\Resources\TranslationResource; | ||
use App\Models\Translation; | ||
use App\Models\TranslationGroup; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class TranslationController extends Controller | ||
{ | ||
public function index(TranslationIndexRequest $request): JsonResponse | ||
{ | ||
$translations = $request->buildQueryBuilder() | ||
->with(['translationGroup']) | ||
->paginate(); | ||
|
||
return TranslationResource::collection($translations)->response(); | ||
} | ||
|
||
public function show(Translation $translation): JsonResponse | ||
{ | ||
return TranslationResource::make($translation)->response(); | ||
} | ||
|
||
public function store(TranslationStoreRequest $request): JsonResponse | ||
{ | ||
$translationGroup = TranslationGroup::find($request->validated('translation_group_id')); | ||
$translation = Translation::create([ | ||
...$request->validated(), | ||
'key' => "{$translationGroup->key}.{$request->input('key')}", | ||
]); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $translation->uuid, | ||
'created' => $translation->wasRecentlyCreated, | ||
]); | ||
} | ||
|
||
public function update(TranslationUpdateRequest $request, Translation $translation): JsonResponse | ||
{ | ||
$translationGroup = TranslationGroup::find($request->validated('translation_group_id')); | ||
|
||
$updateStatus = $translation->update([ | ||
...$request->validated(), | ||
'key' => "{$translationGroup->key}.{$request->input('key')}", | ||
]); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $translation->uuid, | ||
'updated' => $updateStatus, | ||
]); | ||
} | ||
|
||
public function destroy(Translation $translation): JsonResponse | ||
{ | ||
$deleteResult = $translation->delete(); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $translation->uuid, | ||
'deleted' => $deleteResult, | ||
]); | ||
} | ||
} |
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,61 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Requests\TranslationGroupIndexRequest; | ||
use App\Http\Requests\TranslationGroupStoreRequest; | ||
use App\Http\Requests\TranslationGroupUpdateRequest; | ||
use App\Http\Resources\TranslationGroupResource; | ||
use App\Models\TranslationGroup; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class TranslationGroupController extends Controller | ||
{ | ||
public function index(TranslationGroupIndexRequest $request): JsonResponse | ||
{ | ||
$translationGroups = $request->buildQueryBuilder() | ||
->paginate(); | ||
|
||
return TranslationGroupResource::collection($translationGroups)->response(); | ||
} | ||
|
||
public function show(TranslationGroup $translationGroup): JsonResponse | ||
{ | ||
return TranslationGroupResource::make($translationGroup)->response(); | ||
} | ||
|
||
public function store(TranslationGroupStoreRequest $request): JsonResponse | ||
{ | ||
$translationGroup = TranslationGroup::create($request->validated()); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $translationGroup->uuid, | ||
'created' => $translationGroup->wasRecentlyCreated, | ||
]); | ||
} | ||
|
||
public function update(TranslationGroupUpdateRequest $request, TranslationGroup $translationGroup): JsonResponse | ||
{ | ||
$updateStatus = $translationGroup->update($request->validated()); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $translationGroup->uuid, | ||
'updated' => $updateStatus, | ||
]); | ||
} | ||
|
||
public function destroy(TranslationGroup $translationGroup): JsonResponse | ||
{ | ||
$deleteResult = DB::transaction(function () use ($translationGroup) { | ||
$translationGroup->translations()->delete(); | ||
|
||
return $translationGroup->delete(); | ||
}); | ||
|
||
return new JsonResponse([ | ||
'uuid' => $translationGroup->uuid, | ||
'deleted' => $deleteResult, | ||
]); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\Language; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class LanguageIndexRequest extends AbstractIndexRequest | ||
{ | ||
protected function getModel(): Model | ||
{ | ||
return new Language(); | ||
} | ||
|
||
protected function getAllowedSortColumns(): array | ||
{ | ||
return [ | ||
'code', | ||
'name', | ||
'created_at', | ||
]; | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\Language; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Validation\Rule; | ||
|
||
class LanguageStoreRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'code' => [ | ||
'required', | ||
'string', | ||
Rule::unique((new Language())->getTable()), | ||
], | ||
'name' => 'required|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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\Language; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Validation\Rule; | ||
|
||
class LanguageUpdateRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'name' => 'required|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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\TranslationGroup; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class TranslationGroupIndexRequest extends AbstractIndexRequest | ||
{ | ||
protected function getModel(): Model | ||
{ | ||
return new TranslationGroup(); | ||
} | ||
|
||
protected function getAllowedSortColumns(): array | ||
{ | ||
return [ | ||
'key', | ||
'name', | ||
'created_at', | ||
]; | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\TranslationGroup; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Validation\Rule; | ||
|
||
class TranslationGroupStoreRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'key' => [ | ||
'required', | ||
'string', | ||
Rule::unique((new TranslationGroup())->getTable()), | ||
], | ||
'name' => 'required|string', | ||
'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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\TranslationGroup; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Validation\Rule; | ||
|
||
class TranslationGroupUpdateRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'name' => 'required|string', | ||
'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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\Translation; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class TranslationIndexRequest extends AbstractIndexRequest | ||
{ | ||
protected function getModel(): Model | ||
{ | ||
return new Translation(); | ||
} | ||
|
||
protected function getAllowedSortColumns(): array | ||
{ | ||
return [ | ||
'key', | ||
'name', | ||
'created_at', | ||
]; | ||
} | ||
} |
Oops, something went wrong.