master #19

Closed
ilmedova wants to merge 585 commits from master into mahri_dev
257 changed files with 12772 additions and 5523 deletions

View File

@ -3,7 +3,7 @@ APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
BACKEND_URI=admin
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

View File

@ -1,6 +0,0 @@
<?php
namespace App\AccountTypes;
interface AccountTypesService
{
public function create(array $data) : AccountTypesService;
}

View File

@ -1,17 +0,0 @@
<?php
namespace App\AccountTypes;
use App\Http\Resources\BusinessProfileResource;
class BusinessAccount implements AccountTypesService
{
public function create(array $data) : AccountTypesService
{
$account = new BusinessAccount();
return $account->fill($data);
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace App\AccountTypes;
use App\Http\Resources\CompanyProfileResource;
class CompanyAccount implements AccountTypesService
{
public function create(array $data) : AccountTypesService
{
$account = new CompanyAccount();
return $account->fill($data);
}
}

92
app/Http/Controllers/API/AccountController.php Executable file → Normal file
View File

@ -5,24 +5,32 @@
use App\Http\Controllers\Controller;
use App\Http\Requests\API\BankAccountRequest;
use App\Http\Requests\API\ContactsRequest;
use App\Http\Requests\API\DocumentRequest;
use App\Http\Requests\API\ManagementRequest;
use App\Http\Requests\API\ProfileRequest;
use App\Http\Resources\AccountResource;
use App\Models\Account;
use App\Models\Business;
use App\Models\Company;
use App\Http\Resources\ApplicationStatusResource;
use App\Http\Resources\BankResource;
use App\Http\Resources\ContactResource;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AccountController extends Controller
{
public function __construct()
{
$this->middleware(function ($request, $next) {
public function account(Request $request){
$this->account = auth()->user()
->account()
->with('profile')
->first();
return $next($request);
});
$account = Account::with('profile')->find($request->user()->account_id);
}
if(!empty($account)){
return AccountResource::make($account);
public function account(Request $request)
{
if(!empty($this->account)){
return AccountResource::make($this->account);
}
return response()->json([
@ -32,13 +40,12 @@ public function account(Request $request){
public function storeContacts(ContactsRequest $request){
$account = Account::with('profile')->find($request->user()->account_id);
$contacts = $request->only(array_keys($request->rules()));
$data['contacts'] = json_encode($request->only($account->getContactFillables()));
$account->fill($data)->save();
$this->account->fill(['contacts' => json_encode($contacts)]);
if(!empty($account)){
return AccountResource::make($account);
if($this->account->save()){
return new ContactResource((object)$contacts);
}
return response()->json([
@ -49,13 +56,11 @@ public function storeContacts(ContactsRequest $request){
public function storeBankAccount(BankAccountRequest $request){
$account = Account::with('profile')->find($request->user()->account_id);
$bank = $request->only(array_keys($request->rules()));
$this->account->fill(['bank' => json_encode($bank)]);
$data['bank'] = json_encode($request->only($account->getBankFillables()));
$account->fill($data)->save();
if(!empty($account)){
return AccountResource::make($account);
if($this->account->save()){
return BankResource::make((object)$bank);
}
return response()->json([
@ -64,44 +69,35 @@ public function storeBankAccount(BankAccountRequest $request){
}
public function storePersonal(DocumentRequest $request){
$account = Account::with('profile')->find($request->user()->account_id);
$data['document'] = json_encode($request->all());
public function storeProfile()
{
//Profile type using Strategy pattern
$type = config('account.'.$this->account->type.'.class');
$account->profile()->fill($data);
$account->profile()->save();
$profileStrategy = new $type;
return AccountResource::make($account);
}
$profileStrategy->validateRequest();
public function storeManagement(ManagementRequest $request){
if($profile = $profileStrategy->updateProfile($this->account->profile)){
return $profile;
}
return response()->json(['message' => trans('app.account.update_account_error')],400);
}
public function storeProfile(ProfileRequest $request){
$account = Account::with('profile')->find($request->user()->account_id);
if(!empty($account)){
if($account->type == 'business'){
$data['personal'] = $request->all();
$profile = new Business($data);
$account->profile = $profile;
$account->save;
$profile->save();
}
else{
$profile = new Company($request->all());
$account->profile = $profile;
$account->save;
$profile->save();
}
return AccountResource::make($account);
public function numbersAvailibility(){
if(!empty($this->account)){
return ApplicationStatusResource::make($this->account);
}
return response()->json([
'message'=> trans('app.account.not_found')
],404 );
}
}

View File

@ -0,0 +1,202 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Http\Requests\API\DocumentUploadRequest;
use App\Http\Resources\ApplicationResource;
use App\Models\Application;
use App\Models\Attachment;
use App\Models\Document;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
class ApplicationController extends Controller
{
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->account = Auth::user()
->account()
->with('profile')
->first();
return $next($request);
});
}
/**
* Create new Legalization Application
* @return ApplicationResource|\Illuminate\Http\Response
*/
public function create()
{
//validate if profile is filled
if(is_null($this->account) || is_null($this->account->profile))
{
return response([
'success' => false,
'message' => trans('app.application.fill_profile_message'),
],422);
}
//validate legalization number exists
elseif(!$this->account->can_apply && !$this->account->can_extend){
$month = Config::get('settings.legalization_extend') ?? 1;
return response([
'success' => false,
'message' => trans('app.application.expire_message',['one'=>$month])
],422);
}
//delete old application??? Should we replace it???
if($app = $this->account->last_application())
{
if($app->state != 'approved')
return ApplicationResource::make($app);
else{
$app->state = 'archive';
$app->save();
}
}
//upload etmeli dokumentlaryn spisogy
$documents = Document::where($this->account->type,true)
->where(fn($query) => $query->where('all_country',true)
->orWhereHas('countries',function(Builder $query)
{
$query->where('countries.id',$this->account->country_id);
}))
->get();
if($documents->count() == 0)
{
return response([
'success' => false,
'message' => trans('application.list_not_found')
],404);
}
$application = Application::create([
'account_id' => $this->account->id,
'state' => 'draft' //default mysql value is new
]);
foreach ($documents as $document){
$attachment = new Attachment([
'name' => $document->name,
'document_id' => $document->id
]);
$application->attachments()->save($attachment);
}
return ApplicationResource::make($application);
}
/**
* Get accounts legalization application
* @return ApplicationResource
*/
public function get()
{
$appication = $this->account
->applications()
->latest()
->with('attachments')
->first();
if($appication){
return ApplicationResource::make($appication);
}
return response()->json(['success' => false,'message' =>'Not Found'],404);
}
public function apply()
{
$app = $this->account
->applications()
->whereIn('state',['draft','refine'])
->with('attachments')
->latest()
->first();
if( $app )
{
$app->state = 'new';
$app->save();
//todo send email to operators
return response([
'success' => true,
'message' => trans('app.application.app_success_message')
]);
}
return response([
'success' => false,
'message' => trans('app.application.app_error_message')
],400);
}
public function upload(DocumentUploadRequest $request,$attachment_id)
{
$attachment = Attachment::with(['application','document'])->find($attachment_id);
if(!$attachment || !$attachment->application || $attachment->application->account_id != $this->account->id ){
return response()->json(['success' => false, 'message' =>'Bad request'],400);
}
$uploadedFile = $request->file('file');
if($attachment->document->max_size != 0
&& $uploadedFile->getSize() > $attachment->document->max_size * 1024){//max size in kilobytes
return response()->json(['success' => false, 'message' =>trans('app.application.upload_max_size')],422);
}
$filename = Str::snake($attachment->name).'.'.$uploadedFile->getClientOriginalExtension();
$directory = 'documents/'.Carbon::today()->year.'/'.$this->account->id;
$path = $uploadedFile->storePubliclyAs($directory,$filename);
if(!$path){
return response()->json(['success' => false, 'message' =>trans('app.application.upload_failure')],400);
}
$attachment->file = $directory.'/'.$filename;
$attachment->size = number_format($uploadedFile->getSize()/1024, 2, '.', '');
$attachment->type = $uploadedFile->getClientOriginalExtension();
$attachment->save();
return response()->json(['success' => true, 'message' =>trans('app.app.application.upload_success')]);
//todo make attachment relation
}
public function downloadQuestionaire()
{
$headers = [
"Content-type"=>"text/html",
"Content-Disposition"=>"attachment;Filename=myGeneratefile.doc"
];
$content = view('oprosniki.'.$this->account->type,$this->account->profile)->render();
return \Response::make($content,200, $headers);
}
}

View File

@ -0,0 +1,190 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Requests\API\DocumentUploadRequest;
use App\Http\Resources\BrokerApplicationResource;
use App\Models\BrokerApplication;
use App\Models\BrokerAttachment;
use App\Models\BrokerDocument;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class BrokerApplicationController extends Controller
{
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->account = auth()->guard('api')->user()
->account()
->with('profile')
->with('broker_applications')
->first();
return $next($request);
});
}
/**
* Create new Legalization Application
* @return BrokerApplicationResource|\Illuminate\Http\Response
*/
public function create()
{
//validate if profile is filled
if(is_null($this->account) || is_null($this->account->profile))
{
return response([
'success' => false,
'message' => trans('app.application.fill_profile_message'),
],422);
}
//validate legalization number exists
elseif(!$this->account->can_apply_broker && !$this->account->can_extend_broker){
$month = Config::get('settings.legalization_extend') ?? 1;
return response([
'success' => false,
'message' => trans('app.application.expire_message',['one'=>$month])
],422);
}
//delete old application??? Should we replace it???
if($app = $this->account->last_broker_application())
{
if($app->state != 'approved')
return BrokerApplicationResource::make($app);
else{
$app->state = 'archive';
$app->save();
}
}
//upload etmeli dokumentlaryn spisogy
$documents = BrokerDocument::where($this->account->type,true)->get();
if($documents->count() == 0)
{
return response([
'success' => false,
'message' => trans('application.list_not_found')
],404);
}
$application = BrokerApplication::create([
'account_id' => $this->account->id,
'state' => 'draft', //default mysql value is new
'is_local' => $this->account->country->code == "TM" ? true : false
]);
foreach ($documents as $document){
$attachment = new BrokerAttachment([
'name' => $document->name,
'broker_document_id' => $document->id
]);
$application->broker_attachments()->save($attachment);
}
return BrokerApplicationResource::make($application);
}
public function get()
{
$application = $this->account
->broker_applications()
->latest()
->with('broker_attachments')->first();
if($application){
return BrokerApplicationResource::make($application);
}
return response()->json(['success' => false, 'message' => 'Not Found'], 404);
}
public function apply()
{
$app = $this->account
->broker_applications()
->whereIn('state',['draft','refine'])
->with('broker_attachments')
->latest()
->first();
if( $app )
{
$app->state = 'new';
$app->save();
//todo send email to operators
return response([
'success' => true,
'message' => trans('app.application.app_success_message')
]);
}
return response([
'success' => false,
'message' => trans('app.application.app_error_message')
],400);
}
public function upload(DocumentUploadRequest $request,$attachment_id)
{
$broker_attachment = BrokerAttachment::with(['broker_application','broker_document'])->find($attachment_id);
if(!$broker_attachment || !$broker_attachment->broker_application || $broker_attachment->broker_application->account_id != $this->account->id ){
return response()->json(['success' => false, 'message' =>'Bad request'],400);
}
$uploadedFile = $request->file('file');
if($broker_attachment->broker_document->max_size != 0
&& $uploadedFile->getSize() > $broker_attachment->broker_document->max_size * 1024){//max size in kilobytes
return response()->json(['success' => false, 'message' =>trans('app.application.upload_max_size')],422);
}
$filename = Str::snake($broker_attachment->name).'.'.$uploadedFile->getClientOriginalExtension();
$directory = 'broker-documents/'.Carbon::today()->year.'/'.$this->account->id;
$path = $uploadedFile->storePubliclyAs($directory,$filename);
if(!$path){
return response()->json(['success' => false, 'message' =>trans('app.application.upload_failure')],400);
}
$broker_attachment->file = $directory.'/'.$filename;
$broker_attachment->size = number_format($uploadedFile->getSize()/1024, 2, '.', '');
$broker_attachment->type = $uploadedFile->getClientOriginalExtension();
$broker_attachment->save();
return response()->json(['success' => true, 'message' =>trans('app.app.application.upload_success')]);
//todo make attachment relation
}
public function downloadQuestionaire()
{
$headers = [
"Content-type"=>"text/html",
"Content-Disposition"=>"attachment;Filename=myGeneratefile.doc"
];
$content = view('oprosniki.'.$this->account->type,$this->account->profile)->render();
return \Response::make($content,200, $headers);
}
}

View File

@ -2,45 +2,50 @@
namespace App\Http\Controllers\API;
use App\Http\Requests\API\AddClientRequest;
use App\Http\Requests\API\LoginRequest;
use App\Http\Requests\API\RegisterRequest;
use App\Http\Requests\API\ClientRequest;
use App\Http\Requests\API\ResetPassword;
use App\Http\Resources\ClientResource;
use App\Mail\EmailVerification;
use App\Mail\ResetPassword;
use App\Models\Account;
use App\Models\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Lang;
use App\Http\Controllers\Controller;
use App\Notifications\EmailVerify;
use App\Notifications\PasswordReset;
class AuthController extends Controller
class ClientController extends Controller
{
public function login(LoginRequest $request){
$client = Client::where('email', $request->input('email'))->first();
if($client){
if($client->is_suspended){
if($client)
{
if($client->is_suspended)
{
return response()->json([
'message' => 'Account with this email is suspended'
], 403);
'message' => trans('auth.suspended')
], 422);
}
elseif (!$client->is_verified)
{
return response()->json([
'message' => trans('auth.not_verified')
], 422);
}
if (!Hash::check(request()->password, $client->password)){
return response()->json([
'message' => 'Unauthorized'
], 401);
}
elseif ($client->is_suspended){
return response()->json([
'message' => 'Account suspended'
], 401);
'message' => trans('auth.unauthorized')
], 422);
}
$credentials = $request->only('email', 'password');
@ -56,7 +61,7 @@ public function login(LoginRequest $request){
return response()->json(['message' => Lang::get('auth.email_not_found')], 404);
}
public function register(RegisterRequest $request){
public function signup(RegisterRequest $request){
$client = new Client($request->only(['email','firstname','lastname']));
$client->password = Hash::make($request->input('password'));
@ -66,15 +71,7 @@ public function register(RegisterRequest $request){
if($email_verification)
{
$client->verification_token = rand(10000, 99999);
try{
Mail::to($request->email)
->queue(new EmailVerification($request->firstname, $client->verification_token));
}catch (\Exception $ex){
//eger email ugradyp bolmasa verification edip bolmaz
$client->is_verified = true;
}
$client->notify(new EmailVerify($request->firstname, $client->verification_token));
}
$account = Account::create([
@ -83,7 +80,6 @@ public function register(RegisterRequest $request){
]);
$client->account()->associate($account)->save();
if($client->is_verified){
Auth::login($client);
$client->token = $client->createToken('auth_token')->plainTextToken;
@ -112,12 +108,12 @@ public function verifyEmail(Request $request){
return ClientResource::make($client);
}
else{
return response()->json(['message' => 'tokens don\'t match'], 401);
return response()->json(['message' => trans('auth.token_mismatch')], 401);
}
}
else{
return response()->json([
'message' => 'no such client'
'message' => trans('auth.user_not_found')
], 404);
}
}
@ -127,7 +123,7 @@ public function client(Request $request) {
return ClientResource::make($client);
}
return response()->json([
'message' => 'token_expired'
'message' => trans('auth.token_expired')
], 401);
}
@ -145,18 +141,20 @@ public function sendPasswordResetLinkEmail(Request $request) {
$user = Client::where('email', $request->email)->first();
if (!$user) {
return response()->json([
'message' => 'user with provided email not found'
'message' => trans('auth.user_not_found')
], 404);
}
$token = rand(1000, 9999);
$user->notify(new PasswordReset($user->firstname, $token));
$user['verification_token'] = $token;
$user->save();
Mail::to($request->email)->queue(new ResetPassword($user->firstname, $token));
return response()->json([
'message' => 'sent reset code'
'message' => trans('auth.sent_reset_code')
], 200);
}
catch(\Exception $e){
@ -166,32 +164,33 @@ public function sendPasswordResetLinkEmail(Request $request) {
}
}
public function updatePassword(Request $request) {
public function updatePassword(ResetPassword $request) {
try{
$this->validate($request, [
'token' => 'required',
'email' => 'required|email',
'password' => 'required',
'confirm_password' => 'required|same:password'
]);
$user = Client::where('email', $request->email)->first();
if($user && $request->token == $user->token){
if(!$user){
return response()->json([
'message' => trans('auth.user_not_found')
], 404);
}
if($request->token == $user->verification_token){
$user['password'] = Hash::make($request->password);
$user->save();
return response()->json([
'message' => 'OK'
'message' => trans('auth.reset_password_successful')
], 200);
}
return response()->json([
'message' => 'not_found'
'message' => trans('auth.invalid_token')
], 404);
}
catch(\Exception $e){
return response()->json([
'message' => $e->getMessage()
], 500);
], 400);
}
}
@ -213,7 +212,28 @@ public function updateClient(ClientRequest $request){
}
return response()->json([
'message' => 'Your account has not been updated.',
],500);
'message' => trans('app.account.update_profile_error')
],400);
}
public function registerClient(AddClientRequest $request)
{
$client = new Client($request->only(['email','firstname','lastname']));
$client->password = Hash::make($request->input('password'));
$client->is_verified = true;
$client->account_id = $request->user()->account_id;
if($client->save()){
return ClientResource::make($client);
}
return response()->json([
'message' => trans('app.account.update_profile_error')
],400);
}
public function accountClients(){
return ClientResource::collection(request()->user()->account->clients);
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Http\Requests\API\ContractRequest;
use App\Http\Resources\ContractResource;
use App\Models\Contract;
use App\Models\Resolutionbasis;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class ContractController extends Controller
{
public function contract(ContractRequest $request){
if($contract = Contract::with('resolution_basis')->where('InputNumber',$request->get('number'))->first())
{
return ContractResource::make($contract);
}
return response(["message" => "Not Found",'success' => false],);
}
public function import(Request $request){
Log::info($request->all());
foreach($request->all() as $item){
$contract['foreign_ID'] = $item['ID'];
$contract['InputNumber'] = $item['InputNumber'];
$contract['InputDate'] = $item['InputDate'];
$contract['RegDate'] = $item['RegDate'];
$contract['MarkerSpec'] = $item['MarkerSpec'];
$contract['Workflow_ID'] = $item['Workflow_ID'];
$contract['Note'] = $item['Note'];
$contract['Remark'] = $item['Remark'];
$record = Contract::where('foreign_ID', $contract['foreign_ID'])->first();
if($record != null){
$record['InputNumber'] = $item['InputNumber'];
$record['InputDate'] = $item['InputDate'];
$record['RegDate'] = $item['RegDate'];
$record['MarkerSpec'] = $item['MarkerSpec'];
$record['Workflow_ID'] = $item['Workflow_ID'];
$record['Note'] = $item['Note'];
$record['Remark'] = $item['Remark'];
$record->save();
}
else{
Contract::create($contract);
}
}
return 'ok';
}
public function resolutionBasis(Request $request){
//Log::info('resolutionCalled',$request->all());
foreach($request->all() as $entry){
$resolution['contract_id'] = $entry['Contract_ID'];
$resolution['workflow_id'] = $entry['Workflow_ID'];
$resolution['department_id'] = $entry['Department_ID'];
$resolution['resolution_id'] = $entry['Resolution_ID'];
$resolution['resolutionbasis'] = $entry['ResolutionBasis'];
$resolution['foreign_id'] = $entry['ID'];
$res = Resolutionbasis::where('foreign_id', $resolution['foreign_id'])->first();
if($res == null){
Resolutionbasis::create($resolution);
}
}
return 'ok';
}
}

View File

@ -3,14 +3,28 @@
namespace App\Http\Controllers\API;
use App\Http\Resources\CountryResource;
use App\Http\Resources\CategoryResource;
use App\Models\Country;
use App\Models\Category;
use App\Http\Controllers\Controller;
use App\Http\Resources\QuestionResource;
use App\Models\Question;
class ResourceController extends Controller
{
public function countries(){
public function countries()
{
return CountryResource::collection(Country::all());
}
public function categories()
{
return CategoryResource::collection(Category::all());
}
public function faqs()
{
return QuestionResource::collection(Question::get());//todo investigate do we need all??
}
}

View File

@ -4,51 +4,198 @@
use App\Http\Controllers\Controller;
use App\Http\Requests\API\TicketRequest;
use App\Http\Requests\API\MessageRequest;
use App\Http\Resources\MessageResource;
use App\Http\Resources\TicketResource;
use App\Models\Account;
use App\Models\Business;
use App\Models\Category;
use App\Models\Client;
use App\Models\Company;
use App\Models\Message;
use App\Models\Status;
use App\Models\Ticket;
use App\Models\User;
use App\Notifications\ApplicationApproved;
use App\Notifications\TicketMessage;
use App\Notifications\TicketPosted;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Notification;
class TicketController extends Controller
{
public function chat(Request $request){
return view('admin.messages');
public function chat(Request $request)
{
$ticket = Ticket::with(['account.profile','category'])->find($request->ticket_id);
//todo send email to admin
return view('admin.messages',[
'ticket' => $ticket
]);
}
public function getTicketMessages(Request $request){
$messages = Message::where('ticket_id', $request->ticket_id)->orderBy('id', 'asc')->get();
return MessageResource::collection($messages);
public function getTicketMessages(Request $request)
{
if(Ticket::find($request->ticket_id))
{
$messages = Message::with('admin')->where('ticket_id', $request->ticket_id)
->orderBy('id', 'asc')
->paginate($request->per_page ?? 10);
return MessageResource::collection($messages);
}
return response()->json([
"message" => trans('app.ticket.not_found', ['id' => $request->ticket_id]),
"errors" => [
"ticket_id" => [trans('app.ticket.not_found', ['id' => $request->ticket_id])
]
]
], 404);
}
public function postMessage(Request $request){
public function postMessage(MessageRequest $request)
{
try{
$data = $request->all();
$message = new Message($data);
$message = new Message($request->only(['ticket_id', 'content']));
$message['is_client'] = true;
$message['client_id'] = $request->user()->id;
$message->save();
$ticket = Ticket::find($request->ticket_id);
if($ticket->last_sender == 'admin'){
$users = User::with(['permissions' => function($q) {
$q->whereIn("name", ["tickets"]);
}])->get();
Notification::send($users, new TicketMessage());
}
$ticket['last_sender'] = 'client';
$ticket->save();
//todo send notification email to admin
return MessageResource::make($message);
}
catch(\Exception $e){
return $e->getMessage();
}
}
public function getTickets(Request $request){
public function postMessageAdmin(MessageRequest $request)
{
try{
$message = new Message($request->only(['ticket_id', 'content', 'admin_id', 'status_id']));
$message['is_client'] = false;
$message->save();
$ticket = Ticket::find($request->ticket_id);
if($ticket->last_sender == 'client'){
$account = Account::with('clients')->find($ticket->client_id);
Notification::send($account->clients()->where('is_suspended', 0)->get(), new TicketMessage());
}
$ticket['last_sender'] = 'admin';
$ticket->save();
return MessageResource::make($message);
}
catch(\Exception $e){
return $e->getMessage();
}
}
public function getTickets(Request $request)
{
$client = $request->user();
$tickets = Ticket::with('status')->where('client_id', $client->id)->get();
$account = Account::find($client->account_id);
$tickets = Ticket::with('status')->where('client_id', $account->id)
->orderBy('created_at', 'desc')->paginate($request->per_page ?? 10);
return TicketResource::collection($tickets);
}
public function postTicket(TicketRequest $request){
$ticket = new Ticket($request->only('content', 'title'));
$client = $request->user();
$ticket['client_id'] = $client->id;
$status = Status::where('name', 'LIKE', '%' . 'open' . '%')->firstOrFail();
$ticket['status_id'] = $status->id;
$ticket->save();
public function postTicket(TicketRequest $request)
{
$ticket = new Ticket($request->only('content', 'title', 'category_id'));
$category = Category::find($ticket->catgeory_id);
$client = $request->user();
$ticket['client_id'] = $client->account_id;
$status = Status::where('name', 'Open')->firstOrFail();
$ticket['status_id'] = $status->id;
$ticket['last_sender'] = 'client';
$ticket->save();
$users = User::with(["permissions" => function($q) use ($category){
$q->whereIn("name", ["tickets"])->whereIn("name", ["ticket-category-" . $category->name]);
}])->get();
Notification::send($users, new TicketPosted());
return TicketResource::make($ticket);
}
public function createAppTicket(Request $request){
$ticket = new Ticket($request->only('content', 'title','category_id', 'account_id', 'application_id'));
$ticket['status_id'] = 1;
$ticket['client_id'] = $request->account_id;
$ticket['last_sender'] = 'admin';
$ticket->save();
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $request->account_id)->get();
Notification::send($not_suspended_clients, new TicketPosted());
return redirect(route('chat',['ticket_id' => $ticket->id]));
}
public function createBrokerAppTicket(Request $request){
$ticket = new Ticket($request->only('content', 'title','category_id', 'account_id', 'broker_application_id'));
$ticket['status_id'] = 1;
$ticket['client_id'] = $request->account_id;
$ticket['last_sender'] = 'admin';
$ticket->save();
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $request->account_id)->get();
Notification::send($not_suspended_clients, new TicketPosted());
return redirect(route('chat',['ticket_id' => $ticket->id]));
}
public function accountForTicketsAjax(Request $request){
$search_term = $request->input('q');
if ($search_term)
{
$accounts = Account::whereHasMorph('profile',
[Business::class, Company::class],
function (Builder $query) use ($search_term) {
$query->where('name', 'like', '%' . $search_term . '%');
})->paginate(10);
$accounts_array = Account::whereHasMorph('profile',
[Business::class, Company::class],
function (Builder $query) use ($search_term) {
$query->where('name', 'like', '%' . $search_term . '%');
})->paginate(10)->toArray();
$array = [];
foreach($accounts as $account){
if($account->type == 'company'){
$array_item['name'] = $account->profile->name;
}
else{
$array_item['name'] = $account->profile->name . ' ' .$account->profile->surname;
}
$array_item['id'] = $account['id'];
array_push($array, $array_item);
}
$accounts_array['data'] = $array;
}
else
{
$accounts = Account::paginate(10);
$accounts_array = Account::paginate(10)->toArray();
$array = [];
foreach($accounts as $account){
if($account->type == 'company'){
$array_item['name'] = $account->profile->name;
}
else{
$array_item['name'] = $account->profile->name . ' ' . $account->profile->surname;
}
$array_item['id'] = $account['id'];
array_push($array, $array_item);
}
$accounts_array['data'] = $array;
}
return $accounts_array;
}
}

View File

@ -3,10 +3,13 @@
namespace App\Http\Controllers\Admin;
use App\Http\Requests\AccountRequest;
use App\Models\Account;
use App\Models\Business;
use App\Models\Company;
use App\Models\Country;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use Illuminate\Support\Facades\Log;
/**
* Class AccountCrudController
@ -16,7 +19,7 @@
class AccountCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
// use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
@ -29,7 +32,32 @@ public function setup()
{
CRUD::setModel(\App\Models\Account::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/account');
CRUD::setEntityNameStrings('account', 'accounts');
CRUD::setEntityNameStrings(trans('app.account.title'), trans('app.account.list_title'));
$this->crud->addFilter([
'name' => 'type',
'type' => 'dropdown',
'label' => trans('app.account.filter.type')
], [
'business' => trans('app.account.filter.business'),
'company' => trans('app.account.filter.company'),
], function ($value) { // if the filter is active
$this->crud->addClause('where', 'type', $value);
});
if(!(backpack_user()->hasPermissionTo('accounts'))){
$this->crud->denyAccess(['delete', 'update']);
}
$this->crud->addFilter([
'name' => 'country',
'type' => 'select2',
'label' => trans('app.account.country')
], function () {
Country::get()->pluck('name', 'id');
}, function ($value) { // if the filter is active
$this->crud->addClause('where', 'country_id', $value);
});
}
/**
@ -40,22 +68,29 @@ public function setup()
*/
protected function setupListOperation()
{
CRUD::column('type');
CRUD::column('vat');
CRUD::column('country_id');
CRUD::column('legalization_number');
CRUD::addColumn([
'name'=>'account_type',
'type'=>'text',
'label'=> trans('app.account.filter.type'),
]);
CRUD::addColumn([
'name' => 'profile',
'label' => trans('app.account.name'),
'type' => 'profile_name',
'searchLogic' => function ($query, $column, $searchTerm) {
Log::info((array)$column['searchLogic']);
$query->whereHas('profile', function ($q) use ($column, $searchTerm) {
$q->where('name', 'like', '%'.$searchTerm.'%');
});
}
]);
CRUD::addColumn(['name'=>'legalization_number', 'type'=>'text','label'=> trans('app.account.legalization_number')]);
CRUD::addColumn(['name'=>'expires_at', 'type'=>'text','label'=> trans('app.account.expires_at')]);
CRUD::addColumn(['name'=>'country_id', 'type'=>'select','label'=> trans('app.account.country'), 'entity' => 'country' ,'model' => 'App\Model\Country','attribute' => 'name']);
// $this->crud->addFilter([
// 'name' => 'status',
// 'type' => 'dropdown',
// 'label' => 'Account type'
// ], [
// 'company' => 'Company',
// 'business' => 'Business'
// ], function($value) { // if the filter is active
// $this->crud->addClause('where', 'type', $value);
// });
$this->crud->addButtonFromModelFunction('line', 'preview_button', 'preview', 'beginning');
// $this->crud->addButtonFromModelFunction('line', 'export_button', 'export_account', 'beginning');
}
/**
@ -70,53 +105,58 @@ protected function setupCreateOperation()
$this->crud->addFields([
[
'name' => 'contacts',
'label' => 'Contacts',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'address' => 'Address',
'phone' => 'Phone',
'email' => 'Email',
'fax' => 'Fax'
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
'name' => 'legalization_number',
'label' => trans('app.account.legalization_number'),
'type' => 'text',
'tab' => trans('app.account.tab_legalization')
],
[
'name' => 'expires_at',
'label' => trans('app.account.expires_at'),
'type' => 'date',
'tab' => trans('app.account.tab_legalization')
],
[
'name' => 'bank',
'label' => 'Bank',
'label' => trans('app.account.bank'),
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'account_number' => 'Account number',
'account_date' => 'Account date',
'currency' => 'Currency',
'iban' => 'IBAN',
'bank_name' => 'Bank name',
'country' => 'Country'
'account_number' => trans('app.account.account_number'),
'account_date' => trans('app.account.account_date'),
'currency' => trans('app.account.currency'),
'iban' => trans('app.account.iban'),
'bank_name' => trans('app.account.bank_name'),
'country' => trans('app.account.country'),
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
'tab' => trans('app.account.tab_bank'),
],
[
'name' => 'vat',
'label' => 'VAT',
'type' => 'text'
'name' => 'contacts',
'label' => trans('app.account.contacts'),
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'address' => trans('app.account.address'),
'phone' => trans('app.account.phone'),
'email' => trans('app.account.email'),
'fax' => trans('app.account.fax'),
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
'tab' => trans('app.account.tab_contacts'),
],
[
'name' => 'country_id',
'label' => 'Country',
'label' => trans('app.account.country'),
'type' => 'select',
'entity' => 'country',
'model' => "App\Models\Country", // related model
'attribute' => 'name', // foreign key attribute that is shown to user
'tab' => trans('app.account.tab_country'),
],
[
'name' => 'legalization_number',
'label' => 'Legalization number',
'type' => 'text'
]
]);
@ -138,5 +178,22 @@ protected function setupUpdateOperation()
$this->setupCreateOperation();
}
public function previewAccountAdmin($id)
{
$account = Account::with(['country','profile','clients','applications', 'broker_applications'])//tormoz etdirer todo fix this
->find($id);
return view('admin.preview',[
'account' => $account
]);
}
public function createAccountClient($account_id)
{
return view('admin.account_client_create',[
'account_id' => $account_id
]);
}
}

View File

@ -3,8 +3,16 @@
namespace App\Http\Controllers\Admin;
use App\Http\Requests\ApplicationRequest;
use App\Models\Account;
use App\Models\Application;
use App\Models\Client;
use App\Notifications\ApplicationApproved;
use App\Notifications\ApplicationRefined;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Notification;
/**
* Class ApplicationCrudController
@ -14,21 +22,65 @@
class ApplicationCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Application::class);
public function setup(){
if(!(backpack_user()->hasPermissionTo('applications'))){
$this->crud->denyAccess(['update']);
}
if(!(backpack_user()->hasRole('Super Admin'))){
$this->crud->denyAccess(['delete']);
}
CRUD::setModel(Application::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/application');
CRUD::setEntityNameStrings('application', 'applications');
CRUD::setEntityNameStrings('application', trans('app.application.list_title'));
Application::updating(function($entry) {
$entry->modified_by = backpack_user()->name;
});
$this->crud->addClause('where', 'state', '!=', 'Draft');
$this->crud->addFilter([
'name' => 'state',
'type' => 'dropdown',
'label' => trans('app.application.state')
], [
'new' => trans('app.application.new'),
'accepted' => trans('app.application.accepted'),
'refine' => trans('app.application.refine'),
'approved' => trans('app.application.approved'),
'archive' => trans('app.application.archived')
], function ($value) {
$this->crud->addClause('where', 'state', $value);
});
$this->crud->addFilter([
'type' => 'date_range',
'name' => 'from_to',
'label' => trans('app.application.date_filter'),
],
false,
function ($value) {
$dates = json_decode($value);
$this->crud->addClause('where', 'created_at', '>=', $dates->from);
$this->crud->addClause('where', 'created_at', '<=', $dates->to . ' 23:59:59');
});
$this->crud->addFilter([
'type' => 'text',
'name' => 'accepted_by',
'label' => trans('app.last_updates.accepted_by'),
],
false,
function ($value) {
$this->crud->addClause('where', 'accepted_by', 'LIKE', '%' . $value . '%');
});
}
/**
@ -39,33 +91,95 @@ public function setup()
*/
protected function setupListOperation()
{
$this->crud->setFromDb();
//$this->crud->addClause('where', 'state', '!=', 'new');
$this->crud->addColumns([
[
'label' => trans('app.application.name'),
'type' => 'select',
'name' => 'account_type',
'entity' => 'account',
'model' => "App\Models\Account",
'attribute' => 'type_and_name',
],
[
'label' => trans('app.application.leg_number'),
'type' => 'select',
'name' => 'account_legnumber',
'entity' => 'account',
'model' => "App\Models\Account",
'attribute' => 'legalization_number',
],
[
'label' => trans('app.application.expires_at'),
'type' => 'select',
'name' => 'account_exp_date',
'entity' => 'account',
'model' => "App\Models\Account",
'attribute' => 'expires_at',
],
[
'name' => 'state',
'label' => trans('app.application.state'),
'type' => 'badge',
],
[
'name' => 'accepted_by',
'label' => trans('app.last_updates.accepted_by'),
'type' => 'text',
],
[
'name' => 'created_at',
'label' => trans('app.application.created_at'),
]
]);
$this->crud->addButtonFromModelFunction('line', 'preview_button', 'preview', 'beginning');
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(ApplicationRequest::class);
$this->crud->addFields([
['name' => 'account_id', 'type' => 'select', 'label' => 'Account', 'entity' => 'account', 'model' => "App\Models\Account", 'attribute' => 'vat'],
['name' => 'status','label' => 'Status','type' => 'checkbox']
public function accept($id){
$entry = Application::findOrfail($id);
$entry->accepted_by = backpack_user()->name;
$entry->state = 'accepted';
$entry->accepted_date = Carbon::now();
$entry->save();
\Alert::add('success', '<strong>Success!</strong><br>Application is accepted')->flash();
return redirect()->back();
}
public function refine($id){
$entry = Application::findOrfail($id);
$entry->state = 'refine';
$entry->refine_note = request()->get('note');
$entry->save();
$account = Account::with('clients')->find($entry->account_id);
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $account->id)->get();
Notification::send($not_suspended_clients, new ApplicationRefined());
\Alert::add('success', '<strong>Success!</strong><br>Application is refined')->flash();
return redirect()->back();
}
public function approveApplication(Request $request){
$application = Application::find($request->id);
$application->state = 'approved';
$application->approved_by = backpack_user()->name;
$application->approved_date = Carbon::now();
$application->save();
$account = Account::with('clients')->find($application->account_id);
$account->legalization_number = $request->legalization_number;
$account->expires_at = $request->expires_at;
$account->save();
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $account->id)->get();
Notification::send($not_suspended_clients, new ApplicationApproved());
\Alert::add('success', '<strong>Success!</strong><br>Application is approved')->flash();
return redirect()->back();
}
public function previewApplicationAdmin($id){
$application = Application::with(['account', 'attachments', 'ticket'])->find($id);
return view('admin.application_preview',[
'application' => $application
]);
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
$this->crud->setFromDb();
}
}

View File

@ -0,0 +1,197 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\BrokerApplicationRequest;
use App\Models\Account;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use App\Models\BrokerApplication;
use App\Models\Client;
use App\Notifications\ApplicationApproved;
use App\Notifications\ApplicationRefined;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Notification;
/**
* Class BrokerApplicationCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class BrokerApplicationCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('broker-applications'))){
$this->crud->denyAccess(['update']);
}
if(!(backpack_user()->hasRole('Super Admin'))){
$this->crud->denyAccess(['delete']);
}
CRUD::setModel(BrokerApplication::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/broker-application');
CRUD::setEntityNameStrings('broker application', 'broker applications');
BrokerApplication::updating(function($entry) {
$entry->modified_by = backpack_user()->name;
});
$this->crud->addClause('where', 'state', '!=', 'Draft');
$this->crud->addFilter([
'name' => 'state',
'type' => 'dropdown',
'label' => trans('app.application.state')
], [
'new' => trans('app.application.new'),
'accepted' => trans('app.application.accepted'),
'refine' => trans('app.application.refine'),
'approved' => trans('app.application.approved'),
'archive' => trans('app.application.archived')
], function ($value) {
$this->crud->addClause('where', 'state', $value);
});
$this->crud->addFilter([
'type' => 'date_range',
'name' => 'from_to',
'label' => trans('app.application.date_filter'),
],
false,
function ($value) {
$dates = json_decode($value);
$this->crud->addClause('where', 'created_at', '>=', $dates->from);
$this->crud->addClause('where', 'created_at', '<=', $dates->to . ' 23:59:59');
});
$this->crud->addFilter([
'type' => 'text',
'name' => 'accepted_by',
'label' => trans('app.last_updates.accepted_by'),
],
false,
function ($value) {
$this->crud->addClause('where', 'accepted_by', 'LIKE', '%' . $value . '%');
});
$this->crud->addFilter([
'name' => 'is_local',
'type' => 'dropdown',
'label' => trans('app.broker_application.is_local')
], [
0 => trans('app.no'),
1 => trans('app.yes')
], function ($value) {
$this->crud->addClause('where', 'is_local', $value);
});
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
//$this->crud->addClause('where', 'state', '!=', 'new');
$this->crud->addColumns([
[
'label' => trans('app.application.name'),
'type' => 'select',
'name' => 'account_type',
'entity' => 'account',
'model' => "App\Models\Account",
'attribute' => 'type_and_name',
],
[
'label' => trans('app.application.leg_number'),
'type' => 'select',
'name' => 'account_legnumber',
'entity' => 'account',
'model' => "App\Models\Account",
'attribute' => 'legalization_number',
],
[
'label' => trans('app.application.expires_at'),
'type' => 'select',
'name' => 'account_exp_date',
'entity' => 'account',
'model' => "App\Models\Account",
'attribute' => 'expires_at',
],
[
'name' => 'state',
'label' => trans('app.application.state'),
'type' => 'badge',
],
[
'name' => 'accepted_by',
'label' => trans('app.last_updates.accepted_by'),
'type' => 'text',
],
[
'name' => 'created_at',
'label' => trans('app.application.created_at'),
]
]);
$this->crud->addButtonFromModelFunction('line', 'preview_button', 'preview', 'beginning');
}
public function accept($id){
$entry = BrokerApplication::findOrfail($id);
$entry->accepted_by = backpack_user()->name;
$entry->state = 'accepted';
$entry->accepted_date = Carbon::now();
$entry->save();
\Alert::add('success', '<strong>Success!</strong><br>Broker application is accepted')->flash();
return redirect()->back();
}
public function refine($id){
$entry = BrokerApplication::findOrfail($id);
$entry->state = 'refine';
$entry->refine_note = request()->get('note');
$entry->save();
$account = Account::with('clients')->find($entry->account_id);
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $account->id)->get();
Notification::send($not_suspended_clients, new ApplicationRefined());
\Alert::add('success', '<strong>Success!</strong><br>Broker application is refined')->flash();
return redirect()->back();
}
public function approveApplication(Request $request){
$application = BrokerApplication::find($request->id);
$application->state = 'approved';
$application->approved_by = backpack_user()->name;
$application->approved_date = Carbon::now();
$application->save();
$account = Account::with('clients')->find($application->account_id);
$account->broker_number = $request->broker_number;
$account->broker_expires_at = $request->broker_expires_at;
$account->save();
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $account->id)->get();
Notification::send($not_suspended_clients, new ApplicationApproved());
\Alert::add('success', '<strong>Success!</strong><br>Broker application is approved')->flash();
return redirect()->back();
}
public function previewBrokerApplicationAdmin($id){
$application = BrokerApplication::with(['account', 'broker_attachments', 'ticket'])->find($id);
return view('admin.broker_application_preview',[
'application' => $application
]);
}
}

View File

@ -0,0 +1,119 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\BrokerAttachmentRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class BrokerAttachmentCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class BrokerAttachmentCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\BrokerAttachment::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/broker-attachment');
CRUD::setEntityNameStrings('broker attachment', 'broker attachments');
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
$this->crud->setFromDb();
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(BrokerAttachmentRequest::class);
CRUD::addFields([
[
'name' => 'name',
'type' => 'text'
],
[
'name' => 'size',
'type' => 'text'
],
[
'name' => 'type',
'label' => "Type",
'type' => 'select2_from_array',
'options' => ['docx' => 'docx', 'xls' => 'xls', 'pdf' => 'pdf'],
'allows_null' => true,
],
[ // Upload
'name' => 'file',
'label' => 'File',
'type' => 'upload',
'upload' => true,
'disk' => 'uploads', // if you store files in the /public folder, please ommit this; if you store them in /storage or S3, please specify it;
],
[
'name' => 'document_id',
'type' => 'select',
'label' => 'Document',
'entity' => 'document',
'model' => "App\Models\Document",
'attribute' => 'name_ru'
],
[
'name' => 'application_id',
'type' => 'select',
'label' => 'Application',
'entity' => 'application',
'model' => "App\Models\Application",
'attribute' => 'account_id'
],
]);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}

View File

@ -0,0 +1,177 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\BrokerDocumentRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class BrokerDocumentCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class BrokerDocumentCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('broker-documents'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\BrokerDocument::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/broker-document');
CRUD::setEntityNameStrings('broker document', 'broker documents');
$this->crud->addFilter([
'name' => 'business',
'type' => 'dropdown',
'label' => trans('app.resource.business')
], [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
], function ($value) { // if the filter is active
$this->crud->addClause('where', 'business', $value);
});
$this->crud->addFilter([
'name' => 'company',
'type' => 'dropdown',
'label' => trans('app.resource.company')
], [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
], function ($value) { // if the filter is active
$this->crud->addClause('where', 'company', $value);
});
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
$this->crud->addColumns([
[
'name' => 'name',
'type' => 'text',
'label' => trans('app.resource.name')
],
[
'name' => 'max_size',
'type' => 'number',
'label' => trans('app.resource.max_size'),
'default' => 0
],
[
'name' => 'order',
'type' => 'number',
'label' => trans('app.resource.position'),
'default' => 0
],
[
'name' => 'business',
'type' => 'radio',
'label' => trans('app.resource.enterpreneurs'),
'options' => [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
]
],
[
'name' => 'company',
'type' => 'radio',
'label' => trans('app.resource.companies'),
'options' => [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
]
],
]);
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(BrokerDocumentRequest::class);
$this->crud->addFields([
[
'name' => 'name',
'type' => 'text',
'label' => 'Name'
],
[
'name' => 'description',
'type' => 'textarea',
'label' => 'Description'
],
[
'name' => 'max_size',
'type' => 'number',
'label' => 'Max size (KBytes)',
'default' => 0
],
[
'name' => 'order',
'type' => 'number',
'label' => 'Position',
'default' => 0
],
[
'name' => 'business',
'label' => 'Enterpreneurs',
'type' => 'checkbox'
],
[
'name' => 'company',
'label' => 'Companies',
'type' => 'checkbox'
],
[ // Checkbox
'name' => 'is_required',
'label' => 'Is required?',
'type' => 'checkbox'
],
]);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}

View File

@ -16,7 +16,7 @@
class BusinessCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
// use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
@ -28,9 +28,12 @@ class BusinessCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('clients'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Business::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/business');
CRUD::setEntityNameStrings('business', 'businesses');
CRUD::setEntityNameStrings(trans('app.business.title'), trans('app.business.list_title'));
}
/**
@ -42,19 +45,19 @@ public function setup()
protected function setupListOperation()
{
CRUD::addColumn([
'name' => 'personal',
'type' => 'json',
'label' => 'Personal'
'name' => 'name',
'type' => 'text',
'label' => trans('app.business.name')
]);
CRUD::addColumn([
'name' => 'document',
'type' => 'json',
'label' => 'Document'
'name' => 'surname',
'type' => 'text',
'label' => trans('app.business.surname')
]);
CRUD::addColumn([
'name' => 'job',
'type' => 'json',
'label' => 'Job'
'name' => 'patronomic_name',
'type' => 'text',
'label' => trans('app.business.patronomic_name')
]);
@ -77,58 +80,42 @@ protected function setupCreateOperation()
$this->crud->addFields([
[
'name' => 'personal',
'label' => 'Personal',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'name' => 'Name',
'surname' => 'Surname',
'patronomic_name' => 'Patronomic name',
'date_of_birth' => 'Date of birth',
'birth_place' => 'Birth place',
'citizenship_id' => 'Citizenship ID',
'registration_address' => 'Registration address'
],
'max' => 15,
'min' => 0,
'name' => 'name',
'label' => trans('app.business.name'),
'type' => 'text',
],
[
'name' => 'document',
'label' => 'Document',
'type' => 'table',
'entity_singular' => 'option',
'columns' => [
'doc_name' => 'Doc name',
'doc_series' => 'Doc series',
'doc_number' => 'Doc number',
'doc_date' => 'Doc date',
'doc_given_by' => 'Doc given by'
],
'max' => 15,
'min' => 0,
'name' => 'surname',
'label' => trans('app.business.surname'),
'type' => 'text',
],
[
'name' => 'job',
'label' => 'Job',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'work_place' => 'Work place',
'position' => 'Position',
'business_type' => 'Business type',
'licenses' => 'Licenses',
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
'name' => 'patronomic_name',
'label' => trans('app.business.patronomic_name'),
'type' => 'text',
],
[
'label' => "profile",
'name' => 'date_of_birth',
'label' => trans('app.business.date_of_birth'),
'type' => 'date',
],
[
'name' => 'birth_place',
'label' => trans('app.business.birth_place'),
'type' => 'text',
],
[
'name' => 'registration_address',
'label' => trans('app.business.registration_address'),
'type' => 'text',
],
[
'label' =>trans('app.business.citizenship'),
'type' => 'select',
'name' => 'account.id', // the method that defines the relationship in your Model
'entity' => 'account', // the method that defines the relationship in your Model
'attribute' => 'id', // foreign key attribute that is shown to user
'model' => "App\Models\Account", // foreign key model
'name' => 'citizenship', // the method that defines the relationship in your Model
'entity' => 'citizenship', // the method that defines the relationship in your Model
'attribute' => 'name', // foreign key attribute that is shown to user
'model' => "App\Models\Country", // foreign key model
]
]);

View File

@ -5,6 +5,7 @@
use App\Http\Requests\CategoryRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use Backpack\PermissionManager\app\Models\Permission;
/**
* Class CategoryCrudController
@ -17,7 +18,7 @@ class CategoryCrudController extends CrudController
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
/**
* Configure the CrudPanel object. Apply settings to all operations.
@ -26,6 +27,9 @@ class CategoryCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('ticket-category'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Category::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/category');
CRUD::setEntityNameStrings('category', 'categories');
@ -39,9 +43,7 @@ public function setup()
*/
protected function setupListOperation()
{
CRUD::column('name_en');
CRUD::column('name_ru');
CRUD::column('name_tm');
CRUD::column('name');
/**
* Columns can be defined using the fluent syntax or array syntax:
@ -60,9 +62,7 @@ protected function setupCreateOperation()
{
CRUD::setValidation(CategoryRequest::class);
CRUD::field('name_en');
CRUD::field('name_ru');
CRUD::field('name_tm');
CRUD::field('name');
/**
* Fields can be defined using the fluent syntax or array syntax:
@ -81,4 +81,14 @@ protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
public function store()
{
$response = $this->traitStore();
Permission::create([
'name' => "ticket-category-" . $this->crud->getRequest()->request->get('name'),
'guard_name' => 'web'
]);
return $response;
}
}

View File

@ -3,8 +3,10 @@
namespace App\Http\Controllers\Admin;
use App\Http\Requests\ClientRequest;
use App\Models\Client;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use Illuminate\Http\Request;
/**
* Class ClientCrudController
@ -14,10 +16,9 @@
class ClientCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
// use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
@ -26,9 +27,34 @@ class ClientCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('clients'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Client::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/client');
CRUD::setEntityNameStrings('client', 'clients');
CRUD::setEntityNameStrings(trans('app.client.title'), trans('app.client.list_title'));
$this->crud->addFilter([
'name' => 'is_verified',
'type' => 'dropdown',
'label' => trans('app.client.is_verified')
], [
1 => trans('app.yes'),
0 => trans('app.no'),
], function ($value) { // if the filter is active
$this->crud->addClause('where', 'is_verified', $value);
});
$this->crud->addFilter([
'name' => 'is_suspended',
'type' => 'dropdown',
'label' => trans('app.client.is_suspended'),
], [
1 => trans('app.yes'),
0 => trans('app.no'),
], function ($value) { // if the filter is active
$this->crud->addClause('where', 'is_suspended', $value);
});
}
/**
@ -39,13 +65,29 @@ public function setup()
*/
protected function setupListOperation()
{
CRUD::column('firstname');
CRUD::column('lastname');
CRUD::column('email');
CRUD::column('status');
CRUD::column('account_id');
CRUD::column('created_at');
CRUD::column('updated_at');
CRUD::addColumns([
['name' => 'firstname','type'=>'text','label'=> trans('app.client.firstname')],
['name' => 'lastname','type'=>'text','label'=> trans('app.client.lastname')],
['name' => 'email','type'=>'text','label'=> trans('app.client.email')],
[
'name' => 'is_verified',
'type' => 'radio',
'label' => trans('app.client.is_verified'),
'options' => [
1 => trans('app.yes'),
0 => trans('app.no'),
]
],
[
'name' => 'is_suspended',
'type' => 'radio',
'label' => trans('app.client.is_suspended'),
'options' => [
1 => trans('app.yes'),
0 => trans('app.no'),
]
]
]);
}
/**
@ -58,14 +100,15 @@ protected function setupCreateOperation()
{
CRUD::setValidation(ClientRequest::class);
CRUD::field('firstname');
CRUD::field('lastname');
CRUD::field('email');
CRUD::field('status');
CRUD::field('is_suspended');
CRUD::field('account_id');
CRUD::field('created_at');
CRUD::field('updated_at');
CRUD::addFields([
['name' => 'firstname','type'=>'text','label'=> trans('app.client.firstname')],
['name' => 'lastname','type'=>'text','label'=> trans('app.client.lastname')],
['name' => 'email','type'=>'text','label'=> trans('app.client.email')],
['name' => 'is_suspended', 'type' => 'switch', 'label' => trans('app.client.is_suspended')],
['name' => 'is_verified', 'type' => 'switch', 'label' => trans('app.client.is_verified')]
]);
}
/**
@ -78,4 +121,13 @@ protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
public function createClient(Request $request){
$data = $request->only('firstname', 'lastname', 'email', 'password', 'account_id');
$data['is_verified'] = false;
$data['is_suspended'] = false;
$client = new Client($data);
$client->save();
return redirect()->to('/admin/preview/' . $request->account_id . '#users');
}
}

View File

@ -15,7 +15,7 @@
class CompanyCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
// use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
@ -27,9 +27,12 @@ class CompanyCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('clients'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Company::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/company');
CRUD::setEntityNameStrings('company', 'companies');
CRUD::setEntityNameStrings(trans('app.company.title'), trans('app.company.list_title'));
}
/**
@ -40,30 +43,28 @@ public function setup()
*/
protected function setupListOperation()
{
CRUD::column('name');
CRUD::column('short_name');
CRUD::column('registration_number');
CRUD::addColumn([ // Date
'name' => 'registration_date',
'label' => 'Regitration date',
'type' => 'date'
CRUD::addColumns([
['name' => 'name', 'type' => 'text', 'label' => trans('app.company.name')],
['name' => 'short_name', 'type' => 'text', 'label' => trans('app.company.short_name')],
['name' => 'registration_number', 'type' => 'text', 'label' => trans('app.company.registration_number')],
['name' => 'state_registration_agency', 'type' => 'text', 'label' => trans('app.company.state_registration_agency')],
['name' => 'registration_place', 'type' => 'text', 'label' => trans('app.company.registration_place')],
['name' => 'registration_address', 'type' => 'text', 'label' => trans('app.company.registration_address')],
[ // Date
'name' => 'registration_date',
'label' => trans('app.company.registration_date'),
'type' => 'date'
]
]);
CRUD::column('state_registration_agency');
CRUD::column('registration_place');
CRUD::column('registration_address');
CRUD::column('fond_capital');
CRUD::column('management_types');
CRUD::column('signers');
CRUD::column('share_holders');
CRUD::column('organizational_form');
CRUD::column('is_agent');
}
protected function setupShowOperation()
{
$this->setupListOperation();
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
@ -75,45 +76,20 @@ protected function setupListOperation()
protected function setupCreateOperation()
{
CRUD::setValidation(CompanyRequest::class);
CRUD::field('name');
CRUD::field('short_name');
CRUD::field('registration_number');
CRUD::addFields([
['name' => 'name', 'type' => 'text', 'label' => trans('app.company.name')],
['name' => 'short_name', 'type' => 'text', 'label' => trans('app.company.short_name')],
['name' => 'registration_number', 'type' => 'text', 'label' => trans('app.company.registration_number')],
['name' => 'state_registration_agency', 'type' => 'text', 'label' => trans('app.company.state_registration_agency')],
['name' => 'registration_place', 'type' => 'text', 'label' => trans('app.company.registration_place')],
['name' => 'registration_address', 'type' => 'text', 'label' => trans('app.company.registration_address')],
]);
CRUD::addField([ // Date
'name' => 'registration_date',
'label' => 'Regitration date',
'label' => trans('app.company.registration_date'),
'type' => 'date'
]);
CRUD::field('state_registration_agency');
CRUD::field('registration_place');
CRUD::field('registration_address');
CRUD::field('fond_capital');
CRUD::field('management_types');
CRUD::field([
'name' => 'signers',
'label' => 'Signers',
'type' => 'table',
'entity_singular' => 'option', // used on the "Add X" button
'columns' => [
'fullname' => 'Fullname',
'birthdate_n_birthplace' => 'Birthdate, place',
'citizenzhip' => 'Citizenship',
'registratino_address' => 'Registration address',
'' => '',
],
'max' => 15, // maximum rows allowed in the table
'min' => 0, // minimum rows allowed in the table
]);
CRUD::field('share_holders');
CRUD::field('organizational_form');
CRUD::field('is_agent');
CRUD::addField([
'label' => "profile",
'type' => 'select',
'name' => 'account.id', // the method that defines the relationship in your Model
'entity' => 'account', // the method that defines the relationship in your Model
'attribute' => 'id', // foreign key attribute that is shown to user
'model' => "App\Models\Account", // foreign key model
]);
/**
* Fields can be defined using the fluent syntax or array syntax:

View File

@ -0,0 +1,171 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\ContractRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use Illuminate\Support\Facades\Lang;
/**
* Class ContractCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class ContractCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('contracts'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Contract::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/contract');
CRUD::setEntityNameStrings(trans('app.contract.title'), trans('app.contract.list_title'));
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::addColumns([
[
'name' => 'foreign_ID',
'label' => 'Foreign',
'type' => 'text'
],
[
'name' => 'InputNumber',
'label' => trans('app.contract.input_number'),
'type' => 'text'
],
[
'name' => 'InputDate',
'label' => trans('app.contract.input_date'),
'type' => 'text'
],
[
'name' => 'RegDate',
'label' => trans('app.contract.reg_date'),
'type' => 'text'
],
[
'name' => 'MarkerSpec',
'label' => trans('app.contract.status_marker'),
'type' => 'closure',
'function' => function($entry) {
return $entry->MarkerSpec ? Lang::get('imported.markerspec.' . $entry->MarkerSpec) : "";
}
],
[
'name' => 'Workflow_ID',
'label' => trans('app.contract.workflow'),
'type' => 'closure',
'function' => function($entry) {
return Lang::get('imported.workflow.' . $entry->Workflow_ID);
}
],
[
'name' => 'Note',
'label' => trans('app.contract.note'),
'type' => 'text'
],
[
'name' => 'Remark',
'label' => trans('app.contract.remark'),
'type' => 'text'
],
]);
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(ContractRequest::class);
CRUD::addFields([
[
'name' => 'InputNumber',
'label' => trans('app.contract.input_number'),
'type' => 'text'
],
[
'name' => 'InputDate',
'label' => trans('app.contract.input_date'),
'type' => 'text'
],
[
'name' => 'RegDate',
'label' => trans('app.contract.reg_date'),
'type' => 'text'
],
[
'name' => 'MarkerSpec',
'label' => trans('app.contract.status_marker'),
'type' => 'closure',
'function' => function($entry) {
return Lang::get('imported.markerspec.' . $entry->MarkerSpec);
}
],
[
'name' => 'Workflow_ID',
'label' => trans('app.contract.workflow'),
'type' => 'closure',
'function' => function($entry) {
return Lang::get('imported.workflow.' . $entry->Workflow_ID);
}
],
[
'name' => 'Note',
'label' => trans('app.contract.note'),
'type' => 'text'
],
[
'name' => 'Remark',
'label' => trans('app.contract.remark'),
'type' => 'text'
],
]);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}

View File

@ -21,37 +21,50 @@ class CountryCrudController extends CrudController
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
*
* @return void
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('countries'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Country::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/country');
CRUD::setEntityNameStrings('country', 'countries');
CRUD::setEntityNameStrings(trans('app.resource.country'), trans('app.resource.countries'));
}
/**
* Define what happens when the List operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
CRUD::column('name');
CRUD::column('code');
CRUD::addColumns([
[
'name' => 'name',
'label' => trans('app.resource.name'),
'type' => 'text'
],
[
'name' => 'code',
'label' => trans('app.resource.code'),
'type' => 'text'
]
]);
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
@ -59,19 +72,29 @@ protected function setupCreateOperation()
{
CRUD::setValidation(CountryRequest::class);
CRUD::field('name');
CRUD::field('code');
CRUD::addFields([
[
'name' => 'name',
'label' => trans('app.resource.name'),
'type' => 'text'
],
[
'name' => 'code',
'label' => trans('app.resource.code'),
'type' => 'text'
]
]);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/

View File

@ -0,0 +1,86 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\DepartmentRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class DepartmentCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class DepartmentCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Department::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/department');
CRUD::setEntityNameStrings(trans('app.resolution.department'), trans('app.resolution.departments'));
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
//CRUD::column('id');
CRUD::addColumn([
'name' => 'title',
'type' => 'text',
'label' => trans('app.account.name')
]);
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(DepartmentRequest::class);
CRUD::addField([
'name' => 'title',
'type' => 'text',
'label' => trans('app.account.name')
]);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin;
use App\Http\Requests\DocumentRequest;
use App\Models\Country;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
@ -17,7 +18,6 @@ class DocumentCrudController extends CrudController
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
@ -26,9 +26,69 @@ class DocumentCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('documents'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Document::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/document');
CRUD::setEntityNameStrings('document', 'documents');
CRUD::setEntityNameStrings(trans('app.resource.document'), trans('app.resource.documents'));
$this->crud->addFilter([
'name' => 'business',
'type' => 'dropdown',
'label' => trans('app.resource.business')
], [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
], function ($value) { // if the filter is active
$this->crud->addClause('where', 'business', $value);
});
$this->crud->addFilter([
'name' => 'company',
'type' => 'dropdown',
'label' => trans('app.resource.company')
], [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
], function ($value) { // if the filter is active
$this->crud->addClause('where', 'company', $value);
});
$this->crud->addFilter([
'name' => 'all_country',
'type' => 'dropdown',
'label' => trans('app.resource.all_countries')
], [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
], function ($value) {
$this->crud->addClause('where', 'all_country', $value);
});
// select2_multiple filter
$this->crud->addFilter([
'name' => 'countries',
'type' => 'select2_multiple',
'label' => trans('app.resource.countries')
], function() {
return Country::all()->pluck('name', 'id')->toArray();
}, function($values) {
if(!is_array($values)){
foreach (json_decode($values) as $key => $value) {
$this->crud->query = $this->crud->query->whereHas('countries', function ($query) use ($value) {
$query->where('country_id', $value);
});
}
}
else{
foreach ($values as $key => $value) {
$this->crud->query = $this->crud->query->whereHas('countries', function ($query) use ($value) {
$query->where('country_id', $value);
});
}
}
});
}
/**
@ -39,7 +99,66 @@ public function setup()
*/
protected function setupListOperation()
{
$this->crud->setFromDb();
$this->crud->addColumns([
[
'name' => 'name',
'type' => 'text',
'label' => trans('app.resource.name')
],
[
'name' => 'max_size',
'type' => 'number',
'label' => trans('app.resource.max_size'),
'default' => 0
],
[
'name' => 'order',
'type' => 'number',
'label' => trans('app.resource.position'),
'default' => 0
],
[
'name' => 'business',
'type' => 'radio',
'label' => trans('app.resource.enterpreneurs'),
'options' => [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
]
],
[
'name' => 'company',
'type' => 'radio',
'label' => trans('app.resource.companies'),
'options' => [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
]
],
[
'name' => 'all_country',
'type' => 'radio',
'label' => trans('app.resource.all_countries'),
'options' => [
1 => trans('app.resource.yes'),
0 => trans('app.resource.no')
]
],
[
'label' => trans('app.resource.doc_countries'),
'type' => 'select_multiple',
'name' => 'countries',
'entity' => 'countries',
'model' => "App\Models\Country",
'attribute' => 'name',
'pivot' => true,
'options' => (function ($query) {
return $query->orderBy('name', 'ASC')->get();
}),
],
]);
}
/**
@ -63,9 +182,50 @@ protected function setupCreateOperation()
'label' => 'Description'
],
[
'name' => 'max_size',
'type' => 'text',
'label' => 'Max size'
'name' => 'max_size',
'type' => 'number',
'label' => 'Max size (KBytes)',
'default' => 0
],
[
'name' => 'order',
'type' => 'number',
'label' => 'Position',
'default' => 0
],
[
'name' => 'business',
'label' => 'Enterpreneurs',
'type' => 'checkbox'
],
[
'name' => 'company',
'label' => 'Companies',
'type' => 'checkbox'
],
[
'name' => 'all_country',
'label' => 'All countries',
'type' => 'checkbox'
],
[ // Checkbox
'name' => 'is_required',
'label' => 'Is required?',
'type' => 'checkbox'
],
[
'label' => "Document Countries",
'type' => 'select2_multiple',
'name' => 'countries',
'entity' => 'countries',
'model' => "App\Models\Country",
'attribute' => 'name',
'pivot' => true,
'options' => (function ($query) {
return $query->orderBy('name', 'ASC')->get();
}),
]
]);
}

View File

@ -21,11 +21,14 @@ class DocumentgroupCountryCrudController extends CrudController
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
*
* @return void
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('documents'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\DocumentgroupCountry::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/documentgroup-country');
CRUD::setEntityNameStrings('documentgroup country', 'documentgroup countries');
@ -33,24 +36,24 @@ public function setup()
/**
* Define what happens when the List operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
@ -58,18 +61,18 @@ protected function setupCreateOperation()
{
CRUD::setValidation(DocumentgroupCountryRequest::class);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/

View File

@ -17,7 +17,6 @@ class DocumentgroupCrudController extends CrudController
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
@ -26,6 +25,9 @@ class DocumentgroupCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('documents'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Documentgroup::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/documentgroup');
CRUD::setEntityNameStrings('documentgroup', 'documentgroups');
@ -39,7 +41,38 @@ public function setup()
*/
protected function setupListOperation()
{
$this->crud->setFromDb();
$this->crud->addColumns([
[
'name' => 'name',
'type' => 'text',
'label' => 'Name'
],
[
'name' => 'type',
'type' => 'select_from_array',
'label' => 'Type',
'options' => [
'business' => 'business',
'company' => 'company'
]
],
[ // SelectMultiple = n-n relationship (with pivot table)
'label' => "Countries",
'type' => 'select_multiple',
'name' => 'countries', // the method that defines the relationship in your Model
// optional
'entity' => 'countries', // the method that defines the relationship in your Model
'model' => "App\Models\Country", // foreign key model
'attribute' => 'name', // foreign key attribute that is shown to user
'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
// also optional
'options' => (function ($query) {
return $query->orderBy('name', 'ASC')->get();
}), // force the related options to be a custom query, instead of all(); you can use this to filter the results show in the select
],
]);
}
/**
@ -52,7 +85,7 @@ protected function setupCreateOperation()
{
CRUD::setValidation(DocumentgroupRequest::class);
$this->crud->addField([
$this->crud->addFields([
[
'name' => 'name',
'type' => 'text',
@ -65,9 +98,29 @@ protected function setupCreateOperation()
],
[
'name' => 'type',
'type' => 'text',
'label' => 'Type'
]
'type' => 'select_from_array',
'label' => 'Type',
'options' => [
'business' => 'business',
'company' => 'company'
]
],
[ // SelectMultiple = n-n relationship (with pivot table)
'label' => "Countries",
'type' => 'select_multiple',
'name' => 'countries', // the method that defines the relationship in your Model
// optional
'entity' => 'countries', // the method that defines the relationship in your Model
'model' => "App\Models\Country", // foreign key model
'attribute' => 'name', // foreign key attribute that is shown to user
'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
// also optional
'options' => (function ($query) {
return $query->orderBy('name', 'ASC')->get();
}), // force the related options to be a custom query, instead of all(); you can use this to filter the results show in the select
],
]);
}

View File

@ -21,11 +21,14 @@ class DocumentgroupDocumentCrudController extends CrudController
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
*
* @return void
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('documents'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\DocumentgroupDocument::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/documentgroup-document');
CRUD::setEntityNameStrings('documentgroup document', 'documentgroup documents');
@ -33,24 +36,18 @@ public function setup()
/**
* Define what happens when the List operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
$this->crud->setFromDb();
}
/**
* Define what happens when the Create operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
@ -58,18 +55,12 @@ protected function setupCreateOperation()
{
CRUD::setValidation(DocumentgroupDocumentRequest::class);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
$this->crud->setFromDb();
}
/**
* Define what happens when the Update operation is loaded.
*
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/

View File

@ -0,0 +1,26 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
class LocalizationController extends Controller
{
public function setLang(Request $request){
if($request->lang == 'ru'){
$request->session()->put('locale', $request->lang);
App::setLocale('ru');
}
elseif($request->lang == 'tm'){
$request->session()->put('locale', $request->lang);
App::setLocale('tm');
}
else{
$request->session()->put('locale', $request->lang);
App::setLocale('en');
}
return redirect()->back();
}
}

View File

@ -25,6 +25,9 @@ class MessageCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('tickets'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Message::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/message');
CRUD::setEntityNameStrings('message', 'messages');

View File

@ -26,9 +26,12 @@ class QuestionCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('tickets'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Question::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/question');
CRUD::setEntityNameStrings('question', 'questions');
CRUD::setEntityNameStrings(trans('app.faq.title'), trans('app.faq.list_title'));
}
/**
@ -39,7 +42,18 @@ public function setup()
*/
protected function setupListOperation()
{
$this->crud->setFromDb();
CRUD::addColumns([
[
'name' => 'question_text',
'type' => 'text',
'label' => trans('app.faq.question_text')
],
[
'name' => 'options',
'type' => 'text',
'label' => trans('app.faq.answer')
]
]);
}
/**
@ -55,13 +69,13 @@ protected function setupCreateOperation()
CRUD::addFields([
[
'name' => 'question_text',
'type' => 'textarea',
'label' => 'Question text'
'type' => 'text',
'label' => trans('app.faq.question_text')
],
[
'name' => 'options',
'type' => 'text',
'label' => 'Options'
'type' => 'simplemde',
'label' => trans('app.faq.answer')
]
]);
}

View File

@ -0,0 +1,86 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\ResolutionRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class ResolutionCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class ResolutionCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Resolution::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/resolution');
CRUD::setEntityNameStrings(trans('app.resolution.resolution'), trans('app.resolution.resolutions'));
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
//CRUD::column('id');
CRUD::addColumn([
'name' => 'title',
'type' => 'text',
'label' => trans('app.account.name')
]);
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(ResolutionRequest::class);
CRUD::addFields([
'name' => 'title',
'type' => 'text',
'label' => trans('app.account.name')
]);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\ResolutionbasisRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class ResolutionbasisCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class ResolutionbasisCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
/**
* Configure the CrudPanel object. Apply settings to all operations.
*
* @return void
*/
public function setup()
{
CRUD::setModel(\App\Models\Resolutionbasis::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/resolutionbasis');
CRUD::setEntityNameStrings(trans('app.resolution.resolutionbasis'), trans('app.resolution.resolutionbases'));
}
/**
* Define what happens when the List operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
* @return void
*/
protected function setupListOperation()
{
$this->crud->enableExportButtons();
$this->crud->addColumns([
[
'name' => 'contract_id',
'type' => 'select',
'label' => trans('app.contract.title'),
'entity' => 'contract',
'attribute' => 'InputNumber',
'model' => 'App\Models\Contract',
'searchLogic' => function ($query, $column, $searchTerm) {
$query->whereHas('contract', function ($q) use ($column, $searchTerm) {
$q->where('InputNumber', 'like', '%'.$searchTerm.'%');
});
}
],
[
'name' => 'department_id',
'type' => 'select',
'label' => trans('app.resolution.department'),
'entity' => 'department',
'attribute' => 'title',
'model' => 'App\Models\Department',
'searchLogic' => false
],
[
'name' => 'resolution_id',
'type' => 'select',
'label' => trans('app.resolution.resolution'),
'entity' => 'resolution',
'attribute' => 'title',
'model' => 'App\Models\Resolution',
'searchLogic' => false
],
[
'name' => 'resolutionbasis',
'type' => 'text',
'label' => trans('app.resolution.resolutionbasis'),
'searchLogic' => false
]
]);
/**
* Columns can be defined using the fluent syntax or array syntax:
* - CRUD::column('price')->type('number');
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
*/
}
/**
* Define what happens when the Create operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-create
* @return void
*/
protected function setupCreateOperation()
{
CRUD::setValidation(ResolutionbasisRequest::class);
/**
* Fields can be defined using the fluent syntax or array syntax:
* - CRUD::field('price')->type('number');
* - CRUD::addField(['name' => 'price', 'type' => 'number']));
*/
}
/**
* Define what happens when the Update operation is loaded.
*
* @see https://backpackforlaravel.com/docs/crud-operation-update
* @return void
*/
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}

View File

@ -26,6 +26,9 @@ class StatusCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('ticket-status'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Status::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/status');
CRUD::setEntityNameStrings('status', 'statuses');

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin;
use App\Http\Requests\TicketRequest;
use App\Models\Status;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
@ -25,9 +26,23 @@ class TicketCrudController extends CrudController
*/
public function setup()
{
if(!(backpack_user()->hasPermissionTo('tickets'))){
$this->crud->denyAccess(['delete', 'update']);
}
CRUD::setModel(\App\Models\Ticket::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/ticket');
CRUD::setEntityNameStrings('ticket', 'tickets');
CRUD::setEntityNameStrings(trans('app.ticket.title'), trans('app.ticket.list_title'));
// select2 filter
$this->crud->addFilter([
'name' => 'status',
'type' => 'select2',
'label' => trans('app.ticket.status'),
], function () {
return Status::get()->pluck('name', 'id')->toArray();
}, function ($value) { // if the filter is active
$this->crud->addClause('where', 'status_id', $value);
});
}
/**
@ -40,27 +55,29 @@ protected function setupListOperation()
{
$this->crud->addColumns([
[
'name' => 'title',
'name' => 'content',
'type' => 'text',
'label' => 'Title'
'label' => trans('app.ticket.content')
],
[
'name' => 'content',
'type' => 'textarea',
'label' => 'Content'
'name' => 'title',
'type' => 'text',
'label' => trans('app.ticket.ticket_title')
],
[
'name' => 'client_id',
'entity' => 'client',
'type' => 'select',
'label' => 'Client',
'attribute' => 'email',
'model' => 'App\Models\Client'
'type' => 'account_profile_name',
'label' => trans('app.ticket.account'),
],
[
'name' => 'status',
'type' => 'status',
'label' => 'Status'
'label' => trans('app.ticket.status'),
],
[
'name' => 'application_id',
'type' => 'text',
'label' => trans('app.ticket.application_id')
]
]);
@ -79,31 +96,58 @@ protected function setupCreateOperation()
$this->crud->addFields([
[
'name' => 'title',
'type' => 'text',
'label' => 'Title'
'name' => 'title',
'type' => 'text',
'label' => trans('app.ticket.ticket_title')
],
[
'name' => 'content',
'type' => 'textarea',
'label' => 'Content'
'name' => 'content',
'type' => 'textarea',
'label' => trans('app.ticket.content')
],
// [ // SelectMultiple = n-n relationship (with pivot table)
// 'label' => trans('app.ticket.account'),
// 'type' => 'custom_select_account',
// 'name' => 'client_id', // the method that defines the relationship in your Model
// 'entity' => 'account', // the method that defines the relationship in your Model
// 'model' => "App\Models\Account", // foreign key model
// 'attribute_1' => 'name', // foreign key attribute that is shown to user
// 'attribute_2' => 'surname',
// ],
[ //NOT WORKING
'label' => trans('app.ticket.account'), // Table column heading
'type' => "select2_from_ajax",
'name' => 'client_id', // the column that contains the ID of that connected entity
'entity' => 'account', // the method that defines the relationship in your Model
'attribute' => "name", // foreign key attribute that is shown to user
'data_source' => backpack_url('account/fetch'),
'placeholder' => "Select a client", // placeholder for the select
'minimum_input_length' => 2, // minimum characters to type before querying results
'model' => "App\Models\Account", // foreign key model
'method' => 'POST', // optional - HTTP method to use for the AJAX call (GET, POST)
],
[
'name' => 'client_id',
'entity' => 'client',
'type' => 'select',
'label' => 'Client',
'attribute' => 'email',
'model' => 'App\Models\Client'
],
[
'name' => 'status_id',
'entity' => 'status',
'type' => 'select',
'label' => 'Status',
'name' => 'category_id',
'entity' => 'category',
'type' => 'select',
'label' => trans('app.ticket.category'),
'attribute' => 'name',
'model' => 'App\Models\Status'
'model' => 'App\Models\Category'
],
[
'name' => 'status_id',
'entity' => 'status',
'type' => 'select',
'label' =>trans('app.ticket.status'),
'attribute' => 'name',
'model' => 'App\Models\Status'
],
[
'name' => 'last_sender',
'type' => 'hidden',
'value' => 'admin',
]
]);
}

View File

@ -6,6 +6,7 @@
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Auth;
class Controller extends BaseController
{

View File

@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers;
use App\Models\Account;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
use App\View\Composers\ProfileComposer;
use Laravel\Sanctum\PersonalAccessToken;
class ExportController extends Controller
{
public function exportAccount($hashedTooken){
$token = PersonalAccessToken::findToken($hashedTooken);
$user = $token->tokenable;
$account = $user->account()->with('profile')->first();
//dd(json_decode($account->bank));
$headers = array(
"Content-type"=>"text/html",
"Content-Disposition"=>"attachment;Filename=Sowalnama.doc"
);
$content = view('oprosniki.'.$account->type, ['account' => $account])->render();
return \Response::make($content,200, $headers);
}
public function export($id){
$account = Account::with('profile')->find($id);
//dd(json_decode($account->bank));
$headers = array(
"Content-type"=>"text/html",
"Content-Disposition"=>"attachment;Filename=Sowalnama.doc"
);
$content = view('oprosniki.'.$account->type, ['account' => $account])->render();
return \Response::make($content,200, $headers);
}
}

View File

@ -36,6 +36,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
'web_localization',
],
'api' => [
@ -66,6 +67,7 @@ class Kernel extends HttpKernel
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'auth.client' => \App\Http\Middleware\ClientUserProvider::class,
'localization' => \App\Http\Middleware\Localization::class,
'web_localization' => \App\Http\Middleware\WebLocalization::class
];
protected $middlewarePriority = [

View File

@ -15,7 +15,7 @@ class Authenticate extends Middleware
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
return response(['message' =>'Forbidden'],403);
}
}
}

View File

@ -4,6 +4,7 @@
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ClientUserProvider
{
@ -14,8 +15,16 @@ class ClientUserProvider
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
// public function handle($request, Closure $next, $guard = 'api')
// {
// return response()->json(Auth::guard($guard)->check());
// if (!Auth::guard($guard)->check()) {
// return redirect('/');
// }
public function handle($request, Closure $next){
config(['auth.guards.api.provider' => 'clients']);
return $next($request);
}
}

View File

@ -17,7 +17,7 @@ class Localization
public function handle(Request $request, Closure $next)
{
// Check header request and determine localizaton
$locale = ($request->hasHeader('X-localization')) ? $request->header('X-localization') : 'en';
$locale = ($request->hasHeader('X-Localization')) ? $request->header('X-Localization') : 'ru';
// set laravel localization
app()->setLocale($locale);

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Session;
use Config;
use App;
class WebLocalization
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$raw_locale = $request->session()->get('locale');
if (in_array($raw_locale, Config::get('app.locales'))) {
$locale = $raw_locale;
}
else $locale = Config::get('app.locale');
$request->session()->put('locale', $locale ?? 'en');
app()->setLocale($locale);
return $next($request);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
class AddClientRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'email' => 'required|email|unique:clients,email',
'password' => 'required|min:6',
'firstname' => 'required|string|max:255',
'lastname' => 'required|string|max:255',
];
}
}

View File

@ -4,7 +4,7 @@
use Illuminate\Foundation\Http\FormRequest;
class AccountRequest extends FormRequest
class BusinessProfileDocRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
@ -13,7 +13,7 @@ class AccountRequest extends FormRequest
*/
public function authorize()
{
return true;
return false;
}
/**

View File

@ -0,0 +1,36 @@
<?php
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
class BusinessProfileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'name' => 'required|string|max:500',
'surname' => 'required|string|max:500',
'patronomic_name' => 'string|nullable|string|max:500',
'date_of_birth' => 'required|date_format:Y-m-d',
'birth_place' => 'required|string|max:500',
'citizenship_id' => 'required',
'registration_address' => 'required|string|max:500'
];
}
}

View File

@ -24,9 +24,10 @@ public function authorize()
public function rules()
{
return [
'firstname' => 'required',
'lastname' => 'required',
'password' => 'min:6'
'firstname' => 'required|string|max:500',
'lastname' => 'required|string|max:500',
'password' => 'min:6',
'old_password' => 'required_with:password'
];
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
class CompanyProfileDocRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'fond_capital' => 'required',
'management_types' => 'required',
'signers' => 'required',
'share_holders' => 'required',
'organizational_form' => 'required',
'is_agent' => 'required'
];
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
class CompanyProfileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'name' => 'required|string|max:500',
'short_name' => 'required|string|max:500',
'registration_number' => 'required|string|max:500',
'registration_date' => 'required|date_format:Y-m-d',
'state_registration_agency' => 'required|string|max:500',
'registration_place' => 'required|string|max:500',
'registration_address' => 'required|string|max:500',
];
}
}

View File

@ -26,7 +26,8 @@ public function rules()
return [
'address' => 'required',
'phone' => 'required',
'email' => 'required',
'email' => 'required|email',
'fax' => 'nullable'
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
class ContractRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'number' => 'required|numeric',
];
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
class DocumentUploadRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'file' => 'required|file|mimes:jpg,pdf,png,zip',
];
}
// protected function prepareForValidation(): void
// {
// $this->merge(json_decode($this->payload, true, 512, JSON_THROW_ON_ERROR));
// }
}

View File

@ -3,6 +3,7 @@
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
use App\Rules\TicketRule;
class MessageRequest extends FormRequest
{
@ -13,7 +14,7 @@ class MessageRequest extends FormRequest
*/
public function authorize()
{
return false;
return true;
}
/**
@ -25,8 +26,7 @@ public function rules()
{
return [
'content' => 'required',
'ticket_id' => 'required',
'is_client' => 'required'
'ticket_id' => ['required', new TicketRule]
];
}
}

View File

@ -1,65 +0,0 @@
<?php
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
class ProfileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
$type = $this->get('account_type');
if ($type == "business") {
$rules = $this->businessRules();
}
else{
$rules = $this->companyRules();
}
return $rules;
}
private function businessRules(){
return [
'name' => 'required',
'surname' => 'required',
'patronomic_name' => 'required',
'date_of_birth' => 'required',
'birth_place' => 'required',
'citizenship_id' => 'required',
'registration_address' => 'required'
];
}
private function companyRules(){
return [
'name' => 'required',
'short_name' => 'required',
'registration_number' => 'required',
'registration_date' => 'required',
'state_registration_agency' => 'required',
'registration_place' => 'required',
'registration_address' => 'required',
'fond_capital' => 'required',
'management_types' => 'required',
'signers' => 'required',
'share_holders' => 'required',
'organizational_form' => 'required',
'is_agent' => 'required'
];
}
}

View File

@ -26,8 +26,8 @@ public function rules()
return [
'email' => 'required|email|unique:clients,email',
'password' => 'required|min:6',
'firstname' => 'required',
'lastname' => 'required',
'firstname' => 'required|string|max:255',
'lastname' => 'required|string|max:255',
'account_type' => 'required|in:company,business',
'country' => 'required|numeric|gt:0',
];

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Requests\API;
use App\Rules\CategoryRule;
use Illuminate\Foundation\Http\FormRequest;
class ResetPassword extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'token' => 'required',
'email' => 'required|email',
'password' => 'required',
'confirm_password' => 'required|same:password'
];
}
}

View File

@ -3,6 +3,7 @@
namespace App\Http\Requests\API;
use Illuminate\Foundation\Http\FormRequest;
use App\Rules\CategoryRule;
class TicketRequest extends FormRequest
{
@ -24,6 +25,7 @@ public function authorize()
public function rules()
{
return [
'category_id' => ['required', new CategoryRule],
'title' => 'required',
'content' => 'required',
];

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class BrokerApplicationRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class BrokerAttachmentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class BrokerDocumentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ContractRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class DepartmentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ResolutionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ResolutionbasisRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'name' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}

27
app/Http/Resources/AccountResource.php Executable file → Normal file
View File

@ -2,9 +2,7 @@
namespace App\Http\Resources;
use App\Models\Business;
use Illuminate\Http\Resources\Json\JsonResource;
use Symfony\Component\HttpKernel\Profiler\Profile;
class AccountResource extends JsonResource
{
@ -17,20 +15,23 @@ class AccountResource extends JsonResource
public function toArray($request)
{
return [
'id' => $this->id,
'bank_account' => $this->bank,
'contacts' => $this->contacts,
'account_type' => $this->type,
'profile' => $this->profile()
'bank_account' => $this->bank ? BankResource::make(json_decode($this->bank)):null,
'contacts' => $this->contacts ? ContactResource::make(json_decode($this->contacts)):null,
'account_type' => $this->type,
'country' => CountryResource::make($this->country),
'profile' => $this->getProfile(),
'legal_number' => $this->legalization_number,
'legal_expires_at' => !is_null($this->expires_at)?$this->expires_at->format('d.m.Y'):null,
'legal_can_apply' => $this->can_apply,
'legal_can_extend' => $this->can_extend,
'legal_app_status' => $this->application_status,
];
}
private function profile() : JsonResource
private function getProfile() : JsonResource
{
if($this->profile){
$type = config('account.'.$this->type.'.resource');
return $type::make($this->profile);
}
return new JsonResource([]);
$type = config('account.'.$this->type.'.resources');
return new $type($this->profile);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ApplicationResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'application_id' => $this->id,
'state' => $this->state,
'accepted_by' => $this->accepted_by,
'accepted_date' => $this->accepted_date,
'approved_by' => $this->approved_by,
'refine_note' => $this->refine_note,
'approved_date' => $this->approved_date,
'questionnaire_path' => $this->questionnaire_path,
'receipt_path' => $this->receipt_path,
'attachments' => AttachmentResource::collection($this->attachments),
'ticket' => TicketResource::make($this->ticket),
];
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ApplicationStatusResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'legal' => [
'number' => $this->legalization_number,
'expires_at' => !is_null($this->expires_at)?$this->expires_at->format('d.m.Y'):null,
'can_apply' => $this->can_apply,
'can_extend' => $this->can_extend,
'app_status' => $this->application_status,
],
'broker' => [
'number' => $this->broker_number,
'expires_at' => !is_null($this->broker_expires_at)?$this->broker_expires_at->format('d.m.Y'):null,
'can_apply' => $this->can_apply_broker,
'can_extend' => $this->can_extend_broker,
'app_status' => $this->application_broker_status,
]
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources;
use Illuminate\Support\Facades\Storage;
class AttachmentResource extends \Illuminate\Http\Resources\Json\JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'attachment_id' => $this->id,
'attachment_name' => $this->document->name ?: $this->name,
'attachment_size' => $this->size,
'attachment_file_type' => $this->type,
'attachment_file_path' => is_null($this->file) ? null:Storage::url($this->file),
'document_name' => $this->document->name,
'document_description' => $this->document->description,
'document_max_size' => $this->document->max_size,
'is_required' => $this->document->is_required,
];
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class BankResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'account_number' => $this->account_number,
'account_date' => $this->account_date,
'currency' => $this->currency,
'iban' => $this->iban,
'bank_name' => $this->bank_name,
'country' => $this->country
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class BrokerApplicationResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'broker_application_id' => $this->id,
'is_local' => $this->is_local ?? true,
'state' => $this->state,
'accepted_by' => $this->accepted_by,
'accepted_date' => $this->accepted_date,
'approved_by' => $this->approved_by,
'refine_note' => $this->refine_note,
'approved_date' => $this->approved_date,
'questionnaire_path' => $this->questionnaire_path,
'receipt_path' => $this->receipt_path,
'broker_attachments' => BrokerAttachmentResource::collection($this->broker_attachments),
'ticket' => TicketResource::make($this->ticket),
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Storage;
class BrokerAttachmentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'attachment_id' => $this->id,
'attachment_name' => $this->broker_document->name ?: $this->name,
'attachment_size' => $this->size,
'attachment_file_type' => $this->type,
'attachment_file_path' => is_null($this->file) ? null:Storage::url($this->file),
'document_name' => $this->broker_document->name,
'document_description' => $this->broker_document->description,
'document_max_size' => $this->broker_document->max_size,
'is_required' => $this->broker_document->is_required,
];
}
}

View File

@ -15,9 +15,13 @@ class BusinessProfileResource extends JsonResource
public function toArray($request)
{
return [
'personal' => $this->personal,
'document' => $this->document,
'job' => $this->job
'name' => $this->name,
'surname' => $this->surname,
'patronomic_name' => $this->patronomic_name,
'date_of_birth' => $this->date_of_birth,
'birth_place' => $this->birth_place,
'citizenship' => CountryResource::make($this->citizenship),
'registration_address' => $this->registration_address,
];
}
}

View File

@ -15,10 +15,8 @@ class CategoryResource extends JsonResource
public function toArray($request)
{
return [
'id' => $this->id,
'name_en' => $this->name_en,
'name_ru' => $this->name_ru,
'name_tm' => $this->name_tm
'id' => $this->id,
'name' => $this->name
];
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ContactResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'address' => $this->address,
'phone' => $this->phone,
'email' => $this->email,
'fax' => $this->fax
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ContractResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'InputNumber' => $this->InputNumber,
'InputDate' => $this->InputDate,
'RegDate' => $this->RegDate,
'Status' => $this->MarkerSpec ? trans('imported.markerspec.'.$this->MarkerSpec) :"",
'Workflow_ID' => $this->Workflow_ID,
'Workflow' => trans('imported.workflow.'.$this->Workflow_ID),
'Remark' => $this->Remark,
'ResolutionBasis' => ResolutionBasesResource::collection($this->resolution_basis),
];
}
}

View File

@ -15,11 +15,13 @@ class MessageResource extends JsonResource
public function toArray($request)
{
return [
'id' => $this->id,
'content' => $this->content,
'ticket_id' => $this->ticket_id,
'is_client' => $this->is_client,
'created_at' => $this->created_at
'id' => $this->id,
'content' => $this->content,
'ticket_id' => $this->ticket_id,
'is_client' => $this->is_client,
'created_at' => $this->created_at,
'admin' => $this->admin->name ?? null,
'client' => $this->client
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class QuestionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'id' => $this->id,
'question_text' => $this->question_text,
'options' => $this->options
];
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ResolutionBasesResource extends JsonResource
{
public function toArray($request){
return [
// 'workflow' => $this->workflow_id,
'department_id' => $this->department_id,
'department' => $this->department->title ?? '',
'status' => $this->resolution->title ?? '',
'note' => $this->resolution->id != 1 ? $this->resolutionbasis:null,
'date' => $this->created_at,
];
}
}

View File

@ -16,10 +16,12 @@ public function toArray($request)
{
return [
'id' => $this->id,
'category_id' => $this->category_id,
'category' => CategoryResource::make($this->category),
'title' => $this->title,
'content' => $this->content,
'status' => $this->status->name
'status' => $this->status->name,
'last_sender' => $this->last_sender,
'created_at' => $this->created_at,
];
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class EmailVerification extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public $name;
public $token;
public function __construct($name, $token)
{
$this->name = $name;
$this->token = $token;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$user['name'] = $this->name;
$user['token'] = $this->token;
return $this->subject('Verify your email')
->view('emails.email-verification', ['user' => $user]);
}
}

View File

@ -1,43 +0,0 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class ResetPassword extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public $name;
public $token;
public function __construct($name, $token)
{
$this->name = $name;
$this->token = $token;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$user['name'] = $this->name;
$user['token'] = $this->token;
return $this->from("milmedova96@gmail.com", "Password reset code")
->subject('Resetting your password')
->view('emails.reset-password', ['user' => $user]);
}
}

View File

@ -3,7 +3,13 @@
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
class Account extends Model
{
@ -18,71 +24,83 @@ class Account extends Model
protected $table = 'accounts';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
protected $guarded = [];
protected $fillable = [
'contacts', 'bank', 'vat', 'country_id', 'legalization_number', 'type',
'contacts',
'bank',
'vat',
'country_id',
'legalization_number',
'type',
'expires_at',
'broker_expires_at',
'broker_number'
];
protected $casts = [
'contacts' => 'array',
'bank' => 'array'
];
// protected $hidden = [];
// protected $dates = [];
protected $dates = ['expires_at', 'broker_expires_at'];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
public function getFillable(){
return $this->fillable;
public function preview(){
return '<a class="btn btn-sm btn-link" href="'. backpack_url('preview/'.$this->id) .'" data-toggle="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
<path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
<path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
</svg>
Preview</a>';
}
public function getContactFillables(){
return [
'address',
'phone',
'email',
'fax'
];
}
public function getBankFillables(){
return [
'account_number',
'account_date',
'currency',
'iban',
'bank_name',
'country'
];
}
// public function export_account(){
// return '<a class="btn btn-sm btn-link" href="'.backpack_url('export-account-admin/'.$this->id) .'" data-toggle="tooltip">
// <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-filetype-docx" viewBox="0 0 16 16">
// <path fill-rule="evenodd" d="M14 4.5V11h-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5Zm-6.839 9.688v-.522a1.54 1.54 0 0 0-.117-.641.861.861 0 0 0-.322-.387.862.862 0 0 0-.469-.129.868.868 0 0 0-.471.13.868.868 0 0 0-.32.386 1.54 1.54 0 0 0-.117.641v.522c0 .256.04.47.117.641a.868.868 0 0 0 .32.387.883.883 0 0 0 .471.126.877.877 0 0 0 .469-.126.861.861 0 0 0 .322-.386 1.55 1.55 0 0 0 .117-.642Zm.803-.516v.513c0 .375-.068.7-.205.973a1.47 1.47 0 0 1-.589.627c-.254.144-.56.216-.917.216a1.86 1.86 0 0 1-.92-.216 1.463 1.463 0 0 1-.589-.627 2.151 2.151 0 0 1-.205-.973v-.513c0-.379.069-.704.205-.975.137-.274.333-.483.59-.627.257-.147.564-.22.92-.22.357 0 .662.073.916.22.256.146.452.356.59.63.136.271.204.595.204.972ZM1 15.925v-3.999h1.459c.406 0 .741.078 1.005.235.264.156.46.382.589.68.13.296.196.655.196 1.074 0 .422-.065.784-.196 1.084-.131.301-.33.53-.595.689-.264.158-.597.237-.999.237H1Zm1.354-3.354H1.79v2.707h.563c.185 0 .346-.028.483-.082a.8.8 0 0 0 .334-.252c.088-.114.153-.254.196-.422a2.3 2.3 0 0 0 .068-.592c0-.3-.04-.552-.118-.753a.89.89 0 0 0-.354-.454c-.158-.102-.361-.152-.61-.152Zm6.756 1.116c0-.248.034-.46.103-.633a.868.868 0 0 1 .301-.398.814.814 0 0 1 .475-.138c.15 0 .283.032.398.097a.7.7 0 0 1 .273.26.85.85 0 0 1 .12.381h.765v-.073a1.33 1.33 0 0 0-.466-.964 1.44 1.44 0 0 0-.49-.272 1.836 1.836 0 0 0-.606-.097c-.355 0-.66.074-.911.223-.25.148-.44.359-.571.633-.131.273-.197.6-.197.978v.498c0 .379.065.704.194.976.13.271.321.48.571.627.25.144.555.216.914.216.293 0 .555-.054.785-.164.23-.11.414-.26.551-.454a1.27 1.27 0 0 0 .226-.674v-.076h-.765a.8.8 0 0 1-.117.364.699.699 0 0 1-.273.248.874.874 0 0 1-.401.088.845.845 0 0 1-.478-.131.834.834 0 0 1-.298-.393 1.7 1.7 0 0 1-.103-.627v-.495Zm5.092-1.76h.894l-1.275 2.006 1.254 1.992h-.908l-.85-1.415h-.035l-.852 1.415h-.862l1.24-2.015-1.228-1.984h.932l.832 1.439h.035l.823-1.439Z"/>
// </svg>
// Export</a>';
// }
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function profile()
public function profile():MorphTo
{
return $this->morphTo();
}
public function country(){
public function country():BelongsTo
{
return $this->belongsTo(Country::class, 'country_id');
}
public function account(){
public function clients():HasMany
{
return $this->hasMany(Client::class);
}
public function application(){
return $this->hasOne(Application::class);
public function applications():HasMany
{
return $this->hasMany(Application::class);
}
public function clients(){
return $this->hasMany(Client::class);
public function last_application(){
return $this->applications()->latest()->first();
}
public function broker_applications():HasMany
{
return $this->hasMany(BrokerApplication::class);
}
public function last_broker_application(){
return $this->broker_applications()->latest()->first();
}
/*
@ -96,6 +114,61 @@ public function clients(){
| ACCESSORS
|--------------------------------------------------------------------------
*/
public function getTypeAndNameAttribute(){
return trans('app.account.filter.'.$this->type).' '.$this->profile->full_name;
}
public function getAccountTypeAttribute(){
return trans('app.account.filter.'.$this->type);
}
public function getCanApplyAttribute(){
return is_null($this->last_application());
}
public function getCanExtendAttribute()
{
$month = Config::get('settings.legalization_extend') ?? 1;
if($application = $this->last_application()){
return $application->state == 'approved' && $this->expires_at->lte(Carbon::now()->subMonths($month));
}
return !empty($this->legalization_number) && !empty( $this->expires_at) && $this->expires_at->gte(Carbon::now()->subMonths($month));
}
public function getApplicationStatusAttribute(){
$application = $this->last_application();
return $application->state ?? null;
}
public function getCountryNameAttribute(){
return $this->country->name;
}
public function getCanApplyBrokerAttribute(){
return is_null($this->last_broker_application());
}
public function getCanExtendBrokerAttribute()
{
$month = Config::get('settings.legalization_extend') ?? 1;
if($broker_application = $this->last_broker_application()){
return $broker_application->state == 'approved' && $this->broker_expires_at->lte(Carbon::now()->subMonths($month));
}
return !empty($this->broker_number) && !empty($this->broker_expires_at) && $this->broker_expires_at->gte(Carbon::now()->subMonths($month));
}
public function getApplicationBrokerStatusAttribute(){
$broker_application = $this->last_broker_application();
return $broker_application->state ?? null;
}
/*
|--------------------------------------------------------------------------

View File

@ -18,7 +18,7 @@ class Answer extends Model
protected $table = 'answers';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'question_id', 'question_text', 'answer_text'
];

View File

@ -4,6 +4,7 @@
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
class Application extends Model
{
@ -18,18 +19,26 @@ class Application extends Model
protected $table = 'applications';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'account_id', 'status'
'account_id', 'status','state','accepted_by','approved_by'
];
// protected $hidden = [];
// protected $dates = [];
protected $dates = ['accepted_date','approved_date','created_at','updated_at'];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
public function preview(){
return '<a class="btn btn-sm btn-link" href="'. backpack_url('preview-application/'.$this->id) .'" data-toggle="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
<path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
<path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
</svg>
' . trans('app.last_updates.preview') . '</a>';
}
/*
|--------------------------------------------------------------------------
@ -41,9 +50,18 @@ public function account(){
}
public function attachments(){
return $this->hasMany(Attachment::class);
return $this->hasMany(Attachment::class)
->leftJoin('documents','attachments.document_id','=','documents.id')
->select('attachments.*','order')
->orderBy('documents.order');
}
public function ticket():HasOne{
return $this->hasOne(Ticket::class);
}
/*
|--------------------------------------------------------------------------
| SCOPES

View File

@ -18,7 +18,7 @@ class Attachment extends Model
protected $table = 'attachments';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'name', 'size', 'type', 'file', 'document_id', 'application_id'
];

View File

@ -0,0 +1,80 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
class BrokerApplication extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'broker_applications';
// protected $primaryKey = 'id';
// public $timestamps = false;
// protected $guarded = ['id'];
protected $fillable = [
'account_id', 'status','state','accepted_by','approved_by', 'ticket_id', 'is_local'
];
// protected $hidden = [];
protected $dates = ['accepted_date','approved_date','created_at','updated_at'];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
public function preview(){
return '<a class="btn btn-sm btn-link" href="'. backpack_url('preview-broker-application/'.$this->id) .'" data-toggle="tooltip">
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
<path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
<path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
</svg>
' . trans('app.last_updates.preview') . '</a>';
}
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function account(){
return $this->belongsTo(Account::class, 'account_id');
}
public function broker_attachments(){
return $this->hasMany(BrokerAttachment::class)
->leftJoin('broker_documents','broker_attachments.broker_document_id','=','broker_documents.id')
->select('broker_attachments.*','order')
->orderBy('broker_documents.order');
}
public function ticket():HasOne{
return $this->hasOne(Ticket::class);
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

View File

@ -0,0 +1,82 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
class BrokerAttachment extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'broker_attachments';
// protected $primaryKey = 'id';
// public $timestamps = false;
// protected $guarded = ['id'];
protected $fillable = [
'name', 'size', 'type', 'file', 'broker_document_id', 'broker_application_id'
];
// protected $hidden = [];
// protected $dates = [];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function broker_application(){
return $this->belongsTo(BrokerApplication::class, 'broker_application_id');
}
public function broker_document(){
return $this->belongsTo(BrokerDocument::class, 'broker_document_id');
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
public function setFileAttribute($value)
{
$attribute_name = 'file';
$disk = 'public';
$destination_path = 'uploads/broker_attachments';
$this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path);
// return $this->attributes[{$attribute_name}]; // uncomment if this is a translatable field
}
public static function boot()
{
parent::boot();
static::deleting(function($obj) {
\Storage::disk('public')->delete($obj->file);
});
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class BrokerDocument extends Model
{
use CrudTrait;
use HasTranslations;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'broker_documents';
// protected $primaryKey = 'id';
// public $timestamps = false;
// protected $guarded = ['id'];
protected $fillable = [
'name',
'description',
'max_size',
'business',
'company',
'all_country',
'order',
'is_required'
];
// protected $hidden = [];
// protected $dates = [];
protected $translatable = ['name', 'description'];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function broker_attachments(): BelongsToMany{
return $this->belongsToMany(BrokerAttachment::class);
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

View File

@ -18,17 +18,23 @@ class Business extends Model
protected $table = 'businesses';
// protected $primaryKey = 'id';
// public $timestamps = false;Akargider#2323!
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'personal', 'document', 'job'
'name' ,
'surname',
'patronomic_name',
'date_of_birth',
'birth_place',
'citizenship_id',
'registration_address',
];
// protected $hidden = [];
// protected $dates = [];
protected $casts = [
'personal' => 'array',
'document' => 'array',
'job' => 'array',
];
// protected $casts = [
// 'personal' => 'array',
// 'document' => 'array',
// 'job' => 'array',
// ];
/*
|--------------------------------------------------------------------------
@ -49,6 +55,10 @@ public function account()
return $this->morphOne(Account::class, 'profile');
}
public function citizenship(){
return $this->belongsTo(Country::class,'citizenship_id');
}
/*
|--------------------------------------------------------------------------
| SCOPES
@ -60,7 +70,9 @@ public function account()
| ACCESSORS
|--------------------------------------------------------------------------
*/
public function getFullNameAttribute(){
return $this->name.' '.$this->surname;
}
/*
|--------------------------------------------------------------------------
| MUTATORS

View File

@ -4,10 +4,12 @@
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
class Category extends Model
{
use CrudTrait;
use HasTranslations;
/*
|--------------------------------------------------------------------------
@ -18,12 +20,15 @@ class Category extends Model
protected $table = 'categories';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'name_en', 'name_tm', 'name_ru'
'name'
];
// protected $hidden = [];
// protected $dates = [];
protected $translatable = [
'name'
];
/*
|--------------------------------------------------------------------------

View File

@ -23,7 +23,7 @@ class Client extends Authenticatable
protected $table = 'clients';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'firstname', 'lastname', 'email', 'password', 'is_verified','verification_token', 'is_suspended', 'account_id'
];

View File

@ -18,7 +18,7 @@ class Company extends Model
protected $table = 'companies';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'name',
'short_name',
@ -73,6 +73,9 @@ public function account()
|--------------------------------------------------------------------------
*/
public function getFullNameAttribute(){
return $this->name;
}
/*
|--------------------------------------------------------------------------
| MUTATORS

70
app/Models/Contract.php Normal file
View File

@ -0,0 +1,70 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Contract extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'contracts';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
protected $fillable = [
'foreign_ID',
'InputNumber',
'InputDate',
'RegDate',
'MarkerSpec',
'Workflow_ID',
'Note',
'Remark',
];
// protected $hidden = [];
// protected $dates = [];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function resolution_basis():HasMany
{
return $this->hasMany(Resolutionbasis::class, 'contract_id', 'foreign_ID');
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

View File

@ -5,6 +5,8 @@
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Country extends Model
{
@ -20,7 +22,7 @@ class Country extends Model
protected $table = 'countries';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'name', 'code'
];
@ -39,10 +41,18 @@ class Country extends Model
| RELATIONS
|--------------------------------------------------------------------------
*/
public function accounts(){
public function accounts() : HasMany{
return $this->hasMany(Account::class);
}
public function document_groups():BelongsToMany{
return $this->belongsToMany(Documentgroup::class,'documentgroup_countries');
}
public function documents():BelongsToMany{
return $this->belongsToMany(Document::class,'document_countries');
}
/*
|--------------------------------------------------------------------------
| SCOPES

65
app/Models/Department.php Normal file
View File

@ -0,0 +1,65 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
use Illuminate\Database\Eloquent\Model;
class Department extends Model
{
use CrudTrait;
use HasTranslations;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'departments';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
protected $fillable = [
'title'
];
// protected $hidden = [];
// protected $dates = [];
protected $translatable = [
'title'
];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function resolutionbasis(){
return $this->hasMany(Resolutionbasis::class);
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

View File

@ -5,6 +5,7 @@
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Document extends Model
@ -21,11 +22,16 @@ class Document extends Model
protected $table = 'documents';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'name',
'description',
'max_size'
'max_size',
'business',
'company',
'all_country',
'order',
'is_required'
];
// protected $hidden = [];
// protected $dates = [];
@ -42,8 +48,16 @@ class Document extends Model
| RELATIONS
|--------------------------------------------------------------------------
*/
public function attachments(){
return $this->hasMany(Attachment::class);
public function attachments(): BelongsToMany{
return $this->belongsToMany(Attachment::class);
}
public function groups(): BelongsToMany{
return $this->belongsToMany(Documentgroup::class,'documentgroup_documents');
}
public function countries(): BelongsToMany{
return $this->belongsToMany(Country::class,'document_countries', 'document_id', 'country_id');
}
/*

View File

@ -5,6 +5,8 @@
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Builder;
class Documentgroup extends Model
{
@ -20,7 +22,7 @@ class Documentgroup extends Model
protected $table = 'documentgroups';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'name',
'description',
@ -42,11 +44,26 @@ class Documentgroup extends Model
|--------------------------------------------------------------------------
*/
public function documents():BelongsToMany{
return $this->belongsToMany(Document::class,'documentgroup_documents', 'documentgroup_id', 'document_id');
}
public function countries():BelongsToMany{
return $this->belongsToMany(Country::class,'documentgroup_countries', 'documentgroup_id', 'country_id');
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
public function scopeWithDocs($query,$type,$country){
return $query->where('type',$type)
->whereHas('countries',function(Builder $query) use ($country){
$query->where('countries.id',$country);
})
->with('documents');
}
/*
|--------------------------------------------------------------------------

View File

@ -18,7 +18,7 @@ class DocumentgroupCountry extends Model
protected $table = 'documentgroup_countries';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
// protected $fillable = [];
// protected $hidden = [];
// protected $dates = [];

View File

@ -18,7 +18,7 @@ class DocumentgroupDocument extends Model
protected $table = 'documentgroup_documents';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
// protected $fillable = [];
// protected $hidden = [];
// protected $dates = [];

View File

@ -18,9 +18,9 @@ class Message extends Model
protected $table = 'messages';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'content', 'ticket_id', 'is_client'
'content', 'ticket_id', 'is_client', 'admin_id', 'client_id'
];
// protected $hidden = [];
// protected $dates = [];
@ -40,6 +40,14 @@ public function ticket(){
return $this->belongsTo(Ticket::class, 'ticket_id');
}
public function admin(){
return $this->belongsTo(User::class, 'admin_id');
}
public function client(){
return $this->belongsTo(Client::class, 'client_id');
}
/*
|--------------------------------------------------------------------------
| SCOPES

View File

@ -3,11 +3,14 @@
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
use Illuminate\Database\Eloquent\Model;
class Question extends Model
{
use CrudTrait;
use HasTranslations;
/*
|--------------------------------------------------------------------------
@ -18,13 +21,14 @@ class Question extends Model
protected $table = 'questions';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $guarded = ['id'];
protected $fillable = [
'question_text',
'options'
];
// protected $hidden = [];
// protected $dates = [];
protected $translatable = ['question_text', 'options'];
/*
|--------------------------------------------------------------------------

65
app/Models/Resolution.php Normal file
View File

@ -0,0 +1,65 @@
<?php
namespace App\Models;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
use Illuminate\Database\Eloquent\Model;
class Resolution extends Model
{
use CrudTrait;
use HasTranslations;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'resolutions';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
protected $fillable = [
'title'
];
// protected $hidden = [];
// protected $dates = [];
protected $translatable = [
'title'
];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function resolutionbasis(){
return $this->hasMany(Resolutionbasis::class);
}
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESSORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}

Some files were not shown because too many files have changed in this diff Show More