01 2020
This commit is contained in:
parent
f117f79bb9
commit
3711fcc8d0
101 changed files with 4027 additions and 918 deletions
144
app/Repositories/ContractPDFRepository.php
Normal file
144
app/Repositories/ContractPDFRepository.php
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Libraries\ContractPDF;
|
||||
use App\Models\File;
|
||||
use App\User;
|
||||
use Request;
|
||||
use Response;
|
||||
use Storage;
|
||||
use Util;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ContractPDFRepository extends BaseRepository {
|
||||
|
||||
|
||||
|
||||
|
||||
protected $disk;
|
||||
protected $dir;
|
||||
protected $user_id;
|
||||
protected $identifier;
|
||||
|
||||
public function __construct(User $model){
|
||||
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function _set($name, $value){
|
||||
$this->{$name} = $value;
|
||||
}
|
||||
|
||||
public function createContractPDF() {
|
||||
|
||||
$pdf = new ContractPDF();
|
||||
|
||||
$pdf->AddPage('P', array(210, 297));
|
||||
$pdf->SetFont('Helvetica', '', 11);
|
||||
$pdf->SetDrawColor(160, 160, 160);
|
||||
|
||||
$x1 = 16.5;
|
||||
$x2 = 109;
|
||||
$y = 70;
|
||||
$nl = 17.5;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->model->account->m_account);
|
||||
$pdf->SetXY($x2, $y);
|
||||
$pdf->Write(0, now()->format("d.m.Y"));
|
||||
|
||||
$y += $nl;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->model->account->company);
|
||||
$pdf->SetXY($x2, $y);
|
||||
$pre = $this->model->account->pre_phone_id != "" ? $this->model->account->pre_phone->phone." " : "";
|
||||
$pdf->Write(0, $pre.$this->model->account->phone);
|
||||
|
||||
$y += $nl;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->model->account->m_first_name);
|
||||
$pdf->SetXY($x2, $y);
|
||||
$pre = $this->model->account->pre_mobil_id != "" ? $this->model->account->pre_mobil->phone." " : "";
|
||||
$pdf->Write(0, $pre.$this->model->account->mobil);
|
||||
|
||||
$y += $nl;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->model->account->m_last_name);
|
||||
$pdf->SetXY($x2, $y);
|
||||
$pdf->Write(0, $this->model->email);
|
||||
|
||||
$y += $nl;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->model->account->address);
|
||||
$pdf->SetXY($x2, $y);
|
||||
$pdf->Write(0, $this->model->account->birthday);
|
||||
|
||||
$y += $nl;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->model->account->zipcode." ".$this->model->account->city);
|
||||
|
||||
$y += $nl;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pre = $this->model->account->country_id ? $this->model->account->country->de." " : "";
|
||||
$pdf->Write(0, $pre);
|
||||
|
||||
if($this->model->m_sponsor){
|
||||
|
||||
$y += 48;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->model->user_sponsor->account->company);
|
||||
$pdf->SetXY($x2, $y);
|
||||
$pdf->Write(0, $this->model->user_sponsor->account->m_account);
|
||||
|
||||
$y += $nl;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->model->user_sponsor->account->m_first_name." ".$this->model->user_sponsor->account->m_last_name);
|
||||
|
||||
$website = $this->model->user_sponsor->shop()->count() ? $this->model->user_sponsor->shop->getSubdomain() : "www.mivita.care";
|
||||
|
||||
}else{
|
||||
$website = "www.mivita.care";
|
||||
}
|
||||
|
||||
$pdf->AddPage('P', array(210, 297));
|
||||
$pdf->SetFont('Helvetica', '', 10);
|
||||
$pdf->SetDrawColor(160, 160, 160);
|
||||
$pdf->SetXY(52, 56);
|
||||
$pdf->Write(0, $website);
|
||||
|
||||
|
||||
$pdf->SetXY($x1, 65);
|
||||
$pdf->Write(0, $this->model->account->m_first_name." ".$this->model->account->m_last_name);
|
||||
$pdf->SetXY($x2, 65);
|
||||
$pdf->Write(0, $this->model->account->m_account);
|
||||
|
||||
$pdf->AddPage('P', array(210, 297));
|
||||
|
||||
|
||||
if(!Storage::disk($this->disk)->exists( $this->dir )){
|
||||
Storage::disk($this->disk)->makeDirectory($this->dir); //creates directory
|
||||
}
|
||||
$filename = "MIVITA_Beratervertrag.pdf";
|
||||
Storage::disk($this->disk)->put($this->dir.$filename, $pdf->Output('S'));
|
||||
$size = Storage::disk($this->disk)->size($this->dir.$filename);
|
||||
$mine = Storage::disk($this->disk)->getMimeType($this->dir.$filename);
|
||||
|
||||
File::create([
|
||||
'user_id' => $this->model->id,
|
||||
'identifier' => $this->identifier,
|
||||
'filename' => $filename,
|
||||
'dir' => $this->dir,
|
||||
'original_name' => $filename,
|
||||
'ext' => "pdf",
|
||||
'mine' => $mine,
|
||||
'size' => $size
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
141
app/Repositories/FileRepository.php
Normal file
141
app/Repositories/FileRepository.php
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\File;
|
||||
use Request;
|
||||
use Response;
|
||||
use Storage;
|
||||
use Util;
|
||||
use Validator;
|
||||
|
||||
|
||||
class FileRepository extends BaseRepository {
|
||||
|
||||
|
||||
protected $rules;
|
||||
protected $messages;
|
||||
|
||||
protected $disk;
|
||||
protected $dir;
|
||||
protected $user_id;
|
||||
protected $identifier;
|
||||
|
||||
public function __construct(File $model){
|
||||
|
||||
$this->model = $model;
|
||||
|
||||
$this->rules = [
|
||||
'file' => 'required|mimes:pdf,jpeg,png|max:32768'
|
||||
];
|
||||
$this->messages = [
|
||||
'file.mimes' => 'Datei ist kein PDF Format',
|
||||
'file.required' => 'PDF-Datei wird benötigt'
|
||||
];
|
||||
}
|
||||
|
||||
public function _set($name, $value){
|
||||
$this->{$name} = $value;
|
||||
}
|
||||
|
||||
/* public function load($id){
|
||||
$this->model = $id;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public function uploadFile( $form_data )
|
||||
{
|
||||
|
||||
$validator = Validator::make($form_data, $this->rules, $this->messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Response::json([
|
||||
'error' => true,
|
||||
'message' => $validator->messages()->first(),
|
||||
'code' => 400
|
||||
], 400);
|
||||
}
|
||||
$file = $form_data['file'];
|
||||
|
||||
$originalName = $file->getClientOriginalName();
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
$mine = $file->getClientMimeType();
|
||||
$size = $file->getClientSize();
|
||||
|
||||
|
||||
$originalNameWithoutExt = substr($originalName, 0, strlen($originalName) - strlen($extension) - 1);
|
||||
$filename = Util::sanitize($originalNameWithoutExt, true, false, true);
|
||||
$allowed_filename = uniqid() . '_' . $filename.".".$extension;
|
||||
|
||||
//$dir = $this->model->getInvoiceStorageAttDir();
|
||||
|
||||
if(!Storage::disk($this->disk)->exists( $this->dir )){
|
||||
Storage::disk($this->disk)->makeDirectory($this->dir); //creates directory
|
||||
}
|
||||
Storage::disk($this->disk)->put($this->dir.$allowed_filename, file_get_contents($file->getRealPath()));
|
||||
|
||||
File::create([
|
||||
'user_id' => $this->user_id,
|
||||
'identifier' => $this->identifier,
|
||||
'filename' => $allowed_filename,
|
||||
'dir' => $this->dir,
|
||||
'original_name' => $originalName,
|
||||
'ext' => $extension,
|
||||
'mine' => $mine,
|
||||
'size' => $size
|
||||
]);
|
||||
|
||||
return Response::json([
|
||||
'error' => false,
|
||||
'filename' => $allowed_filename,
|
||||
'filedata' => 'pdf',
|
||||
'redirect' => route('wizard_register'),
|
||||
'code' => 200
|
||||
], 200);
|
||||
}
|
||||
|
||||
/* public function createFile(Request $request)
|
||||
{
|
||||
$locale = \App::getLocale();
|
||||
$data = [
|
||||
'step' => 2,
|
||||
'locale' => $locale,
|
||||
];
|
||||
$rules = array(
|
||||
'network_name' => 'required|max:255',
|
||||
'input_file_now' => 'required|mimes:png,pdf,jpg,jpeg|max:30000'
|
||||
);
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.register_complete', $data)->withErrors($validator);
|
||||
|
||||
} else {
|
||||
$user = \Auth::user();
|
||||
if(!$user->account->network_name){
|
||||
$file = request()->file('input_file_now');
|
||||
//$ext = $file->guessClientExtension();
|
||||
//$file->storeAs('user/' . $user->id .'/verification');
|
||||
$data = $file->store('user/' . $user->id .'/verification');
|
||||
$account = $user->account;
|
||||
$account->network_name = Input::get('network_name');
|
||||
$account->network_verification = basename($data);
|
||||
$account->save();
|
||||
|
||||
$user->role_id = 2; //set as User by default!
|
||||
$user->save();
|
||||
|
||||
|
||||
}
|
||||
|
||||
return redirect('complete_register');
|
||||
//return view('user.register_complete', $data);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ namespace App\Repositories;
|
|||
|
||||
use App\Models\UserAccount;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
|
||||
|
||||
class UserRepository extends BaseRepository {
|
||||
|
|
@ -15,6 +17,7 @@ class UserRepository extends BaseRepository {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
|
||||
|
|
@ -44,7 +47,30 @@ class UserRepository extends BaseRepository {
|
|||
$this->model->save();
|
||||
}
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function create($data){
|
||||
|
||||
$this->model = User::create([
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
|
||||
$account = UserAccount::create([
|
||||
'm_salutation' => $data['salutation'],
|
||||
'm_first_name' => $data['first_name'],
|
||||
'm_last_name' => $data['last_name'],
|
||||
'salutation' => $data['salutation'],
|
||||
'first_name' => $data['first_name'],
|
||||
'last_name' => $data['last_name'],
|
||||
]);
|
||||
|
||||
$this->model->account_id = $account->id;
|
||||
$this->model->save();
|
||||
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function deleteUser(User $user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue