-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from tomatophp/develop
add app store
- Loading branch information
Showing
43 changed files
with
1,342 additions
and
83 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,13 @@ | ||
<?php | ||
|
||
namespace Modules\CircleApps\App\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class CircleApps extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'circle-apps'; | ||
} | ||
} |
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 Modules\CircleApps\App\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* @method static array get() | ||
* @method static void register(string|array $menus) | ||
*/ | ||
class CircleAppsMenu extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'circle-apps-menu'; | ||
} | ||
} |
Empty file.
170 changes: 170 additions & 0 deletions
170
Modules/CircleApps/App/Http/Controllers/AppController.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,170 @@ | ||
<?php | ||
|
||
namespace Modules\CircleApps\App\Http\Controllers; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\View\View; | ||
use TomatoPHP\TomatoAdmin\Facade\Tomato; | ||
|
||
class AppController extends Controller | ||
{ | ||
public string $model; | ||
|
||
public function __construct() | ||
{ | ||
$this->model = \Modules\CircleApps\App\Models\App::class; | ||
} | ||
|
||
/** | ||
* @param Request $request | ||
* @return View|JsonResponse | ||
*/ | ||
public function index(Request $request): View|JsonResponse | ||
{ | ||
return Tomato::index( | ||
request: $request, | ||
model: $this->model, | ||
view: 'circle-apps::apps.index', | ||
table: \Modules\CircleApps\App\Tables\AppTable::class | ||
); | ||
} | ||
|
||
/** | ||
* @param Request $request | ||
* @return JsonResponse | ||
*/ | ||
public function api(Request $request): JsonResponse | ||
{ | ||
return Tomato::json( | ||
request: $request, | ||
model: \Modules\CircleApps\App\Models\App::class, | ||
); | ||
} | ||
|
||
/** | ||
* @return View | ||
*/ | ||
public function create(): View | ||
{ | ||
return Tomato::create( | ||
view: 'circle-apps::apps.create', | ||
); | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleApps\App\Http\Requests\App\AppStoreRequest $request | ||
* @return RedirectResponse|JsonResponse | ||
*/ | ||
public function store(\Modules\CircleApps\App\Http\Requests\App\AppStoreRequest $request): RedirectResponse|JsonResponse | ||
{ | ||
$response = Tomato::store( | ||
request: $request, | ||
model: \Modules\CircleApps\App\Models\App::class, | ||
message: __('App updated successfully'), | ||
redirect: 'admin.apps.index', | ||
hasMedia: true, | ||
collection: [ | ||
'logo' => false, | ||
'cover' => false, | ||
] | ||
); | ||
|
||
$response->record->categories()->sync($request->categories); | ||
|
||
if($response instanceof JsonResponse){ | ||
return $response; | ||
} | ||
|
||
return $response->redirect; | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleApps\App\Models\App $model | ||
* @return View|JsonResponse | ||
*/ | ||
public function show(\Modules\CircleApps\App\Models\App $model): View|JsonResponse | ||
{ | ||
return Tomato::get( | ||
model: $model, | ||
view: 'circle-apps::apps.show', | ||
hasMedia: true, | ||
collection: [ | ||
'logo' => false, | ||
'cover' => false, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleApps\App\Models\App $model | ||
* @return View | ||
*/ | ||
public function edit(\Modules\CircleApps\App\Models\App $model): View | ||
{ | ||
$model->categories = $model->categories->pluck('id')->toArray(); | ||
return Tomato::get( | ||
model: $model, | ||
view: 'circle-apps::apps.edit', | ||
hasMedia: true, | ||
collection: [ | ||
'logo' => false, | ||
'cover' => false, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleApps\App\Http\Requests\App\AppUpdateRequest $request | ||
* @param \Modules\CircleApps\App\Models\App $model | ||
* @return RedirectResponse|JsonResponse | ||
*/ | ||
public function update(\Modules\CircleApps\App\Http\Requests\App\AppUpdateRequest $request, \Modules\CircleApps\App\Models\App $model): RedirectResponse|JsonResponse | ||
{ | ||
$response = Tomato::update( | ||
request: $request, | ||
model: $model, | ||
message: __('App updated successfully'), | ||
redirect: 'admin.apps.index', | ||
hasMedia: true, | ||
collection: [ | ||
'logo' => false, | ||
'cover' => false, | ||
] | ||
); | ||
|
||
$response->record->categories()->sync($request->categories); | ||
|
||
if($response instanceof JsonResponse){ | ||
return $response; | ||
} | ||
|
||
return $response->redirect; | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleApps\App\Models\App $model | ||
* @return RedirectResponse|JsonResponse | ||
*/ | ||
public function destroy(\Modules\CircleApps\App\Models\App $model): RedirectResponse|JsonResponse | ||
{ | ||
$response = Tomato::destroy( | ||
model: $model, | ||
message: __('App deleted successfully'), | ||
redirect: 'admin.apps.index', | ||
hasMedia: true, | ||
collection: [ | ||
'logo' => false, | ||
'cover' => false, | ||
] | ||
); | ||
|
||
if($response instanceof JsonResponse){ | ||
return $response; | ||
} | ||
|
||
return $response->redirect; | ||
} | ||
} |
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
Empty file.
Empty file.
47 changes: 47 additions & 0 deletions
47
Modules/CircleApps/App/Http/Requests/App/AppStoreRequest.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,47 @@ | ||
<?php | ||
|
||
namespace Modules\CircleApps\App\Http\Requests\App; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class AppStoreRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'account_id' => 'nullable|exists:accounts,id', | ||
'name' => 'required|max:255|string', | ||
'description' => 'nullable|max:255|string', | ||
'key' => 'required|string', | ||
'readme' => 'nullable', | ||
'homepage' => 'nullable|max:255|string', | ||
'email' => 'nullable|max:255|string|email', | ||
'docs' => 'nullable|max:255|string', | ||
'github' => 'nullable|max:255|string', | ||
'privacy' => 'nullable|max:255|string', | ||
'faq' => 'nullable|max:255|string', | ||
'status' => 'nullable|max:255|string', | ||
'is_active' => 'nullable', | ||
'price' => 'nullable', | ||
'price_per' => 'nullable|max:255|string', | ||
'discount' => 'nullable', | ||
'discount_to' => 'nullable', | ||
'is_free' => 'nullable' | ||
]; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
Modules/CircleApps/App/Http/Requests/App/AppUpdateRequest.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,47 @@ | ||
<?php | ||
|
||
namespace Modules\CircleApps\App\Http\Requests\App; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class AppUpdateRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'account_id' => 'nullable|exists:accounts,id', | ||
'name' => 'sometimes|max:255|string', | ||
'description' => 'nullable|max:255|string', | ||
'key' => 'sometimes|string', | ||
'readme' => 'nullable', | ||
'homepage' => 'nullable|max:255|string', | ||
'email' => 'nullable|max:255|string|email', | ||
'docs' => 'nullable|max:255|string', | ||
'github' => 'nullable|max:255|string', | ||
'privacy' => 'nullable|max:255|string', | ||
'faq' => 'nullable|max:255|string', | ||
'status' => 'nullable|max:255|string', | ||
'is_active' => 'nullable', | ||
'price' => 'nullable', | ||
'price_per' => 'nullable|max:255|string', | ||
'discount' => 'nullable', | ||
'discount_to' => 'nullable', | ||
'is_free' => 'nullable' | ||
]; | ||
} | ||
} |
Empty file.
Oops, something went wrong.