-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf90621
commit d8d0703
Showing
30 changed files
with
1,487 additions
and
5 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
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
event.edit.heading="活動: :event | :title" | ||
event.stage.edit.heading="活動: :event | 梯次: :stage | :title" | ||
|
||
event.invoice.type.personal="個人" | ||
event.invoice.type.business="公司" |
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Migration; | ||
|
||
use Windwalker\Core\Console\ConsoleApplication; | ||
use Windwalker\Core\Migration\Migration; | ||
use Windwalker\Database\Schema\Schema; | ||
|
||
/** | ||
* Migration UP: 2024070905230001_EventOrderInit. | ||
* | ||
* @var Migration $mig | ||
* @var ConsoleApplication $app | ||
*/ | ||
$mig->up( | ||
static function () use ($mig) { | ||
// $mig->updateTable( | ||
// Table::class, | ||
// function (Schema $schema) {} | ||
// ); | ||
} | ||
); | ||
|
||
/** | ||
* Migration DOWN. | ||
*/ | ||
$mig->down( | ||
static function () use ($mig) { | ||
// $mig->dropTableColumns(Table::class, 'column'); | ||
} | ||
); |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Routes; | ||
|
||
use App\Module\Admin\EventOrder\EventOrderController; | ||
use App\Module\Admin\EventOrder\EventOrderEditView; | ||
use App\Module\Admin\EventOrder\EventOrderListView; | ||
use Windwalker\Core\Router\RouteCreator; | ||
|
||
/** @var RouteCreator $router */ | ||
|
||
$router->group('event-order') | ||
->extra('menu', ['sidemenu' => 'event_order_list']) | ||
->register(function (RouteCreator $router) { | ||
$router->any('event_order_list', '/event-order/list') | ||
->controller(EventOrderController::class) | ||
->view(EventOrderListView::class) | ||
->postHandler('copy') | ||
->putHandler('filter') | ||
->patchHandler('batch'); | ||
|
||
$router->any('event_order_edit', '/event-order/edit[/{id}]') | ||
->controller(EventOrderController::class) | ||
->view(EventOrderEditView::class); | ||
}); |
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,73 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Module\Admin\EventOrder; | ||
|
||
use App\Module\Admin\EventOrder\Form\EditForm; | ||
use App\Repository\EventOrderRepository; | ||
use Unicorn\Controller\CrudController; | ||
use Unicorn\Controller\GridController; | ||
use Windwalker\Core\Application\AppContext; | ||
use Windwalker\Core\Attributes\Controller; | ||
use Windwalker\Core\Router\Navigator; | ||
use Windwalker\DI\Attributes\Autowire; | ||
|
||
#[Controller()] | ||
class EventOrderController | ||
{ | ||
public function save( | ||
AppContext $app, | ||
CrudController $controller, | ||
Navigator $nav, | ||
#[Autowire] EventOrderRepository $repository, | ||
): mixed { | ||
$form = $app->make(EditForm::class); | ||
|
||
$uri = $app->call($controller->saveWithNamespace(...), compact('repository', 'form')); | ||
|
||
return match ($app->input('task')) { | ||
'save2close' => $nav->to('event_order_list'), | ||
default => $uri, | ||
}; | ||
} | ||
|
||
public function delete( | ||
AppContext $app, | ||
#[Autowire] EventOrderRepository $repository, | ||
CrudController $controller | ||
): mixed { | ||
return $app->call($controller->delete(...), compact('repository')); | ||
} | ||
|
||
public function filter( | ||
AppContext $app, | ||
#[Autowire] EventOrderRepository $repository, | ||
GridController $controller | ||
): mixed { | ||
return $app->call($controller->filter(...), compact('repository')); | ||
} | ||
|
||
public function batch( | ||
AppContext $app, | ||
#[Autowire] EventOrderRepository $repository, | ||
GridController $controller | ||
): mixed { | ||
$task = $app->input('task'); | ||
$data = match ($task) { | ||
'publish' => ['state' => 1], | ||
'unpublish' => ['state' => 0], | ||
default => null | ||
}; | ||
|
||
return $app->call($controller->batch(...), compact('repository', 'data')); | ||
} | ||
|
||
public function copy( | ||
AppContext $app, | ||
#[Autowire] EventOrderRepository $repository, | ||
GridController $controller | ||
): mixed { | ||
return $app->call($controller->copy(...), compact('repository')); | ||
} | ||
} |
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,91 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Module\Admin\EventOrder; | ||
|
||
use App\Entity\Event; | ||
use App\Entity\EventAttend; | ||
use App\Entity\EventOrder; | ||
use App\Entity\EventPlan; | ||
use App\Entity\EventStage; | ||
use App\Module\Admin\EventOrder\Form\EditForm; | ||
use App\Repository\EventOrderRepository; | ||
use Unicorn\View\FormAwareViewModelTrait; | ||
use Unicorn\View\ORMAwareViewModelTrait; | ||
use Windwalker\Core\Application\AppContext; | ||
use Windwalker\Core\Attributes\ViewMetadata; | ||
use Windwalker\Core\Attributes\ViewModel; | ||
use Windwalker\Core\Html\HtmlFrame; | ||
use Windwalker\Core\Language\TranslatorTrait; | ||
use Windwalker\Core\View\View; | ||
use Windwalker\Core\View\ViewModelInterface; | ||
use Windwalker\DI\Attributes\Autowire; | ||
|
||
/** | ||
* The EventOrderEditView class. | ||
*/ | ||
#[ViewModel( | ||
layout: 'event-order-edit', | ||
js: 'event-order-edit.js' | ||
)] | ||
class EventOrderEditView implements ViewModelInterface | ||
{ | ||
use TranslatorTrait; | ||
use ORMAwareViewModelTrait; | ||
use FormAwareViewModelTrait; | ||
|
||
public function __construct( | ||
#[Autowire] protected EventOrderRepository $repository, | ||
) { | ||
} | ||
|
||
/** | ||
* Prepare | ||
* | ||
* @param AppContext $app | ||
* @param View $view | ||
* | ||
* @return mixed | ||
*/ | ||
public function prepare(AppContext $app, View $view): mixed | ||
{ | ||
$id = $app->input('id'); | ||
|
||
/** @var EventOrder $item */ | ||
$item = $this->repository->mustGetItem($id); | ||
|
||
// $event = $this->orm->mustFindOne(Event::class, $item->getEventId()); | ||
// $eventStage = $this->orm->mustFindOne(EventStage::class, $item->getStageId()); | ||
|
||
$attends = $this->orm->from(EventAttend::class) | ||
->leftJoin( | ||
EventPlan::class, | ||
'plan' | ||
) | ||
->where('event_attend.order_id', $item->getId()) | ||
->groupByJoins() | ||
->all(EventAttend::class); | ||
|
||
// Bind item for injection | ||
$view[EventOrder::class] = $item; | ||
|
||
$form = $this->createForm(EditForm::class) | ||
->fill( | ||
[ | ||
'item' => $this->repository->getState()->getAndForget('edit.data') | ||
?: $this->orm->extractEntity($item) | ||
] | ||
); | ||
|
||
return compact('form', 'id', 'item', 'attends'); | ||
} | ||
|
||
#[ViewMetadata] | ||
protected function prepareMetadata(HtmlFrame $htmlFrame): void | ||
{ | ||
$htmlFrame->setTitle( | ||
$this->trans('unicorn.title.edit', title: '訂單') | ||
); | ||
} | ||
} |
Oops, something went wrong.