mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
Merge branch '152_annoucment' into 'master'
update: FE vue announcementlist component. added compoment for attach and... See merge request CIEFWorldwideSdnBhd/exchange-2.0!52
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class HasSegments implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('segments', function ($q) use ($value) {
|
||||
$q->whereIn('id', $value);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class isPublished implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDate('starting_on', '<=', Carbon::now())
|
||||
->whereDate('ending_on', '>=', Carbon::now());
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Services\UpdatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||
use App\Http\Resources\UserResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -58,7 +58,7 @@ class UpdateUserLogic extends AbstractControllerLogic
|
||||
{
|
||||
try {
|
||||
|
||||
$object = new UserObject($request->input('name'));
|
||||
$object = new FullNameObject($request->input('name'));
|
||||
|
||||
$this->canUpdateUser->passes($object);
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class FullnameObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* UserObject constructor.
|
||||
* @param string $name
|
||||
* @param string $email
|
||||
* @param string $password
|
||||
* @param string $passwordConfirmation
|
||||
* @param int|null $type
|
||||
* @param int|null $status
|
||||
*/
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||
use App\Models\User;
|
||||
|
||||
class UpdatesUser extends AbstractUpdateRecord
|
||||
@@ -15,7 +15,7 @@ class UpdatesUser extends AbstractUpdateRecord
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(User $model, UserObject $object) {
|
||||
public function execute(User $model, FullNameObject $object) {
|
||||
|
||||
$model->name = $object->getName();
|
||||
return $this->handler($model);
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Processors\AssignAnnouncementToSegmentProcessor;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignAnnouncementToSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Assign Announcement To Segment',
|
||||
'message' => 'You have successfully assigned Announcement to segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var AssignAnnouncementToSegmentProcessor */
|
||||
private $assignAnnouncementToSegmentProcessor;
|
||||
|
||||
/**
|
||||
* AssignAnnouncementToSegmentLogic constructor.
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
*/
|
||||
public function __construct(FetchesAnnouncement $fetchesAnnouncement, AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor)
|
||||
{
|
||||
$this->fetchesAnnouncement = $fetchesAnnouncement;
|
||||
$this->assignAnnouncementToSegmentProcessor = $assignAnnouncementToSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$announcement = $this->fetchesAnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->assignAnnouncementToSegmentProcessor->execute($announcement, $request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanCreateAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\CreatesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Processors\AssignAnnouncementToSegmentProcessor;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Annoucement',
|
||||
'message' => 'You have successfully created a new Annoucements'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateAnnouncement */
|
||||
private $canCreateAnnouncement;
|
||||
|
||||
/** @var CreatesAnnoucement */
|
||||
private $createsAnnoucement;
|
||||
|
||||
/** @var AssignAnnouncementToSegmentProcessor */
|
||||
private $assignAnnouncementToSegmentProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateAnnouncementLogic constructor.
|
||||
* @param CanCreateAnnoucement $canCreateAnnoucement
|
||||
* @param CreatesAnnoucement $createsAnnoucement
|
||||
* @param AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
CanCreateAnnouncement $canCreateAnnouncement,
|
||||
CreatesAnnouncement $createsAnnoucement,
|
||||
AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
) {
|
||||
$this->canCreateAnnouncement = $canCreateAnnouncement;
|
||||
$this->createsAnnoucement = $createsAnnoucement;
|
||||
$this->assignAnnouncementToSegmentProcessor = $assignAnnouncementToSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canCreateAnnouncement->passes($annoucement_object);
|
||||
|
||||
$announcement = $this->createsAnnoucement->execute($annoucement_object);
|
||||
|
||||
$this->assignAnnouncementToSegmentProcessor->execute($announcement);
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanDeleteAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\DeletesAnnouncement;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Delete Announcement',
|
||||
'message' => 'You have successfully deleted the Announcement'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanDeleteAnnouncement */
|
||||
private $canDeleteAnnouncement;
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var DeletesAnnouncement */
|
||||
private $deletesAnnouncement;
|
||||
|
||||
/**
|
||||
* DeleteAnnouncementLogic constructor.
|
||||
* @param CanDeleteAnnouncement $canDeleteAnnouncement
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param DeletesAnnouncement $deletesAnnouncement
|
||||
*/
|
||||
public function __construct(
|
||||
CanDeleteAnnouncement $canDeleteAnnoucement,
|
||||
FetchesAnnouncement $fetchesAnnoucement,
|
||||
DeletesAnnouncement $deletesAnnoucement
|
||||
) {
|
||||
$this->canDeleteAnnoucement = $canDeleteAnnoucement;
|
||||
$this->fetchesAnnoucement = $fetchesAnnoucement;
|
||||
$this->deletesAnnoucement = $deletesAnnoucement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canDeleteAnnoucement->passes();
|
||||
|
||||
$annoucement = $this->fetchesAnnoucement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesAnnoucement->execute($annoucement);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Announcements\Services\ListsAnnouncements;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanListAnnouncements;
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListAnnouncementsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieve Announcements',
|
||||
'message' => 'You have successfully retrieved a list of Announcements'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListAnnouncements */
|
||||
private $canListAnnouncements;
|
||||
|
||||
/** @var ListsAnnouncements */
|
||||
private $listsAnnouncements;
|
||||
|
||||
/**
|
||||
* ListAnnouncementsLogic constructor.
|
||||
* @param CanListAnnouncements $canListAnnouncements
|
||||
* @param ListsAnnouncements $listsAnnouncements
|
||||
*/
|
||||
public function __construct(CanListAnnouncements $canListAnnouncements, ListsAnnouncements $listsAnnouncements)
|
||||
{
|
||||
$this->canListAnnouncements = $canListAnnouncements;
|
||||
$this->listsAnnouncements = $listsAnnouncements;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAnnouncements->passes();
|
||||
|
||||
$annoucements = $this->listsAnnouncements->execute($this->listsAnnouncements->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(AnnouncementResource::collection($annoucements));
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Announcements\Services\RemovesAnnouncementFromSegment;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveSegmentFromAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Detach Announcement From Segment',
|
||||
'message' => 'You have successfully detached Announcement from segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnnouncement;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var RemovesAnnouncementFromSegment */
|
||||
private $removesAnnouncementFromSegment;
|
||||
|
||||
/**
|
||||
* RemoveSegmentFromAnnouncementLogic constructor.
|
||||
* @param FetchesAnnouncement $fetchesAnnnouncement
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param RemovesAnnouncementFromSegment $removesAnnouncementFromSegment
|
||||
*/
|
||||
public function __construct(FetchesAnnouncement $fetchesAnnnouncement, FetchesSegment $fetchesSegment, RemovesAnnouncementFromSegment $removesAnnouncementFromSegment)
|
||||
{
|
||||
$this->fetchesAnnnouncement = $fetchesAnnnouncement;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->removesAnnouncementFromSegment = $removesAnnouncementFromSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$announcement = $this->fetchesAnnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
|
||||
|
||||
$this->removesAnnouncementFromSegment->execute($announcement, $segment);
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanUpdateAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class UpdateAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Announcement',
|
||||
'message' => 'You have successfully updated the Announcement'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateAnnouncement */
|
||||
private $canUpdateAnnouncement;
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var UpdatesAnnouncement */
|
||||
private $updatesAnnouncement;
|
||||
|
||||
/**
|
||||
* UpdateAnnouncementLogic constructor.
|
||||
* @param CanUpdateAnnouncement $canUpdateAnnouncement
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param UpdatesAnnouncement $updatesAnnouncement
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateAnnouncement $canUpdateAnnouncement,
|
||||
FetchesAnnouncement $fetchesAnnouncement,
|
||||
UpdatesAnnouncement $updatesAnnouncement
|
||||
) {
|
||||
$this->canUpdateAnnouncement = $canUpdateAnnouncement;
|
||||
$this->fetchesAnnouncement = $fetchesAnnouncement;
|
||||
$this->updatesAnnouncement = $updatesAnnouncement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canUpdateAnnouncement->passes($annoucement_object);
|
||||
|
||||
$annoucement = $this->fetchesAnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$announcement_query = $this->updatesAnnouncement->execute($annoucement, $annoucement_object);
|
||||
|
||||
//$announcement_query->segments()->sync($request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement_query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class AnnouncementObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $title;
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
|
||||
/** @var string */
|
||||
private $starting_on;
|
||||
|
||||
/** @var string */
|
||||
private $ending_on;
|
||||
|
||||
|
||||
/**
|
||||
* AnnouncementObject constructor.
|
||||
* @param string $title
|
||||
* @param string $description
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
*/
|
||||
|
||||
public function __construct(string $title, string $description, string $starting_on, string $ending_on)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->description = $description;
|
||||
$this->starting_on = $starting_on;
|
||||
$this->ending_on = $ending_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStartingOn(): string
|
||||
{
|
||||
return $this->starting_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEndingOn(): string
|
||||
{
|
||||
return $this->ending_on;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Processors;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\AssignsAnnouncementToSegment;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanAssignSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Announcement;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssignAnnouncementToSegmentProcessor
|
||||
{
|
||||
|
||||
/** @var CanAssignSegment */
|
||||
private $canAssignSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var AssignAnnouncementToSegment */
|
||||
private $assignsAnnouncementToSegment;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AssignAnnouncementToSegmentProcessor constructor.
|
||||
* @param CanAssignSegment $canAssignSegment
|
||||
* @param AssignAnnouncementToSegment $assignsAnnouncementToSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanAssignSegment $canAssignSegment, FetchesSegment $fetchesSegment, AssignsAnnouncementToSegment $assignsAnnouncementToSegment)
|
||||
{
|
||||
$this->canAssignSegment = $canAssignSegment;
|
||||
$this->assignsAnnouncementToSegment = $assignsAnnouncementToSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param int|null $segmentId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Announcement $announcement, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model
|
||||
{
|
||||
$this->canAssignSegment->passes();
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segmentId]);
|
||||
|
||||
return $this->assignsAnnouncementToSegment->execute($announcement, $segment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class AssignsAnnouncementToSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $announcement, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$announcement->segments()->attach($segment);
|
||||
|
||||
return $announcement;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class CreatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(AnnouncementObject $object)
|
||||
{
|
||||
$model = new Announcement();
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class DeletesAnnouncement extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Announcement $model
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class FetchesAnnouncement extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Announcement */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesAnnouncement constructor.
|
||||
* @param Announcement $repository
|
||||
*/
|
||||
public function __construct(Announcement $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class ListsAnnouncements extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Announcement */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsAnnouncement constructor.
|
||||
* @param Announcement $repository
|
||||
*/
|
||||
public function __construct(Announcement $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class RemovesAnnouncementFromSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $announcement, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$announcement->segments()->detach($segment);
|
||||
|
||||
return $announcement;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class UpdatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Announcement $model
|
||||
* @param AnnouncementObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $model, AnnouncementObject $object)
|
||||
{
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
|
||||
class CanAssignSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\Standards\Validators\AnnouncementValidation;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanCreateAnnouncement extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var AnnouncementValidation */
|
||||
private $AnnouncementValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAnnouncement constructor.
|
||||
* @param AnnouncementValidation $AnnouncementValidation
|
||||
*/
|
||||
public function __construct(AnnouncementValidation $AnnouncementValidation)
|
||||
{
|
||||
$this->AnnouncementValidation = $AnnouncementValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->AnnouncementValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcement\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanDeleteAnnouncement extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanListAnnouncements extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Validators\AnnouncementValidation;
|
||||
|
||||
class CanUpdateAnnouncement extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var AnnouncementValidation */
|
||||
private $AnnouncementValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateAnnouncement constructor.
|
||||
* @param AnnouncementValidation $AnnouncementValidation
|
||||
*/
|
||||
public function __construct(AnnouncementValidation $AnnouncementValidation)
|
||||
{
|
||||
$this->AnnouncementValidation = $AnnouncementValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->AnnouncementValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class AnnouncementValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'title' => $object->getTitle(),
|
||||
'description' => $object->getDescription(),
|
||||
'starting_on' => $object->getStartingOn(),
|
||||
'ending_on' => $object->getEndingOn()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required',
|
||||
'description' => 'required',
|
||||
'starting_on' => 'required',
|
||||
'ending_on' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\AssignAnnouncementToSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignAnnouncementToSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param AssignCompanyToSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function assign(Request $request, AssignAnnouncementToSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\CreateAnnouncementLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateAnnouncementController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateAnnouncementLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateAnnouncementLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\DeleteAnnouncementLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteAnnouncementController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteAnnouncementLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeleteAnnouncementLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\ListAnnouncementsLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListAnnouncementsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListAnnouncementsLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListAnnouncementsLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\RemoveSegmentFromAnnouncementLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveSegmentFromAnnouncementController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param RemoveCompanyFromSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function detach(Request $request, RemoveSegmentFromAnnouncementLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Announcements;
|
||||
|
||||
use App\Classes\Modules\Announcements\ControllersLogic\UpdateAnnouncementLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateAnnouncementController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateAnnouncementLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateAnnouncementLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Accounts;
|
||||
namespace App\Http\Controllers\Bookings;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\DeleteBookingLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class AnnouncementResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'segments' => $this->segments,
|
||||
'starting_on' => Carbon::parse($this->starting_on)->format('Y-m-d'),
|
||||
'ending_on' => Carbon::parse($this->ending_on)->format('Y-m-d'),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class Announcement
|
||||
* @package App\Models
|
||||
*
|
||||
*/
|
||||
class Announcement extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'announcements';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
**/
|
||||
public function segments(): BelongsToMany
|
||||
{
|
||||
return $this->BelongsToMany(Segment::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAnnouncementsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('announcements', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title', 50);
|
||||
$table->longText('description');
|
||||
$table->timestamp('starting_on')->nullable();
|
||||
$table->timestamp('ending_on')->nullable();
|
||||
$table->boolean('is_all_day')->default(false);
|
||||
$table->integer('duration')->default(0);
|
||||
$table->boolean('is_recurring')->default(false);
|
||||
$table->string('recurrence_pattern')->nullable();
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('announcements');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAnnouncementSegmentTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('announcement_segment', function (Blueprint $table) {
|
||||
|
||||
$table->primary(['announcement_id', 'segment_id']);
|
||||
$table->bigInteger('announcement_id')->unsigned();
|
||||
$table->bigInteger('segment_id')->unsigned();
|
||||
$table->timestamps();
|
||||
$table->foreign('announcement_id')
|
||||
->references('id')
|
||||
->on('announcements')->onDelete('cascade');
|
||||
$table->foreign('segment_id')
|
||||
->references('id')
|
||||
->on('segments')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('announcement_segment');
|
||||
}
|
||||
}
|
||||
Vendored
+4
@@ -14,6 +14,8 @@ import vuelidate from 'vuelidate';
|
||||
/** Input Mask **/
|
||||
import VueTheMask from 'vue-the-mask';
|
||||
|
||||
/** Vue Filter **/
|
||||
import filters from './general/filters';
|
||||
|
||||
/** Mixins */
|
||||
import request from './general/mixins/request';
|
||||
@@ -27,6 +29,8 @@ import Avatar from 'vue-avatar';
|
||||
/** Application Injections */
|
||||
Vue.use(vuelidate);
|
||||
Vue.use(VueTheMask);
|
||||
Vue.use(filters);
|
||||
|
||||
Vue.directive('closable', closable);
|
||||
Vue.mixin({
|
||||
methods: {
|
||||
|
||||
File diff suppressed because one or more lines are too long
+67
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
||||
<div class="row" v-show="!$store.getters.isLoading(section)">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<h3 class="all-caps m-b-5 bold no-margin">Assign Segment</h3>
|
||||
<div class="fs-11">Select a segment to view annoucment with title <span class="bold">{{parameters.title | truncate(10) }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component selecatable :validator="$v.parameters.segment_id">
|
||||
<label class="muted">Segment</label>
|
||||
<selectable-component :endpoint="route('api.segment.list') + '?filters=' + JSON.stringify({'id_not_in': currentSegmentIds})" :section="'segmentsListSection_'+data.id" valueColumn="id" :labelColumn="['name']" v-model="parameters.segment_id"></selectable-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" data-dismiss="modal">Not Now</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submit(route('api.announcement.segment.assign', data.id), 'post', section, true, false)">Assign Segment</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
parameters: {
|
||||
segment_id: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
segment_id: {
|
||||
required
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
currentSegmentIds(){
|
||||
return this.parameters.segments.map(function (value){
|
||||
return value.id;
|
||||
})
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
|
||||
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h3 class="all-caps">Are you Sure?</h3>
|
||||
<div class="fs-11">Are you sure you want to remove <span class="bold">{{this.item.name}}</span>from viewing this annoucment with title <span class="bold">{{ announcement_title | truncate(10)}}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submit(route('api.announcement.segment.detach', announcement_id, item.id), 'delete', section, true, true)">Remove Segment</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
props: {
|
||||
announcement_id: {
|
||||
required: true,
|
||||
type: Number
|
||||
},
|
||||
announcement_title: {
|
||||
required: true,
|
||||
type: String
|
||||
}
|
||||
},
|
||||
created() {
|
||||
console.log("created detach");
|
||||
},
|
||||
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
|
||||
<div class="row bg-white" v-show="!isLoading">
|
||||
<div class="col">
|
||||
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="50" height="50" viewBox="0 0 172 172" style=" fill:#000000;"><defs><linearGradient x1="99.4375" y1="43.33594" x2="99.4375" y2="60.14625" gradientUnits="userSpaceOnUse" id="color-1_43971_gr1"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="106.15625" y1="26.875" x2="106.15625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-2_43971_gr2"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="83.3125" y1="26.875" x2="83.3125" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-3_43971_gr3"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="73.90625" y1="26.875" x2="73.90625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-4_43971_gr4"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="51.0625" y1="26.875" x2="51.0625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-5_43971_gr5"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="51.0625" y1="26.875" x2="51.0625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-6_43971_gr6"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="45.6875" y1="26.875" x2="45.6875" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-7_43971_gr7"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="43" y1="26.875" x2="43" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-8_43971_gr8"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M112.875,59.125h-26.875c-1.4835,0 -2.6875,-1.204 -2.6875,-2.6875v-10.75c0,-1.4835 1.204,-2.6875 2.6875,-2.6875h26.875c1.4835,0 2.6875,1.204 2.6875,2.6875v10.75c0,1.4835 -1.204,2.6875 -2.6875,2.6875z" fill="url(#color-1_43971_gr1)"></path><path d="M155.875,96.75c0,-7.97381 -5.82381,-14.59581 -13.4375,-15.88313v-18.82325c0,-2.08819 -1.16906,-3.94525 -3.05031,-4.85094c-1.88125,-0.90031 -4.06081,-0.65575 -5.69481,0.64769l-21.48925,17.18925c-0.08062,0.0645 -0.13975,0.14781 -0.21769,0.21769h-31.36044c-7.40944,0 -13.4375,6.02806 -13.4375,13.4375h-5.375c-2.96431,0 -5.375,2.41069 -5.375,5.375v5.375c0,2.96431 2.41069,5.375 5.375,5.375h5.375c0,7.40944 6.02806,13.4375 13.4375,13.4375v16.125c0,5.92863 4.82138,10.75 10.75,10.75c5.92863,0 10.75,-4.82137 10.75,-10.75v-16.125h9.86044c0.07794,0.06988 0.13706,0.15319 0.22038,0.22037l21.48656,17.18925c0.98094,0.78475 2.16075,1.18519 3.35131,1.18519c0.79281,0 1.59369,-0.17738 2.3435,-0.5375c1.88125,-0.903 3.05031,-2.76275 3.05031,-4.84825v-18.82325c7.61369,-1.28731 13.4375,-7.90931 13.4375,-15.88312zM61.8125,99.4375v-5.375h5.375v5.375zM96.75,134.375c0,2.96431 -2.41069,5.375 -5.375,5.375c-2.96431,0 -5.375,-2.41069 -5.375,-5.375v-16.125h10.75zM80.625,112.875c-4.44513,0 -8.0625,-3.61738 -8.0625,-8.0625v-16.125c0,-4.44513 3.61737,-8.0625 8.0625,-8.0625h29.5625v32.25h-8.0625zM137.05175,131.46175l-21.48925,-17.19462v-35.04231l10.75,-8.59194v26.11713h5.375v-30.41175l5.375,-4.29462l0.00538,69.42887c0,0 -0.00538,-0.00269 -0.01613,-0.01075zM142.4375,107.11837v-20.73675c4.6225,1.20131 8.0625,5.375 8.0625,10.36838c0,4.99337 -3.44,9.16706 -8.0625,10.36838z" fill="url(#color-2_43971_gr2)"></path><path d="M77.9375,91.375v5.375h5.375v-5.375h5.375v-5.375h-5.375c-2.96431,0 -5.375,2.41069 -5.375,5.375z" fill="url(#color-3_43971_gr3)"></path><path d="M21.5,107.5v-67.1875c0,-4.44512 3.61737,-8.0625 8.0625,-8.0625h88.6875c4.44512,0 8.0625,3.61738 8.0625,8.0625v10.75h5.375v-10.75c0,-7.40944 -6.02806,-13.4375 -13.4375,-13.4375h-88.6875c-7.40944,0 -13.4375,6.02806 -13.4375,13.4375v67.1875c0,7.40944 6.02806,13.4375 13.4375,13.4375h32.25v-5.375h-32.25c-4.44513,0 -8.0625,-3.61737 -8.0625,-8.0625z" fill="url(#color-4_43971_gr4)"></path><path d="M32.25,43h37.625v5.375h-37.625z" fill="url(#color-5_43971_gr5)"></path><path d="M32.25,53.75h37.625v5.375h-37.625z" fill="url(#color-6_43971_gr6)"></path><path d="M32.25,64.5h26.875v5.375h-26.875z" fill="url(#color-7_43971_gr7)"></path><path d="M32.25,75.25h21.5v5.375h-21.5z" fill="url(#color-8_43971_gr8)"></path></g></g></svg>
|
||||
<label class="fs-20 all-caps"><b>{{item.title}}</b></label>
|
||||
<label class="float-right fs-10"><i>{{item.created_at}}</i></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<div class=""><b>{{item.description}}</b></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-md-center p-b-10">
|
||||
<div class="col-3">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">OK</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div class="col-12">
|
||||
<div class="b-b b-dashed b-grey p-b-25" v-show="!this.show_details" v-if="company">
|
||||
<div class="row align-items-center m-b-5 parentContainer">
|
||||
<div class="col-10">
|
||||
<div class="font-heading fs-10 muted all-caps">Announcement</div>
|
||||
</div>
|
||||
<div class="col-2 text-right pull-right">
|
||||
<div class="font-heading fs-10 muted all-caps">Action</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<list-component :section="this.section" :endpoint="route('api.announcement.list')" :options="{has_segments:segments,is_published:true}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<announcement-list-component :data="data"></announcement-list-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
section: 'announcementsSection',
|
||||
company: null,
|
||||
show_details: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
segments(){
|
||||
return this.company.segments.map(function (value){
|
||||
|
||||
return value.id;
|
||||
})
|
||||
}
|
||||
},
|
||||
created(){
|
||||
this.$store.dispatch('updateListQueue', {'name': this.section});
|
||||
this.fetchCompany();
|
||||
},
|
||||
methods: {
|
||||
fetchCompany(){
|
||||
this.submit(route('api.company.show', this.$store.getters.getCompanyId), 'get', this.section, false, false)
|
||||
},
|
||||
successHandler(response){
|
||||
this.$store.dispatch('completeList', {'name': this.section, 'data': []});
|
||||
this.company = response.payload.data;
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -19,7 +19,7 @@
|
||||
<div class="col">
|
||||
<validation-wrapper-component selecatable :validator="$v.parameters.segment_id">
|
||||
<label class="muted">Segment</label>
|
||||
<selectable-component :endpoint="route('api.segment.list') + '?filters=' + JSON.stringify({'id_not_in': currentSegmentIds})" section="segmentsListSection" valueColumn="id" :labelColumn="['name']" v-model="parameters.segment_id"></selectable-component>
|
||||
<selectable-component :endpoint="route('api.segment.list') + '?filters=' + JSON.stringify({'id_not_in': currentSegmentIds})" :section="multiple?'segmentsListSection_'+data.id:'segmentsListSection'" valueColumn="id" :labelColumn="['name']" v-model="parameters.segment_id"></selectable-component>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
@@ -40,6 +40,12 @@
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
props: {
|
||||
multiple: {
|
||||
default: false,
|
||||
type: Boolean
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
parameters: {
|
||||
@@ -56,6 +62,8 @@
|
||||
},
|
||||
computed: {
|
||||
currentSegmentIds(){
|
||||
console.log("compute");
|
||||
console.log(this.parameters.segments);
|
||||
return this.parameters.segments.map(function (value){
|
||||
return value.id;
|
||||
})
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 50px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
||||
<div class="row" v-show="!$store.getters.isLoading(section)">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h6 class="all-caps m-b-5 bold no-margin">{{this.data?"Update":"Create"}} Announcement</h6>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-5 animate__animated animate__fadeInUpBig animate__fast" v-if="error">
|
||||
<div class="col">
|
||||
<small class="bold fs-10 text-danger">{{error}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.title">
|
||||
<label class="muted">Title</label>
|
||||
<input type="text" class="form-control" v-model="parameters.title">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.description">
|
||||
<label class="muted">Message</label>
|
||||
<textarea class="form-control h-75" v-model="parameters.description" rows="20"></textarea>
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m-b-20">
|
||||
<div class="col-6">
|
||||
<validation-wrapper-component :validator="$v.parameters.starting_on">
|
||||
<label class="muted">Start Date</label>
|
||||
<input type="date" v-model="parameters.starting_on">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<validation-wrapper-component :validator="$v.parameters.ending_on">
|
||||
<label class="muted">End Date</label>
|
||||
<input type="date" v-model="parameters.ending_on">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lightest btn-block b-rad-none" :data-dismiss="closable ? 'modal' : ''" @click="$emit('close')">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" @click="submitForm()">{{this.data?"Update":"Create"}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required, requiredIf } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
props : {
|
||||
closable: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
country_id: {
|
||||
type: Number,
|
||||
default: 1
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
parameters: {
|
||||
starting_on:'',
|
||||
ending_on:'',
|
||||
// segment_id: '',
|
||||
title: '',
|
||||
description: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
title: {
|
||||
required
|
||||
},
|
||||
description: {
|
||||
required
|
||||
},
|
||||
// segment_id: {
|
||||
// required
|
||||
// },
|
||||
starting_on:{
|
||||
required
|
||||
},
|
||||
ending_on:{
|
||||
required
|
||||
},
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
|
||||
},
|
||||
created(){
|
||||
console.log("lado form");
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
//this.submit(route('api.announcement.create'), 'post', this.section, true, false);
|
||||
this.submit((this.data ? this.route('api.announcement.update', this.data.id) : this.route('api.announcement.create')), (this.data ? 'put' : 'post'), this.section, true, false)
|
||||
},
|
||||
// successHandler(response){
|
||||
// this.closeModal();
|
||||
// //this.formHandler();
|
||||
// this.resetForm();
|
||||
// },
|
||||
// errorHandler(error){
|
||||
// this.formHandler(error.message);
|
||||
// }
|
||||
},
|
||||
mixins: [ModalFormHandler],
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
|
||||
<div class="row justify-content-center" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h3 class="all-caps">Are you Sure?</h3>
|
||||
<div class="fs-11">Are you sure you want to delete announcement with title <b>{{item.title}}</b> ?</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submit(route('api.announcement.delete', item.id), 'delete', section, true, true)">Delete</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
import truncate from "./truncate";
|
||||
|
||||
export default {
|
||||
install(Vue) {
|
||||
Vue.filter("truncate", truncate);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function truncate (text, stop, clamp) {
|
||||
return text.slice(0, stop) + (stop < text.length ? clamp || '...' : '')
|
||||
}
|
||||
@@ -147,7 +147,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row m-b-5">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@@ -170,6 +170,29 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col bg-master-light tabButton" tab-name="announcement">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto p-t-10 p-b-10 b-r b-grey">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
width="35" height="35"
|
||||
viewBox="0 0 172 172"
|
||||
style=" fill:#000000;"><defs><linearGradient x1="99.4375" y1="43.33594" x2="99.4375" y2="60.14625" gradientUnits="userSpaceOnUse" id="color-1_43971_gr1"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="106.15625" y1="26.875" x2="106.15625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-2_43971_gr2"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="83.3125" y1="26.875" x2="83.3125" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-3_43971_gr3"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="73.90625" y1="26.875" x2="73.90625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-4_43971_gr4"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="51.0625" y1="26.875" x2="51.0625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-5_43971_gr5"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="51.0625" y1="26.875" x2="51.0625" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-6_43971_gr6"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="45.6875" y1="26.875" x2="45.6875" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-7_43971_gr7"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient><linearGradient x1="43" y1="26.875" x2="43" y2="146.16775" gradientUnits="userSpaceOnUse" id="color-8_43971_gr8"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M112.875,59.125h-26.875c-1.4835,0 -2.6875,-1.204 -2.6875,-2.6875v-10.75c0,-1.4835 1.204,-2.6875 2.6875,-2.6875h26.875c1.4835,0 2.6875,1.204 2.6875,2.6875v10.75c0,1.4835 -1.204,2.6875 -2.6875,2.6875z" fill="url(#color-1_43971_gr1)"></path><path d="M155.875,96.75c0,-7.97381 -5.82381,-14.59581 -13.4375,-15.88313v-18.82325c0,-2.08819 -1.16906,-3.94525 -3.05031,-4.85094c-1.88125,-0.90031 -4.06081,-0.65575 -5.69481,0.64769l-21.48925,17.18925c-0.08062,0.0645 -0.13975,0.14781 -0.21769,0.21769h-31.36044c-7.40944,0 -13.4375,6.02806 -13.4375,13.4375h-5.375c-2.96431,0 -5.375,2.41069 -5.375,5.375v5.375c0,2.96431 2.41069,5.375 5.375,5.375h5.375c0,7.40944 6.02806,13.4375 13.4375,13.4375v16.125c0,5.92863 4.82138,10.75 10.75,10.75c5.92863,0 10.75,-4.82137 10.75,-10.75v-16.125h9.86044c0.07794,0.06988 0.13706,0.15319 0.22038,0.22037l21.48656,17.18925c0.98094,0.78475 2.16075,1.18519 3.35131,1.18519c0.79281,0 1.59369,-0.17738 2.3435,-0.5375c1.88125,-0.903 3.05031,-2.76275 3.05031,-4.84825v-18.82325c7.61369,-1.28731 13.4375,-7.90931 13.4375,-15.88312zM61.8125,99.4375v-5.375h5.375v5.375zM96.75,134.375c0,2.96431 -2.41069,5.375 -5.375,5.375c-2.96431,0 -5.375,-2.41069 -5.375,-5.375v-16.125h10.75zM80.625,112.875c-4.44513,0 -8.0625,-3.61738 -8.0625,-8.0625v-16.125c0,-4.44513 3.61737,-8.0625 8.0625,-8.0625h29.5625v32.25h-8.0625zM137.05175,131.46175l-21.48925,-17.19462v-35.04231l10.75,-8.59194v26.11713h5.375v-30.41175l5.375,-4.29462l0.00538,69.42887c0,0 -0.00538,-0.00269 -0.01613,-0.01075zM142.4375,107.11837v-20.73675c4.6225,1.20131 8.0625,5.375 8.0625,10.36838c0,4.99337 -3.44,9.16706 -8.0625,10.36838z" fill="url(#color-2_43971_gr2)"></path><path d="M77.9375,91.375v5.375h5.375v-5.375h5.375v-5.375h-5.375c-2.96431,0 -5.375,2.41069 -5.375,5.375z" fill="url(#color-3_43971_gr3)"></path><path d="M21.5,107.5v-67.1875c0,-4.44512 3.61737,-8.0625 8.0625,-8.0625h88.6875c4.44512,0 8.0625,3.61738 8.0625,8.0625v10.75h5.375v-10.75c0,-7.40944 -6.02806,-13.4375 -13.4375,-13.4375h-88.6875c-7.40944,0 -13.4375,6.02806 -13.4375,13.4375v67.1875c0,7.40944 6.02806,13.4375 13.4375,13.4375h32.25v-5.375h-32.25c-4.44513,0 -8.0625,-3.61737 -8.0625,-8.0625z" fill="url(#color-4_43971_gr4)"></path><path d="M32.25,43h37.625v5.375h-37.625z" fill="url(#color-5_43971_gr5)"></path><path d="M32.25,53.75h37.625v5.375h-37.625z" fill="url(#color-6_43971_gr6)"></path><path d="M32.25,64.5h26.875v5.375h-26.875z" fill="url(#color-7_43971_gr7)"></path><path d="M32.25,75.25h21.5v5.375h-21.5z" fill="url(#color-8_43971_gr8)"></path></g></g></svg>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="fs-12 m-t-5 all-caps m-b-5">Announcements</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -449,7 +472,43 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="row tabsContainer hide tabContent" tab-name="announcement">
|
||||
<div class="col">
|
||||
<loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading('announcementsSection')"></loading-component>
|
||||
<div class="row" v-show="!$store.getters.isLoading('announcementsSection')">
|
||||
<div class="col">
|
||||
<div class="row p-b-5 m-b-20 b-b b-grey align-items-center parentContainer">
|
||||
<div class="col">
|
||||
<div class="font-heading all-caps fs-10 hint-text">
|
||||
Announcements
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-xs btn-primary b-rad-none requestModal" data-type="createModal">
|
||||
<i class="fa fa-plus m-r-5"></i>
|
||||
Create Announcement
|
||||
</button>
|
||||
<modal-form-component section="allAnnouncementsSection">
|
||||
<template slot="form" slot-scope="{section}">
|
||||
<announcement-form-component :section="section"></announcement-form-component>
|
||||
</template>
|
||||
</modal-form-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<list-component section="allAnnouncementsSection" :endpoint="route('api.announcement.list')" :options="{}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<announcement-list-component :data="data"></announcement-list-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -463,7 +522,7 @@
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton active" tab-name="customer-list">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton" v-bind:class="{ active: $store.getters.isAdmin }" vtab-name="customer-list">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
@@ -482,11 +541,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="col" v-else>
|
||||
<div class="row justify-content-end">
|
||||
<div class="col">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton " tab-name="transactions">
|
||||
<div class="col p-t-20 p-b-20 bg-master-lighter tabButton " v-bind:class="{ active: !$store.getters.isAdmin }" tab-name="announcement-list">
|
||||
<div class="row justify-content-center m-b-5">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
@@ -506,11 +565,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row no-margin" v-if="$store.getters.isAdmin">
|
||||
<div class="row no-margin">
|
||||
<div class="col bg-white padding-25">
|
||||
<div class="row tabsContainer tabContent" tab-name="customer-list">
|
||||
<div class="row tabsContainer tabContent" tab-name="customer-list" v-if="$store.getters.isAdmin">
|
||||
<company-quick-view-section-component></company-quick-view-section-component>
|
||||
</div>
|
||||
<div class="row tabsContainer tabContent" v-bind:class="{ hide: $store.getters.isAdmin }" v-else tab-name="announcement-list">
|
||||
<announcement-quick-view-section-component></announcement-quick-view-section-component>
|
||||
</div>
|
||||
<div class="row tabsContainer hide tabContent" tab-name="PO">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['prefix' => 'announcement', 'as' => 'announcement.', 'namespace' => 'Announcements'], function () {
|
||||
Route::get('/list', 'ListAnnouncementsController@list')->name('list');
|
||||
Route::post('/create', 'CreateAnnouncementController@create')->name('create');
|
||||
Route::put('/update/{id}', 'UpdateAnnouncementController@update')->name('update');
|
||||
Route::delete('/delete/{id}', 'DeleteAnnouncementController@delete')->name('delete');
|
||||
|
||||
Route::group(['prefix' => '{id}/segment', 'as' => 'segment.'], function () {
|
||||
Route::post('/assign', 'AssignAnnouncementToSegmentController@assign')->name('assign');
|
||||
Route::delete('/detach/{segment_id}', 'RemoveSegmentFromAnnouncementController@detach')->name('detach');
|
||||
});
|
||||
});
|
||||
@@ -45,6 +45,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
|
||||
require __DIR__ . '/crud.php';
|
||||
|
||||
require __DIR__ . '/announcement.php';
|
||||
|
||||
// require __DIR__ . '/wallet.php';
|
||||
// require __DIR__ . '/rate.php';
|
||||
// require __DIR__ . '/receipt.php';
|
||||
|
||||
Reference in New Issue
Block a user