-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
135 changed files
with
79,401 additions
and
0 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,14 @@ | ||
/node_modules | ||
/public/hot | ||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
/.idea | ||
/.vscode | ||
/.vagrant | ||
/build | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
.env |
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,63 @@ | ||
FROM php:7.2.8-fpm-alpine3.7 | ||
|
||
RUN apk update | ||
RUN apk add --no-cache $PHPIZE_DEPS imagemagick imagemagick-dev git icu-dev openssl-dev zip unzip libpng-dev python3 py-pip | ||
RUN rm -rf /var/lib/apt/lists/* | ||
|
||
COPY ./docker/Application/php/php.ini /usr/local/etc/php/conf.d | ||
COPY ./docker/Application/php-fpm/www.conf /usr/local/etc/php-fpm.d/www.conf | ||
|
||
RUN pecl install imagick-3.4.3 && \ | ||
docker-php-ext-enable imagick && \ | ||
docker-php-ext-install -j$(nproc) intl && \ | ||
docker-php-ext-install mysqli && \ | ||
docker-php-ext-install pdo pdo_mysql && \ | ||
docker-php-ext-install zip && \ | ||
docker-php-ext-install gd && \ | ||
docker-php-ext-install pcntl | ||
|
||
ENV TERM dump | ||
ENV START_MESSAGE Application has been installed | ||
ENV LOCK_FILE_PATH /tmp/application.lock | ||
|
||
COPY ./docker/Application/bin /usr/local/bin/app | ||
COPY . /var/www/application | ||
COPY docker/Application/confd /etc/confd | ||
|
||
RUN chmod +x /usr/local/bin/app/* && \ | ||
mkdir -p /var/www/application/storage && \ | ||
chown -R www-data:www-data /var/www/application/storage | ||
|
||
RUN sed -i "s/www-data/root/g" /usr/local/etc/php-fpm.d/www.conf | ||
|
||
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ | ||
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \ | ||
php composer-setup.php --install-dir=/bin --filename=composer && \ | ||
php -r "unlink('composer-setup.php');" | ||
|
||
|
||
# create directories and files in case empty directories weren't copied | ||
RUN mkdir -p /var/www/application/storage/framework/cache && \ | ||
chmod -R 775 /var/www/application/storage/framework/cache/ && \ | ||
mkdir -p /var/www/application/storage/framework/sessions && \ | ||
chmod -R 775 /var/www/application/storage/framework/sessions/ && \ | ||
mkdir -p /var/www/application/storage/framework/views && \ | ||
chmod -R 775 /var/www/application/storage/framework/views/ && \ | ||
mkdir -p /var/www/application/storage/cache/ && \ | ||
chmod -R 775 /var/www/application/bootstrap/cache/ && \ | ||
mkdir -p /var/www/application/storage/logs && \ | ||
touch /var/www/application/storage/logs/laravel.log && chmod 777 /var/www/application/storage/logs/laravel.log | ||
|
||
RUN php -d memory_limit=-1 /bin/composer install \ | ||
--no-ansi \ | ||
--prefer-dist \ | ||
--no-interaction \ | ||
--no-progress \ | ||
--no-scripts \ | ||
--optimize-autoloader \ | ||
--working-dir \ | ||
/var/www/application | ||
|
||
WORKDIR /var/www/application | ||
|
||
CMD /usr/local/bin/app/run.sh |
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,3 @@ | ||
FROM nginx | ||
COPY ./docker/WebApplication/default.conf /etc/nginx/conf.d/default.conf | ||
WORKDIR /var/www/application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class ClientRequest extends Model | ||
{ | ||
const STATUS_NEW = 'new'; | ||
const STATUS_REQUEST_SENT = 'request_sent'; | ||
const STATUS_PAYMENT_DONE = 'payment_done'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'client_name', | ||
'vendor_email' | ||
]; | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace App\Console; | ||
|
||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
||
class Kernel extends ConsoleKernel | ||
{ | ||
/** | ||
* The Artisan commands provided by your application. | ||
* | ||
* @var array | ||
*/ | ||
protected $commands = [ | ||
// | ||
]; | ||
|
||
/** | ||
* Define the application's command schedule. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Schedule $schedule | ||
* @return void | ||
*/ | ||
protected function schedule(Schedule $schedule) | ||
{ | ||
// $schedule->command('inspire') | ||
// ->hourly(); | ||
} | ||
|
||
/** | ||
* Register the commands for the application. | ||
* | ||
* @return void | ||
*/ | ||
protected function commands() | ||
{ | ||
$this->load(__DIR__.'/Commands'); | ||
|
||
require base_path('routes/console.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,42 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use App\ClientRequest; | ||
|
||
class RequestSentEvent | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* @var ClientRequest | ||
*/ | ||
public $clientRequest; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(ClientRequest $clientRequest) | ||
{ | ||
$this->clientRequest = $clientRequest; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn() | ||
{ | ||
return new PrivateChannel('channel-name'); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use App\ClientRequest; | ||
|
||
class RequestUpdatePaymentEvent | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* @var ClientRequest | ||
*/ | ||
public $clientRequest; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(ClientRequest $clientRequest) | ||
{ | ||
$this->clientRequest = $clientRequest; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn() | ||
{ | ||
return new PrivateChannel('channel-name'); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use Exception; | ||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | ||
|
||
class Handler extends ExceptionHandler | ||
{ | ||
/** | ||
* A list of the exception types that are not reported. | ||
* | ||
* @var array | ||
*/ | ||
protected $dontReport = [ | ||
// | ||
]; | ||
|
||
/** | ||
* A list of the inputs that are never flashed for validation exceptions. | ||
* | ||
* @var array | ||
*/ | ||
protected $dontFlash = [ | ||
'password', | ||
'password_confirmation', | ||
]; | ||
|
||
/** | ||
* Report or log an exception. | ||
* | ||
* @param \Exception $exception | ||
* @return void | ||
*/ | ||
public function report(Exception $exception) | ||
{ | ||
parent::report($exception); | ||
} | ||
|
||
/** | ||
* Render an exception into an HTTP response. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \Exception $exception | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function render($request, Exception $exception) | ||
{ | ||
return parent::render($request, $exception); | ||
} | ||
} |
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,93 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Validator; | ||
use App\ClientRequest; | ||
use App\Events\RequestSentEvent; | ||
use App\Events\RequestUpdatePaymentEvent; | ||
use Illuminate\Support\Facades\Log; | ||
use Carbon\Carbon; | ||
|
||
class ClientRequestController extends Controller | ||
{ | ||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | ||
*/ | ||
public function postRequest(Request $request) | ||
{ | ||
$validator = Validator::make($request->all(), [ | ||
'client_name' => 'required|string', | ||
'vendor_email' => 'required|email', | ||
]); | ||
|
||
if ($validator->fails()) { | ||
return response()->json(['errors'=>$validator->errors()->all()], 422); | ||
} | ||
|
||
try{ | ||
$clientRequest = new ClientRequest(); | ||
$clientRequest->client_name = $request->get('client_name') ?? ''; | ||
$clientRequest->vendor_email = $request->get('vendor_email') ?? ''; | ||
$clientRequest->status = ClientRequest::STATUS_NEW; | ||
$clientRequest->save(); | ||
|
||
event(new RequestSentEvent($clientRequest)); | ||
return response()->json($clientRequest); | ||
} catch (\Exception $exception){ | ||
Log::critical($exception->getMessage()); | ||
throw new \RuntimeException(__('error.transaction_error'), 500); | ||
} | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | ||
*/ | ||
public function updatePayment(int $id, Request $request) | ||
{ | ||
$clientRequest = ClientRequest::where('id',$id)->first(); | ||
if(!$clientRequest){ | ||
return response()->json(['errors'=>'Client request not found' ], 404); | ||
} | ||
|
||
if($clientRequest->status === ClientRequest::STATUS_PAYMENT_DONE){ | ||
return response()->json(['errors'=>'Already updated payment info.' ], 404); | ||
} | ||
|
||
$validator = Validator::make($request->all(), [ | ||
'payment_method' => 'required|string', | ||
'transaction_reference' => 'required|string', | ||
]); | ||
|
||
if ($validator->fails()) { | ||
return response()->json(['errors'=>$validator->errors()->all()], 422); | ||
} | ||
|
||
try{ | ||
$clientRequest->status = ClientRequest::STATUS_PAYMENT_DONE; | ||
$clientRequest->payment_date = Carbon::now(); | ||
$clientRequest->payment_method = $request->get('payment_method') ?? ''; | ||
$clientRequest->transaction_reference = $request->get('transaction_reference') ?? ''; | ||
$clientRequest->save(); | ||
|
||
event(new RequestUpdatePaymentEvent($clientRequest)); | ||
return response()->json(['msg'=>'Update successfully.']); | ||
} catch (\Exception $exception){ | ||
Log::critical($exception->getMessage()); | ||
throw new \RuntimeException(__('error.transaction_error'), 500); | ||
} | ||
} | ||
} |
Oops, something went wrong.