last corrections for payments
This commit is contained in:
parent
044a6bf253
commit
6db007fc82
53 changed files with 1514 additions and 1177 deletions
|
|
@ -8,6 +8,7 @@ use App\Mail\MailCheckout;
|
|||
use App\Models\PaymentTransaction;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
|
@ -27,17 +28,18 @@ class PayoneController extends Controller
|
|||
$data = \Request::all();
|
||||
// test para
|
||||
|
||||
/* $data = [
|
||||
/* $data = [
|
||||
'key' => '698fb2555f8b2efc74f60b2121421f45',
|
||||
'txaction' => 'paid',
|
||||
'clearingtype' => 'wlt',
|
||||
'userid' => '158006846',
|
||||
'txid' => '320267294',
|
||||
'price' => '59.00',
|
||||
'param' => '18', //$this->shopping_order->id,
|
||||
'reference' => '15c79ba77992e2',
|
||||
'userid' => '158723953',
|
||||
'txid' => '321623031',
|
||||
'price' => '89.00',
|
||||
'param' => '1', //$this->shopping_order->id,
|
||||
'reference' => '15c83aee2766c3',
|
||||
];
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
if(!isset($data['key']) || !isset($data['param']) || !isset($data['userid']) || !isset($data['txid']) || !isset($data['reference']) || !isset($data['price'])){
|
||||
\Log::channel('payone')->error('PaymentStatus: parameter incomplete: '.json_encode($data));
|
||||
|
|
@ -100,7 +102,7 @@ class PayoneController extends Controller
|
|||
'status' => 'PAYONE',
|
||||
'key' => $data['key'],
|
||||
'txaction' => $data['txaction'],
|
||||
'transmitted_data' => $data,
|
||||
'transmitted_data' => Util::utf8ize($data),
|
||||
]);
|
||||
|
||||
$shopping_order->txaction = $data['txaction'];
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use Carbon\Carbon;
|
|||
use Config;
|
||||
use Request;
|
||||
use Input;
|
||||
use Util;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
|
@ -55,13 +56,32 @@ class HomeController extends Controller
|
|||
|
||||
$response = "";
|
||||
if($data == "data_protection"){
|
||||
$response = view('legal.data_protect_de')->render();
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
$response = view('legal.data_protect_de', $data)->render();
|
||||
}
|
||||
if($data == "imprint"){
|
||||
$response = view('legal.imprint_de')->render();
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
$response = view('legal.imprint_de', $data)->render();
|
||||
}
|
||||
if($data == "shop_term_of_use"){
|
||||
$response = view('legal.shop_term_of_use_de')->render();
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
$response = view('legal.shop_term_of_use_de', $data)->render();
|
||||
}
|
||||
if($data == "agb"){
|
||||
$data = [
|
||||
'modal' => true,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
$response = view('legal.agb_de', $data)->render();
|
||||
}
|
||||
if(Request::ajax()) {
|
||||
return response()->json(['response' => $response, 'target'=>$target]);
|
||||
|
|
@ -114,13 +134,31 @@ class HomeController extends Controller
|
|||
|
||||
public function legalDataProtected()
|
||||
{
|
||||
return view('legal.data_protected');
|
||||
$data = [
|
||||
'modal' => false,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
return view('legal.data_protected', $data);
|
||||
}
|
||||
|
||||
public function legalAGB()
|
||||
{
|
||||
$data = [
|
||||
'modal' => false,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
return view('legal.agb', $data);
|
||||
}
|
||||
|
||||
public function legalImprint()
|
||||
{
|
||||
return view('legal.imprint');
|
||||
$data = [
|
||||
'modal' => false,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
];
|
||||
return view('legal.imprint', $data);
|
||||
}
|
||||
|
||||
public function verify($confirmation_code){
|
||||
if( ! $confirmation_code)
|
||||
{
|
||||
|
|
@ -136,12 +174,11 @@ class HomeController extends Controller
|
|||
return redirect('/home');
|
||||
|
||||
}
|
||||
|
||||
$user->confirmed = 1;
|
||||
$user->confirmation_date = now();
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
// $user->confirmation_code = null;
|
||||
// $user->confirmation_code_to = null;
|
||||
// $user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
|
||||
//Login!
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class TranslationController extends Controller
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->directory_separator = DIRECTORY_SEPARATOR;
|
||||
$this->languagesPath = App::langPath();
|
||||
|
||||
|
|
@ -61,6 +62,7 @@ class TranslationController extends Controller
|
|||
public function update($language)
|
||||
{
|
||||
|
||||
|
||||
$path = $this->resourcePath($this->languagesPath);
|
||||
$file = $path.$language.".json";
|
||||
$data = Input::all();
|
||||
|
|
|
|||
|
|
@ -55,12 +55,12 @@ class TranslationFileController extends Controller
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->directory_separator = DIRECTORY_SEPARATOR;
|
||||
$this->translator = App::make('translator');
|
||||
$this->loader = Lang::getLoader();
|
||||
$this->languagesPath = App::langPath();
|
||||
$this->directory_separator = DIRECTORY_SEPARATOR;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -271,8 +271,14 @@ class UserShopController extends Controller
|
|||
|
||||
if(Input::get('shop_submit') == 'check'){
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|',
|
||||
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if(in_array($value, config('profanity.full_word_check'))){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
|
@ -286,8 +292,14 @@ class UserShopController extends Controller
|
|||
if(Input::get('shop_submit') == 'action') {
|
||||
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|',
|
||||
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if(in_array($value, config('profanity.full_word_check'))){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
|
@ -334,6 +346,8 @@ class UserShopController extends Controller
|
|||
|
||||
$kas = new KasController();
|
||||
$domain = 'mivita.care';
|
||||
|
||||
|
||||
//check if exisist
|
||||
$subdomains = $kas->action('get_subdomains');
|
||||
foreach ($subdomains as $subdomain){
|
||||
|
|
@ -366,8 +380,15 @@ class UserShopController extends Controller
|
|||
public function checkUserShopName(){
|
||||
|
||||
$rules = array(
|
||||
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|',
|
||||
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
if(in_array($value, config('profanity.full_word_check'))){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
|
|
|||
|
|
@ -67,10 +67,11 @@ class ContactController extends Controller
|
|||
$contact['subject'] = Input::get('subject');
|
||||
$contact['message'] = Input::get('message');
|
||||
|
||||
$checkout_mail = config('app.checkout_mail');
|
||||
if($user_shop){
|
||||
Mail::to($contact['email'])->bcc([$user_shop->user->email, 'k.adametz@kagado.de'])->send(new MailContact($contact));
|
||||
Mail::to($contact['email'])->bcc([$user_shop->user->email, $checkout_mail])->send(new MailContact($contact));
|
||||
}else{
|
||||
Mail::to($contact['email'])->bcc('k.adametz@kagado.de')->send(new MailContact($contact));
|
||||
Mail::to($contact['email'])->bcc($checkout_mail)->send(new MailContact($contact));
|
||||
}
|
||||
|
||||
$data = [
|
||||
|
|
|
|||
|
|
@ -90,6 +90,10 @@ class WizardController extends Controller
|
|||
|
||||
if($user->isPasswort()){
|
||||
$user->wizard = 2;
|
||||
//has Passwort -> delete Code!
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
return redirect(route('wizard', [2]));
|
||||
}
|
||||
|
|
@ -108,6 +112,10 @@ class WizardController extends Controller
|
|||
'password' => Hash::make(Input::get('password'))
|
||||
])->save();
|
||||
$user->wizard = 2;
|
||||
//has Passwort -> delete Code!
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
return redirect(route('wizard', [2]));
|
||||
|
||||
|
|
|
|||
|
|
@ -14,38 +14,32 @@ class MailActivateUser extends Mailable
|
|||
protected $token;
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct($token, User $user)
|
||||
{
|
||||
|
||||
$this->token = $token;
|
||||
$this->user = $user;
|
||||
$this->subject = __('Change E-Mail');
|
||||
|
||||
$this->subject = __('email.change_e_mail');
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
$salutation = __('email.salutation').",";
|
||||
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('Dear Sir')." ".$this->user->account->last_name.",";
|
||||
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->user->account->last_name.",";
|
||||
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
|
||||
}
|
||||
}
|
||||
return $this->view('emails.auth')->with([
|
||||
'url' => route('user_update_email_confirm', $this->token),
|
||||
'salutation' => $salutation,
|
||||
'button' => __('Change E-Mail'),
|
||||
'copy1line' => __('Dear Customer you will receive this e-mail because we have received a request to change your E-Mail Address for your account.'),
|
||||
'copy2line' => __('Or copy this link into the address bar of your browser.'),
|
||||
'copy3line' => __('For further questions we are happy to help you.'),
|
||||
'greetings' => __('Best regards'),
|
||||
'sender' => __('your mivita.care team'),
|
||||
|
||||
'button' => __('email.change_e_mail'),
|
||||
'copy1line' => __('email.active_copy1line'),
|
||||
'copy2line' => __('email.copy2line'),
|
||||
'copy3line' => __('email.copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,42 +26,41 @@ class MailCheckout extends Mailable
|
|||
$this->shopping_order = $shopping_order;
|
||||
$this->shopping_payment = $shopping_payment;
|
||||
|
||||
$this->subject = __('Deine Bestellung auf mivita.care');
|
||||
$this->subject = __('email.checkout_subject')." mivita.care";
|
||||
if($shopping_order->user_shop){
|
||||
$this->subject = __('Deine Bestellung auf '.$shopping_order->user_shop->slug.'.mivita.care');
|
||||
$this->subject = __('email.checkout_subject')." ".$shopping_order->user_shop->slug.'.mivita.care';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
$salutation = __('email.salutation').",";
|
||||
|
||||
if($this->shopping_order->shopping_user){
|
||||
$salutation = __('Hallo')." ".$this->shopping_order->shopping_user->billing_firstname." ".$this->shopping_order->shopping_user->billing_lastname.",";
|
||||
$salutation = __('email.hello')." ".$this->shopping_order->shopping_user->billing_firstname.",";
|
||||
//make Adresse
|
||||
|
||||
}
|
||||
if($this->txaction == 'paid'){
|
||||
return $this->view('emails.checkout')->with([
|
||||
'salutation' => $salutation,
|
||||
'copy1line' => __('vielen Dank für Deine Bestellung bei mivita.care.<br><br>Nachfolgend haben wir zur Kontrolle Deine Bestellung noch einmal aufgelistet.'),
|
||||
'copy1line' => __('email.checkout_copy1line'),
|
||||
'shopping_order' => $this->shopping_order,
|
||||
'shopping_payment' => $this->shopping_payment,
|
||||
'copy3line' => __('Bei Fragen sind wir jederzeit für Dich da.'),
|
||||
'greetings' => __('Best regards'),
|
||||
'sender' => __('your mivita.care team'),
|
||||
'copy3line' => __('email.checkout_copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
]);
|
||||
}else{
|
||||
return $this->view('emails.checkout_status')->with([
|
||||
'salutation' => $salutation,
|
||||
'copy1line' => "Status zu Deiner Bestellung bei mivita.care",
|
||||
'copy1line' => __('email.status_copy1line'),
|
||||
'txactionn' => $this->txaction,
|
||||
'shopping_order' => $this->shopping_order,
|
||||
'shopping_payment' => $this->shopping_payment,
|
||||
'copy3line' => __('Bei Fragen sind wir jederzeit für Dich da.'),
|
||||
'greetings' => __('Best regards'),
|
||||
'sender' => __('your mivita.care team'),
|
||||
'copy3line' => __('email.checkout_copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,30 +21,27 @@ class MailContact extends Mailable
|
|||
{
|
||||
$this->data = $data;
|
||||
$this->user_shop = Util::getUserShop();
|
||||
$this->subject = __('Anfrage von mivita.care');
|
||||
$this->subject = __('email.request_from').' mivita.care';
|
||||
if($this->user_shop){
|
||||
$this->subject = __('Anfrage von '.$this->user_shop->slug.'.mivita.care');
|
||||
$this->subject = __('email.request_from')." ".$this->user_shop->slug.'.mivita.care';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
$salutation = __('email.salutation');
|
||||
|
||||
$copy1line = __('Deine Anfrage von mivita.care');
|
||||
$copy1line = __('email.your_request_from')." mivita.care";
|
||||
if($this->user_shop){
|
||||
$copy1line = __('Deine Anfrage von '.$this->user_shop->slug.'.mivita.care');
|
||||
|
||||
$copy1line = __('email.your_request_from')." ".$this->user_shop->slug.'.mivita.care';
|
||||
}
|
||||
|
||||
return $this->view('emails.contact')->with([
|
||||
'salutation' => $salutation,
|
||||
'copy1line' => $copy1line,
|
||||
'data' => $this->data,
|
||||
'copy3line' => __('For further questions we are happy to help you.'),
|
||||
'greetings' => __('Best regards'),
|
||||
'sender' => __('your mivita.care team'),
|
||||
'copy3line' => __('email.copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,31 +20,31 @@ class MailResetPassword extends Mailable
|
|||
|
||||
$this->token = $token;
|
||||
$this->user = $user;
|
||||
$this->subject = __('Reset Password');
|
||||
$this->subject = __('email.reset_passwort');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
$salutation = __('email.salutation').",";
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('Dear Sir')." ".$this->user->account->last_name.",";
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->user->account->last_name.",";
|
||||
}
|
||||
}
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
|
||||
}else{
|
||||
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
|
||||
}
|
||||
}
|
||||
return $this->view('emails.auth')->with([
|
||||
'url' => route('password.reset', $this->token),
|
||||
'salutation' => $salutation,
|
||||
'button' => __('Reset Password'),
|
||||
'copy1line' => __('Dear Customer you will receive this e-mail because we have received a request to reset the password for your account.'),
|
||||
'copy2line' => __('Or copy this link into the address bar of your browser.'),
|
||||
'copy3line' => __('For further questions we are happy to help you.'),
|
||||
'greetings' => __('Best regards'),
|
||||
'sender' => __('your mivita.care team'),
|
||||
'button' => __('email.reset_passwort'),
|
||||
'copy1line' => __('email.reset_pass_copy1line'),
|
||||
'copy2line' => __('email.copy2line'),
|
||||
'copy3line' => __('email.copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,36 +17,33 @@ class MailVerifyAccount extends Mailable
|
|||
|
||||
public function __construct($confirmation_code, User $user)
|
||||
{
|
||||
|
||||
$this->confirmation_code = $confirmation_code;
|
||||
$this->user = $user;
|
||||
$this->subject = __('Verify Your Email Address');
|
||||
|
||||
$this->subject = __('email.email_verify');
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('Dear Sir')." ".$this->user->account->last_name.",";
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->user->account->last_name.",";
|
||||
}
|
||||
}
|
||||
$salutation = __('email.salutation').",";
|
||||
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
|
||||
}else{
|
||||
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
|
||||
}
|
||||
}
|
||||
return $this->view('emails.auth')->with([
|
||||
'url' => route('register_verify', $this->confirmation_code),
|
||||
'salutation' => $salutation,
|
||||
'button' => __('Verify Your Email Address'),
|
||||
'copy1line' => __('Thank you for creating an account with the JACKON Infomanager. Please follow the link below to confirm your email address.'),
|
||||
'copy2line' => __('Or copy this link into the address bar of your browser.'),
|
||||
'copy3line' => __('For further questions we are happy to help you.'),
|
||||
'greetings' => __('Best regards'),
|
||||
'sender' => __('your mivita.care team'),
|
||||
'button' => __('email.email_verify'),
|
||||
'copy1line' => __('email.email_verify_copy1line'),
|
||||
'copy2line' => __('email.active_copy2line'),
|
||||
'copy3line' => __('email.active_copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -17,36 +17,31 @@ class MailVerifyContact extends Mailable
|
|||
|
||||
public function __construct($confirmation_code, User $user)
|
||||
{
|
||||
|
||||
$this->confirmation_code = $confirmation_code;
|
||||
$this->user = $user;
|
||||
$this->subject = __('Verify your Data and E-Mail Address');
|
||||
|
||||
$this->subject = __('email.verify_e_mail');
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
$salutation = __('email.salutation').",";
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('Dear Sir')." ".$this->user->account->last_name.",";
|
||||
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->user->account->last_name.",";
|
||||
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
|
||||
}
|
||||
}
|
||||
|
||||
return $this->view('emails.auth')->with([
|
||||
'url' => route('register_verify', $this->confirmation_code),
|
||||
'salutation' => $salutation,
|
||||
'button' => __('Verify your Data and E-Mail Address'),
|
||||
'copy1line' => __('We have data about you stored in our JACKON Infomanager. Please follow the link below to verify your email address.You can also change or delete your data.'),
|
||||
'copy2line' => __('Or copy this link into the address bar of your browser.'),
|
||||
'copy3line' => __('For further questions we are happy to help you.'),
|
||||
'greetings' => __('Best regards'),
|
||||
'sender' => __('your mivita.care team'),
|
||||
|
||||
|
||||
'button' => __('email.verify_e_mail'),
|
||||
'copy1line' => __('email.verify_copy1line'),
|
||||
'copy2line' => __('email.copy2line'),
|
||||
'copy3line' => __('email.copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
73
app/Requests/TranslationRequest.php
Normal file
73
app/Requests/TranslationRequest.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Requests;
|
||||
|
||||
use App\Http\Controllers\TranslationFileController;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* Class TranslationRequest
|
||||
*
|
||||
* @package GeniusTS\TranslationManager
|
||||
*/
|
||||
class TranslationRequest 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
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$manager = new TranslationFileController;
|
||||
$rules = [];
|
||||
$file = $this->route()->parameter('file');
|
||||
|
||||
$translation = $manager->translations($file);
|
||||
|
||||
foreach ($translation as $key => $value)
|
||||
{
|
||||
$this->generateRulesOfKey($key, $value, null, $rules);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate rule form an element
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param string $prefix
|
||||
* @param array $rules
|
||||
*/
|
||||
protected function generateRulesOfKey($key, $value, $prefix, &$rules)
|
||||
{
|
||||
$rule = $prefix ? "{$prefix}{$key}" : $key;
|
||||
|
||||
if (is_array($value))
|
||||
{
|
||||
//$rules[$rule] = 'required|array';
|
||||
|
||||
foreach ($value as $subKey => $subValue)
|
||||
{
|
||||
$this->generateRulesOfKey($subKey, $subValue, "{$rule}.", $rules);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//$rules[$rule] = "required|string";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,19 @@ class Util
|
|||
}
|
||||
return 'd.m.Y - H:i';
|
||||
}
|
||||
|
||||
public static function utf8ize( $mixed ) {
|
||||
if (is_array($mixed)) {
|
||||
foreach ($mixed as $key => $value) {
|
||||
$mixed[$key] = self::utf8ize($value);
|
||||
}
|
||||
} elseif (is_string($mixed)) {
|
||||
return mb_convert_encoding($mixed, "UTF-8", "UTF-8");
|
||||
}
|
||||
return $mixed;
|
||||
}
|
||||
|
||||
|
||||
public static function getPostRoute(){
|
||||
return self::$postRoute;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue