-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
d332712
commit 082d5ca
Showing
1,323 changed files
with
95,803 additions
and
79,235 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,20 +1,14 @@ | ||
// .eslintrc.js | ||
|
||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
}, | ||
extends: [ | ||
'plugin:vue/recommended', | ||
'eslint:recommended', | ||
'prettier/vue', | ||
'plugin:prettier/recommended', | ||
// add more generic rulesets here, such as: | ||
// 'eslint:recommended', | ||
"plugin:vue/vue3-recommended", | ||
"prettier", | ||
], | ||
parserOptions: { | ||
parser: 'babel-eslint', | ||
}, | ||
plugins: ['prettier'], | ||
rules: { | ||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
// override/add rules settings here, such as: | ||
// 'vue/no-unused-vars': 'error' | ||
}, | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -11,4 +11,4 @@ Homestead.yaml | |
.rnd | ||
/.expo | ||
/.vscode | ||
/docker-compose/db/data/ | ||
/docker-compose/db/data/ |
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,40 +1,44 @@ | ||
FROM php:7.4-fpm | ||
FROM php:7.4-fpm-alpine | ||
|
||
# Arguments defined in docker-compose.yml | ||
ARG user | ||
ARG uid | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
curl \ | ||
libpng-dev \ | ||
libonig-dev \ | ||
libxml2-dev \ | ||
zip \ | ||
unzip \ | ||
libzip-dev \ | ||
libmagickwand-dev \ | ||
mariadb-client | ||
|
||
# Clear cache | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pecl install imagick \ | ||
&& docker-php-ext-enable imagick | ||
|
||
# Install PHP extensions | ||
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl bcmath gd | ||
|
||
# Get latest Composer | ||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
|
||
# Create system user to run Composer and Artisan Commands | ||
RUN useradd -G www-data,root -u $uid -d /home/$user $user | ||
RUN mkdir -p /home/$user/.composer && \ | ||
chown -R $user:$user /home/$user | ||
|
||
# Set working directory | ||
WORKDIR /var/www | ||
|
||
USER $user | ||
RUN apk add --no-cache \ | ||
$PHPIZE_DEPS \ | ||
freetype-dev \ | ||
git \ | ||
zip \ | ||
libzip-dev \ | ||
php7-bcmath \ | ||
curl \ | ||
unzip \ | ||
libjpeg-turbo-dev \ | ||
libpng-dev \ | ||
libxml2-dev \ | ||
mariadb-client \ | ||
sqlite \ | ||
php7-json \ | ||
php7-openssl \ | ||
php7-pdo \ | ||
php7-pdo_mysql \ | ||
php7-session \ | ||
php7-simplexml \ | ||
php7-tokenizer \ | ||
php7-xml \ | ||
imagemagick \ | ||
imagemagick-libs \ | ||
imagemagick-dev \ | ||
php7-imagick \ | ||
php7-pcntl \ | ||
--repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ gnu-libiconv=1.15-r3 | ||
|
||
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php | ||
|
||
RUN printf "\n" | pecl install \ | ||
imagick && \ | ||
docker-php-ext-enable --ini-name 20-imagick.ini imagick | ||
|
||
RUN docker-php-ext-configure zip | ||
RUN docker-php-ext-install zip | ||
RUN docker-php-ext-install iconv pdo pdo_mysql bcmath pcntl exif | ||
RUN docker-php-ext-configure gd --with-jpeg --with-freetype | ||
RUN docker-php-ext-install gd |
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
2 changes: 1 addition & 1 deletion
2
...ers/V1/Auth/ConfirmPasswordController.php → .../Admin/Auth/ConfirmPasswordController.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
2 changes: 1 addition & 1 deletion
2
...lers/V1/Auth/ForgotPasswordController.php → ...1/Admin/Auth/ForgotPasswordController.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
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,40 @@ | ||
<?php | ||
|
||
namespace Crater\Http\Controllers\V1\Admin\Auth; | ||
|
||
use Crater\Http\Controllers\Controller; | ||
use Crater\Providers\RouteServiceProvider; | ||
use Illuminate\Foundation\Auth\AuthenticatesUsers; | ||
|
||
class LoginController extends Controller | ||
{ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Login Controller | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This controller handles authenticating users for the application and | ||
| redirecting them to your home screen. The controller uses a trait | ||
| to conveniently provide its functionality to your applications. | ||
| | ||
*/ | ||
|
||
use AuthenticatesUsers; | ||
|
||
/** | ||
* Where to redirect users after login. | ||
* | ||
* @var string | ||
*/ | ||
protected $redirectTo = RouteServiceProvider::HOME; | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('guest')->except('logout'); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ontrollers/V1/Auth/RegisterController.php → ...lers/V1/Admin/Auth/RegisterController.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
2 changes: 1 addition & 1 deletion
2
...llers/V1/Auth/ResetPasswordController.php → ...V1/Admin/Auth/ResetPasswordController.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
2 changes: 1 addition & 1 deletion
2
...ollers/V1/Auth/VerificationController.php → .../V1/Admin/Auth/VerificationController.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
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
85 changes: 85 additions & 0 deletions
85
app/Http/Controllers/V1/Admin/Company/CompaniesController.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,85 @@ | ||
<?php | ||
|
||
namespace Crater\Http\Controllers\V1\Admin\Company; | ||
|
||
use Crater\Http\Controllers\Controller; | ||
use Crater\Http\Requests\CompaniesRequest; | ||
use Crater\Http\Resources\CompanyResource; | ||
use Crater\Models\Company; | ||
use Crater\Models\User; | ||
use Illuminate\Http\Request; | ||
use Silber\Bouncer\BouncerFacade; | ||
use Vinkla\Hashids\Facades\Hashids; | ||
|
||
class CompaniesController extends Controller | ||
{ | ||
public function store(CompaniesRequest $request) | ||
{ | ||
$this->authorize('create company'); | ||
|
||
$user = $request->user(); | ||
|
||
$company = Company::create($request->getCompanyPayload()); | ||
$company->unique_hash = Hashids::connection(Company::class)->encode($company->id); | ||
$company->save(); | ||
$company->setupDefaultData(); | ||
$user->companies()->attach($company->id); | ||
$user->assign('super admin'); | ||
|
||
if ($request->address) { | ||
$company->address()->create($request->address); | ||
} | ||
|
||
return new CompanyResource($company); | ||
} | ||
|
||
public function destroy(Request $request) | ||
{ | ||
$company = Company::find($request->header('company')); | ||
|
||
$this->authorize('delete company', $company); | ||
|
||
$user = $request->user(); | ||
|
||
if ($request->name !== $company->name) { | ||
return respondJson('company_name_must_match_with_given_name', 'Company name must match with given name'); | ||
} | ||
|
||
if ($user->loadCount('companies')->companies_count <= 1) { | ||
return respondJson('You_cannot_delete_all_companies', 'You cannot delete all companies'); | ||
} | ||
|
||
$company->deleteCompany($user); | ||
|
||
return response()->json([ | ||
'success' => true | ||
]); | ||
} | ||
|
||
public function transferOwnership(Request $request, User $user) | ||
{ | ||
$company = Company::find($request->header('company')); | ||
$this->authorize('transfer company ownership', $company); | ||
|
||
if ($user->hasCompany($company->id)) { | ||
return response()->json([ | ||
'success' => false, | ||
'message' => 'User does not belongs to this company.' | ||
]); | ||
} | ||
|
||
$company->update(['owner_id' => $user->id]); | ||
BouncerFacade::sync($user)->roles(['super admin']); | ||
|
||
return response()->json([ | ||
'success' => true | ||
]); | ||
} | ||
|
||
public function getUserCompanies(Request $request) | ||
{ | ||
$companies = $request->user()->companies; | ||
|
||
return CompanyResource::collection($companies); | ||
} | ||
} |
Oops, something went wrong.