maximaexchen

maximaexchen

Member Since 1 Year Ago

Experience Points 14,400
Experience
Level
Lessons Completed 133
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

22 May
5 months ago
18 May
5 months ago

maximaexchen started a new conversation Add Custom Subscription Plans Limitations Problem

Hi everybody,

I posted a problem last week. But I am still stuck.

https://laracasts.com/discuss/channels/laravel/best-way-to-restict-the-amount-of-records-a-user-with-sepcific-subscription-plan-can-create

I need to have the possibility to check different subscription plans and than react on them in many controllers and views of the application. And each subscription plan has some different limitations creating amount records for different models and so on.

e.g. plan_1 an account can add/edit/view/list max 5 procedures-records and only can have one user and one client plan_2 an account can add/edit/view/list max 20 procedures-records and only can have one user and 20 clients ... plan_10 unlimited

etc.

Background info: the subscription is added to an account, which is created when a user registers. An account has on or many users and clients.

I am still learning all that stuff and I am a bit confused how to handle this kind of programming challenge. For info, unfortunately I cannot use stripe because of the european "General Data Protection Regulation - GDPR". So I have to do subscription and payment stuff on my own.

So what I tried / I thought about

If I have policy, as I understand, it can only return true or false. If I do something like this in my policy;

class ProcedurePolicy
{
    public function max_procedures_items(User $user)
    {
        $account = Account::whereId(Auth::user()->account_id)->firstOrFail();
        $account->clients()->first()->procedures()->count();
        return $account->clients()->first()->procedures()->count() >= 5;
    }
}

So I have to do this for every different user with a different subscription plan, right? Does not feel right.

I thought about accessors and mutators, but this doesen't works "globally" in different controllers and views, right?

like so

class Account extends Model
{
    public $max_procedure_items = null;

    ...

    /**
     * Set max item number.
     *
     * @param  string  $value
     * @return void
     */
    public function setMaxProcedureItemsAttribute($value)
    {
        $this->attributes['max_procedure_items'] = $value;
    }

    /**
     * Get max item number.
     *
     * @param  string  $value
     * @return void
     */
    public function getMaxProcedureItemsAttribute($value)
    {
        return $value;
    }
}

Sessions?

I am lost. I hope this describes my knowlege problem understandable. I am not that good in programming design pattern, but is there one which could fit and usable in the laravel system?

Any hints, enlightenments, links, tutorials would be great. Thanks for reading.

Regards Marcus

09 May
6 months ago

maximaexchen started a new conversation Best Way To Restict The Amount Of Records A User With Sepcific Subscription Plan Can Create

Hi everybody.

I have a subscription system with 4 plans. So plan1 subscribers should only be able to create 4 records of a model and so on...

I have spatie/laravel-permission in use and own subscription logic.

What would be the best way in your opinion. Roles and Permissions? Policy / Gate?

To do it directly in controller sounds not good to me. I am still learning, so any suggestion appreciated.

Thanks in advance. Regards Marcus

27 Apr
6 months ago

maximaexchen left a reply on Class Defined In Component Data Not Available In Different Methods.

Nobody?

do I have to define it like so, to use a class in different methods?

...
data() {
            return {
        errorsone: new Errors(),
        errorstwo: new Errors(),
....

checkPersonalData: function () {
....
    .catch(error => {
                    this.loading = false;
                    console.log("05: " +  this.errors);
                    this.errorsone.record(error.response.data.errors) <- ?
                });
....
finalizeSubscription: function () {
...
    .catch(error => {
                    this.loading = false;
                    console.log("05: " +  this.errors);
                    this.errorstwo.record(error.response.data.errors) <- ?
                });

Or did I explain my problem not specific enough?

Thanks and regards

24 Apr
6 months ago

maximaexchen left a reply on Route Issue

Hi. What does artisan route:list show?

maximaexchen left a reply on Class Defined In Component Data Not Available In Different Methods.

Somehow I cannot edit my whole post. :-(

this.errors.record(error.response.data.errors) // in finalizeSubscription

Throws the error "TypeError: this.errors is undefined"

maximaexchen started a new conversation Class Defined In Component Data Not Available In Different Methods.

Hi. I have follwoing code.

I defined

errors: new Errors() // in data

Like in Jeffreys tutorial.

In the first method "checkPersonalData" called everything is fine.

console.log("02: " + this.errors);  <-- 02: [object Object]

In the second method "finalizeSubscription" ok untill the call of.

this.errors.record(error.response.data.errors)


console.log("05: " + this.errors);  <-- 05: [object Object]

Here the full code.

<script>

    import { Errors, Messages } from '../Classes/PaymentMessages.js';
    import { ScalingSquaresSpinner  } from 'epic-spinners'

    var csrf_token = $('meta[name="csrf-token"]').attr('content');

    export default {
        name: 'paymentform',
        props: ['customerName','customerEmail','customerPhone'],

        data() {
            return {
                errors: new Errors(), //Custom Error Class (from laracast)
                messages: new Messages(),
                step: 1,
                subscriptionPlan: null,
                customer_name: this.customerName,
                customer_email: this.customerEmail,
                customer_phone: this.customerPhone,
                iban: null,
                tan: null,
                personaldatachecked: false,
                loading : false,
                tanReady: false
            }
        },
        components: {
            ScalingSquaresSpinner
        },
        methods: {
            prev() { this.step--; },
            next() { this.step++; },
            submit() { alert('Done.'); },
            checkPersonalData: function () {

                this.loading = true;

                console.log("00: " + this.errors);

                axios.post('/subscription/checkPersonalData', {
                    subscription_plan: this.subscriptionPlan,
                    customer_name: this.customer_name,
                    customer_email: this.customer_email,
                    customer_phone: this.customer_phone,
                    customer_iban: this.iban
                })
                .then(response => {
                    this.loading = false;
                    this.personaldatachecked = true;
                    this.tanReady = true;
                    message => this.messages.record(response.data);
                    console.log("01: " + this.errors);

                })
                .catch(error => {
                    this.loading = false;
                    console.log("02: " + this.errors);
                    this.errors.record(error.response.data.errors)
                });
            },
            finalizeSubscription: function () {

                this.loading = true;
                console.log("03: " + this.errors);

                axios.post('/subscription/finalizeSubscription', {
                    subscription_plan: this.subscriptionPlan,
                    customer_name: this.customer_name,
                    customer_email: this.customer_email,
                    customer_phone: this.customer_phone,
                    customer_iban: this.iban,
                    customer_tan: this.tan
                })
                .then(response => {
                    this.loading = false;
                    this.personaldatachecked = true;
                    this.tanReady = true;
                    message => this.messages.record(response.data);
                    console.log("04: " + this.errors);
                })
                .catch(error => {
                    this.loading = false;
                    console.log("05: " +  this.errors);
                    this.errors.record(error.response.data.errors)
                });
            }
        }
    }
</script>

Anyone a suggestion for me?

Thanks in advance

Regards Marcus

20 Apr
6 months ago

maximaexchen left a reply on Form In Blade With Vue Functionality

Thank you guys very much!

With your suggestions I achieved it with a component now.

maximaexchen left a reply on Form In Blade With Vue Functionality

Ok. I will try to get the things together. Maybe I come back later. ;-)

Thank you both!

maximaexchen left a reply on Form In Blade With Vue Functionality

@extends('master')
@section('content')
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-8">
                <div class="card">
                    <div class="card-header">
                        {{ __('Your plan') }}
                    </div>

                    @foreach ($errors->all() as $error)
                        <p class="alert alert-danger">{{ $error }}</p>
                    @endforeach

                    <form action="subscription/create" method="post" id="payment-form">
                        <div class="card-block">

                            {!! csrf_field() !!}

                            <div v-if="step === 1">
                                <div class="row">
                                    <div class="col-sm-6 col-md-3">
                                        <div class="card">
                                            <div class="card-header">
                                                {{ __('Basic free') }}
                                            </div>
                                            <div class="card-block">
                                                <label name="plan1" class="plan">

                                                    <span class="input-control radio">
                                                        <input v-model="subscription.subscription_plan" name="subscription_plan" class="subscription_plan" value="basic"
                                                               {{ old('subscription_plan') === "basic" ? "checked" : "" }}
                                                               type="radio">
                                                        <span class="check"></span>
                                                    </span>

                                                    <label>Basic</label>

                                                    <span class="price monthPrice" style="">
                                                        <span class="currency">&euro;</span>
                                                        <span class="amount">0,00</span>
                                                    </span>
                                                </label>
                                            </div>
                                        </div>
                                    </div>


                                    <div class="col-sm-6 col-md-3">
                                        <div class="card">
                                            <div class="card-header">
                                                {{ __('DSB Basic') }}
                                            </div>
                                            <div class="card-block">
                                                <label name="dsb_basic" class="plan">

                                                    <span class="input-control radio">
                                                        <input v-model="subscription.subscription_plan" name="subscription_plan" class="subscription_plan" value="dsb_basic"
                                                               {{ old('subscription_plan') === "dsb_basic" ? "checked" : "" }}
                                                               type="radio">
                                                        <span class="check"></span>
                                                    </span>

                                                    <label>DSB Basic</label>

                                                    <span class="price monthPrice" style="">
                                                        <span class="currency">&euro;</span>
                                                        <span class="amount">9,99</span>
                                                    </span>
                                                </label>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-sm-6 col-md-3">
                                        <div class="card">
                                            <div class="card-header">
                                                {{ __('DSB PRo') }}
                                            </div>
                                            <div class="card-block">
                                                <label name="dsb_pro" class="plan">

                                                    <span class="input-control radio">
                                                        <input v-model="subscription.subscription_plan" name="subscription_plan" class="subscription_plan" value="dsb_pro"
                                                               {{ old('subscription_plan') === "dsb_pro" ? "checked" : "" }}
                                                               type="radio">
                                                        <span class="check"></span>
                                                    </span>

                                                    <label>DSB Pro</label>

                                                    <span class="price monthPrice" style="">
                                                        <span class="currency">&euro;</span>
                                                        <span class="amount">24,90</span>
                                                    </span>
                                                </label>
                                            </div>
                                        </div>

                                    </div>

                                    <div class="col-sm-6 col-md-3">
                                        <div class="card">
                                            <div class="card-header">
                                                {{ __('DSB Verein') }}
                                            </div>
                                            <div class="card-block">
                                                <label name="dsb_verein" class="plan">

                                                    <span class="input-control radio">
                                                        <input v-model="subscription.subscription_plan" name="subscription_plan" id="subscription_plan" value="dsb_verein"
                                                               {{ old('subscription_plan') === "dsb_verein" ? "checked" : "" }}
                                                               type="radio">
                                                        <span class="check"></span>
                                                    </span>

                                                    <label>DSB Verein</label>

                                                    <span class="price monthPrice" style="">
                                                        <span class="currency">&euro;</span>
                                                        <span class="amount">5,90</span>
                                                        <span class="month monthPrice"></span>
                                                    </span>
                                                </label>
                                            </div>
                                        </div>
                                        <button @click.prevent="next()">Next</button>

                                    </div>

                                </div>

                            </div>

                            <div v-if="step === 2">
                                <div class="form-group">
                                    <label for="customer_name">{{ __('Name') }}</label>
                                    <input v-model="subscription.customer_name" type="text" class="form-control" id="customer_name" name="customer_name" value="{{ $user->name ?? '' }}">

                                </div>


                                <div class="form-group">
                                    <label for="customer_email">{{ __('Email') }}</label>
                                    <input v-model="subscription.customer_email" type="text" class="form-control" id="customer_email" name="customer_email" value="{{ $user->email ?? '' }}">
                                </div>

                                <div class="form-group">
                                    <label for="customer_iban">{{ __('IBAN') }}</label>
                                    <input v-model="subscription.customer_iban" type="text" class="form-control" id="customer_iban" name="customer_iban" value="">
                                </div>

                                <div class="form-group">
                                    <label for="customer_phone">{{ __('Mobilenumber') }}</label>
                                    <input v-model="subscription.customer_phone" type="text" class="form-control" id="customer_phone" name="customer_phone" value="{{ $user->telephone ?? '' }}">
                                </div>
                                <button @click.prevent="prev()">Previous</button>
                                <button @click.prevent="next()">Next</button>
                            </div>
                            <div v-if="step === 3">
                                TAN
                                <button @click.prevent="prev()">Previous</button>
                                <button @click.prevent="submit()">Save</button>
                            </div>
                        </div>

                        <div class="card-footer">
                            <button type="submit" class="btn btn-primary" ><i class="fa fa-check-circle" aria-hidden="true"></i> {{ __('Submit Payment') }}</button>
                        </div>



                    </form>
                </div>


            </div>
        </div>
    </div>
@endsection


@section('scripts')
    <script>
        export default {
            name: 'paymentform',
            data() {
                return {
                    step:1,
                    subscription:{
                        subscription_plan:'{{ json_encode($user->name ) }}',
                        customer_name:'{{ json_encode($user->name ) }}',
                        customer_email:'{{ json_encode($user->email ) }}',
                        customer_phpne:'{{ json_encode($user->telephone ) }}',
                        customer_iban:'',
                        customer_tan:''
                    }
                }
            },
            methods:{
                prev() {
                    this.step--;
                },
                next() {
                    this.step++;
                },
                submit() {
                    alert('END');
                }
            }
        }
    </script>

@endsection

maximaexchen left a reply on Form In Blade With Vue Functionality

Mhh. Ok. When I paste your code into the app.js file I get "this.user.plan" in the input field, not the value from the controller.

I think have to pass the values via

{{ json_encode($user->name ) }}

Right? But where?

Do I need to have a part with

export default {
            name: 'paymentform',
            data() {
                return {
                    step:1,
                    subscription:{
                        subscription_plan:'{{ json_encode($user->plan ) }}',
                        customer_name:'{{ json_encode($user->name ) }}',
                        customer_email:'{{ json_encode($user->email ) }}',
                        customer_phone:'{{ json_encode($user->telephone ) }}',
                        customer_iban:'',
                        customer_tan:''
                    }
                }
            }
}

in the blade script part?

Thanks for your patience.

19 Apr
6 months ago

maximaexchen left a reply on Form In Blade With Vue Functionality

yes. the question is how to get the values from the form in the blade file to script in the app.js file.

eg.

$user->name

maximaexchen started a new conversation Form In Blade With Vue Functionality

Hi. I have a vue instance on #app. which is used by a site wide tooltip component.

Now I try to get a subscription multistep form in a blade file up and running.

I still beginn to understand how all this is working together.

in my app.js I have

const app = new Vue({
    el: '#app',
    data: function () {
        return {
            step:1,
            subscription:{
                subscription_plan:'',
                customer_name:'',
                customer_email:'',
                customer_iban:'',
                customer_tan:''
            }
        }
    },
    methods:{
        prev() {
            this.step--;
        },
        next() {
            this.step++;
        },
        submit() {
            
        }
    }
});

in the subscription.blad.php

<div v-if="step === 2">
                                <div class="form-group">
                                    <label for="customer_name">{{ __('Name') }}</label>
                                    <input v-model="subscription.customer_name" type="text" class="form-control" id="customer_name" name="customer_name" value="{{ $user->name ?? '' }}">

                                </div>


                                <div class="form-group">
                                    <label for="customer_email">{{ __('Email') }}</label>
                                    <input v-model="subscription.customer_email" type="text" class="form-control" id="customer_email" name="customer_email" value="{{ $user->email ?? '' }}">
                                </div>

                                <div class="form-group">
                                    <label for="customer_iban">{{ __('IBAN') }}</label>
                                    <input v-model="subscription.customer_iban" type="text" class="form-control" id="customer_iban" name="customer_iban" value="">
                                </div>

                                <div class="form-group">
                                    <label for="customer_phone">{{ __('Mobilenumber') }}</label>
                                    <input v-model="subscription.customer_phone" type="text" class="form-control" id="customer_phone" name="customer_phone" value="{{ $user->telephone ?? '' }}">
                                </div>
                                <button @click.prevent="prev()">Previous</button>
                                <button @click.prevent="next()">Next</button>
                            </div>

The initial values of the input fields get emptied when the VUE instance is called.

Could some one give me a hin?

Thanks and regards Marcus

14 Apr
7 months ago

maximaexchen left a reply on Route Validation

@wilk_randall Ok. So I have to add a policy for every model, right?

Isn't there a more "global" possibilty? I have about 20 models which need to be guearded.

13 Apr
7 months ago

maximaexchen left a reply on Route Validation

@wilburpowery thanks for your advice.

So it seems to be reasonable to crate a "global" Policy. Any advice? If I have many routes like:

lients/{client}/servicecategories 
lients/{client}/model2 
lients/{client}/model3
lients/{client}/model4
....

maximaexchen started a new conversation Route Validation

Hi everybody,

I have a security issue.

I have a route like:

clients/{client}/servicecategories 

how can I secure that a user can only call the client/servicecategories belongs to auth user. A user can have several clients.

I have a system like.

User belongsTo an Account Account hasMany Users User hasMany Clients

In the FormRequest (update/create), if I understood it correct, I could do it with a custom authorize() adjustment.

But how to prevent it in the controller-index-method?

I need a custom middleware to check if the clientId belongs to the user/account, right? But I don't know how....

Thanks in advance for any advice.

Regards Marcus

11 Apr
7 months ago

maximaexchen left a reply on Blade Testing If In_array Combined With Unserialize

Ok. I found the problem.

I have overseen that I am in a loop. And I always only dumped in the first iteration.... Shame on me. Thank you anyway!

Regards Marcus

maximaexchen left a reply on Blade Testing If In_array Combined With Unserialize

If I do

{{ dd(unserialize($receiver->type)) }}

it returns

array:1 [▼
  0 => "external"
]

maximaexchen left a reply on Blade Testing If In_array Combined With Unserialize

receiver->type is a serialized array

 a:1:{i:0;s:8:"external";}

maximaexchen left a reply on Blade Testing If In_array Combined With Unserialize

Thanks.

@rin4ik Not working

If I try it like this:

<span class="small-text">(
                                @if(in_array('internal', unserialize($receiver->type)))
                                    {{ __('internal')  }}
                                    @else
                                    {{ __('external') }}
                                @endif

                            )</span>

Same error

maximaexchen started a new conversation Blade Testing If In_array Combined With Unserialize

Hey. I have a strange problem. Maybe I missed something.

In my blade I have.


@foreach($receivers as $receiver)
               @if(in_array($receiver->id, $selectedReceivers))
                    <li>
                        {!! $receiver->name !!}
                        @if(!empty($receiver->type))
                            <span class="small-text">({{ in_array(__('internal'), unserialize($receiver->type)) ? __('internal') : __('external') }})</span>
                        @endif
                    </li>
                @endif
            @endforeach

I get the error

in_array() expects parameter 2 to be array, null given

but if I test

is_array(unserialize($receiver->type)) => true

Can someone give me a hint?

Thanks and regards Marcus

03 Mar
8 months ago

maximaexchen left a reply on Query Builder Subquery Join On Pivot

I want to combine the two statements above.

I like to have one query with the procedures form the first with the related data_categories over the pivot data_category_procedure from the second.

maximaexchen started a new conversation Query Builder Subquery Join On Pivot

Hi, I cannot use eloquent because of performance issues. (I think)

I have this, which ist working.

$procedures = DB::table('procedures')
            ->leftJoin('users as updateuser', 'updateuser.id', '=', 'procedures.update_user_id')
            ->leftJoin('users as createuser', 'createuser.id', '=', 'procedures.create_user_id')
            ->leftJoin('users as releaseuser', 'releaseuser.id', '=', 'procedures.release_user_id')
            ->select('procedures.*','updateuser.name as updateuser_name' , 'createuser.name as createuser_name', 'releaseuser.name  as releaseuser_name')
            ->where($addWhere)
            ->orderBy('procedures.attachment_01')
            ->get();

and now I have to insert this:

select `data_category_procedure`.*, `data_categories`.*, `procedures`.* from `data_category_procedure`
        inner join `procedures` on `data_category_procedure`.`procedure_id` = `procedures`.`id`
        inner join `data_categories` on `data_category_procedure`.`data_category_id` = `data_categories`.`id`

I need to have a value from data_categories.

Can someone please help? Thanks in advance. Regards Marcus

27 Feb
8 months ago

maximaexchen left a reply on Reusable Component With Different Content/text/values

Hi.

Thanks a lot! You both! I would never think about that this was the problem. Worked like a charm.

You made my day!

maximaexchen started a new conversation Reusable Component With Different Content/text/values

Hi. I am new to vue. :-( I try to add a reusable tooltip component to blade.

test.blade.php

<tooltip header="Headline 1" bodycontent="Bodycontent 1"></tooltip>
<tooltip header="Headline  2" bodycontent="Bodycontent 2"></tooltip>

Tooltip.vue

<template>
<div>

    <div id="contentpopup1" style="display: none" v-tippy-html>
        <div>
            <h3>{{ headline }}</h3>
            <p>{{ body }}</p>
        </div>
    </div>
    <button v-tippy="{ html : '#contentpopup1'  , interactive : true, reactive : false , theme : 'light' }"> INFO </button>
</div>
</template>
<script>
    export default {
        props: ['header','bodycontent'],
        data: function () {
            return {
                //bodycontent: 'btn-primary',
                headline: this.header,
                body:  this.bodycontent,
            }
        },
    }
</script>

I cannot figure out to change the 2 values for each tooltip... It always renders with the content of the first .

I think I have a basic lack of an idea how to work with components. I also tried named-slots....

I have no further idea for what I should google.

Suggestions? LInks?

Thanks in advance and kind regards. Marcus

02 Feb
9 months ago

maximaexchen left a reply on Vue-form-wizard Change Default Title "Awesome Wizard"

Is this a general lack of vue knowlege, or "vue-form-wizard" specific? I tried to google it but I cannot find out how to change the default props values form here:

http://vuejs.creative-tim.com/vue-form-wizard/#/?id=props

how can I override/update this:

props: {
  title: {
    type: String,
    default: 'Awesome Wizard'
  },
  subtitle: {
    type: String,
    default: 'Split a complicated flow in multiple steps'
  }
}

I am new to this topic. Someon who can bring light? Or show me where to switch light on. ;-)

Thanks in advance and regards.

maximaexchen left a reply on DB Transaction Try Catch Swift_TransportException

Thanks a lot. Helped me a lot.

01 Feb
9 months ago

maximaexchen left a reply on DB Transaction Try Catch Swift_TransportException

I did it now like this.

public function register(Request $request)
    {
        DB::transaction(function () use ($request) {
            try {
                $this->validator($request->all())->validate();
                $user = $this->create($request->all());
                UserVerification::generate($user);
                UserVerification::send($user);

                return back()->withAlert(__('Register successfully, please verify your email.'));

            } catch(Swift_TransportException $e){

                return back()->withAlert(__('There was a technical problem. Please contact the technical support'));
            }
        }, 5);
    }

But a new account is created. I think I still did not get it how to use it correctly

maximaexchen left a reply on DB Transaction Try Catch Swift_TransportException

Thanks for your reply. What do you mean with "you don't enjoy the benefit of automatic rollback"?

I will try to put DB::rollback() into function register().

maximaexchen started a new conversation Vue-form-wizard Change Default Title "Awesome Wizard"

I want to change the title coming from vue-form-wizard.

It should be done by props. But I cannot figure out where to put the new string.

This is what I have: (new strings in formOptions, but this obvious wrong)

<script>
    import VueFormGenerator from "vue-form-generator";
    import {FormWizard, TabContent} from 'vue-form-wizard'
    import 'vue-form-wizard/dist/vue-form-wizard.min.css'

    export default {

        components: {
            "vue-form-generator": VueFormGenerator.component,
            FormWizard,
            TabContent,
        },
        data() {
            return {
                selectedplan:'',

                model:{
                    firstName:'',
                    lastName:'',
                    email:'',
                    streetName:'',
                    streetNumber:'',
                    city:'',
                    country:'',

                },
                formOptions: {
                    validationErrorClass: "has-error",
                    validationSuccessClass: "has-success",
                    validateAfterChanged: true,

                    title: 'New Title',
                    subtitle: 'New subtitle.',
                    nextButtonText: 'Weiter',
                    backButtonText: 'Zurück',
                    finishButtonText: 'Abschließen',

                },
                firstTabSchema:{
                    fields:[
                        {
                            type: "awesome",
                            label: "Awesome (custom field)",
                            model: "selectedplan"
                        },
                        {
                            type: "input",
                            inputType: "text",
                            label: "First name",
                            model: "firstName",
                            required:true,
                            validator:VueFormGenerator.validators.string,
                            styleClasses:'col-xs-6'
                        }
                    ]
                },
            }
        },
        methods: {
            onComplete: function(){
                alert('Yay. Done!');
            }
        }
    }
</script>


Someone can help me?

Thanks and regards

25 Jan
9 months ago

maximaexchen left a reply on DB Transaction Try Catch Swift_TransportException

@martinbean Thanks for your answer. Oh. Its the complete code. I wanted to post shortend code.... didn't shortend it.

maximaexchen started a new conversation DB Transaction Try Catch Swift_TransportException

Hi there,

I try to build a small registration process and have some handling problems.

Here my shortend code.


public function register(Request $request)
{
    try {
        $this->validator($request->all())->validate();
        $user = $this->create($request->all());
        UserVerification::generate($user);
        UserVerification::send($user);
        return back()->withAlert(__('Register successfully, please verify your email.'));

    } catch(Swift_TransportException $e){
        return back()->withAlert(__('There was a technical problem. Please contact the technical support'));
    }
}

protected function create(array $data)
{
    DB::beginTransaction();

   
    $account = Account::create([
        'name' => $accountname,
        'companyname' => $companyname,
    ]);

    $user =  User::create([
        'name' => $data['name'],
        'email' => encrypt($data['email']),
        'password' => bcrypt($data['password']),
        'account_id' => $account->id,
        'last_login' => Carbon::now()
    ]);

    $user->assignRole(['Accountadmin']);

    $client =  Client::create([
        'account_id' => $account->id,
        'company' => $companyname,
        'name' => $accountname,
        'default' => 1,
        'activated' => 1,
    ]);

   
    if(!$user || !$account || !$client) {
        DB::rollBack();
    } else {
        DB::commit();
        return $user;
    }
}

Obvious I have some logical problems. If there is a TransportException the account and user are created anyhow. Could someone give me a hint how I should catch any errors during registration process.

Thanks in advance. Regards

18 Jan
9 months ago

maximaexchen left a reply on Cashier - Multiple Payment Methods

oh no. That was misleading. I dont't want to prefill. The values should come from the formfields... I am not that good in JS so I think I have the problem to get the values set from user input to the token.

Select plan C -> select payment method B -> submit -> stripe magic

maximaexchen started a new conversation Cashier - Multiple Payment Methods

Hi there,

I have a default working checkout form with stripe creditcard payment possibility based on this tutorial: https://github.com/drehimself/stripe-elements-with-laravel/blob/master/resources/views/checkout.blade.php

And don't have any clue how and where to add the possibility to add multiple payment methods to that form. I need to use stripe.js and elements, right?

I cannot figure out to add something like this:

var sepadebit = stripe.createSource({
            type: 'sepa_debit',
            sepa_debit: {
                iban: 'DExxxxxxxxxxxxx',
            },
            currency: 'eur',
            owner: {
                name: 'Max Mustermann',
            },
        }).then(function(result) {
            // handle result.error or result.source
        });

And how do I fill it dynamically from input fields?

Anyone who can give me a push in a right direction?

Thanks in advance Regards

24 Nov
11 months ago

maximaexchen left a reply on Generate A Secured Url

@martinbean Thanks! That looks promising.

maximaexchen left a reply on Generate A Secured Url

Thanks a lot. I am not right shure if I got it. But i try to test your advices.

23 Nov
11 months ago

maximaexchen left a reply on Generate A Secured Url

Thanks for your reply! I think my description was a bit missleading. Sorry.

Simply spoken I need a way to generate limited lifetime secured url for a "guest" visitor who is unknown to the system. For someone who needs temporaryly acces to the user-data.

I hope my description makes more sense now.

22 Nov
11 months ago

maximaexchen started a new conversation Generate A Secured Url

Hello,

is there a possibility to generate a limited lifetime url to a page/content which you normally only can access if you are an authenticated and logged-in user.

For example as a authenticated user I want to grant access to my personal content without login with something like a encoded url www.mysite.com/kfhw3ak57jfhda6sk6hfp932sdfsd

Thankfull for any tip.

Regards

maximaexchen left a reply on Check BelongsToMany Before Deleting It

Ok. I got it.

I added

$table->foreign('procedure_id')->references('id')->on('procedures');
$table->foreign('thirdcountry_id')->references('id')->on('thirdcountries');

in the migration. That did the trick.

maximaexchen left a reply on Check BelongsToMany Before Deleting It

Ok. Thanks! I think the way to check it on database level would be the best.

but I don't get it. Is it possible to set constrains on pivot_table via migration? My migration looks like this:

Schema::create('procedure_thirdcountry', function (Blueprint $table)
{
            $table->integer('procedure_id')->unsigned();
            $table->integer('thirdcountry_id')->unsigned();
            $table->primary(['procedure_id', 'thirdcountry_id']);
});

Or do I need another way ?

maximaexchen started a new conversation Check BelongsToMany Before Deleting It

Hello. I could not find a answer...

What would be the best way to prevent deleting a belongsToMany model wich is related to some other models. So I could set a warning "This model could not be deleted, because it is in unse by....."

Thanks in advance for any advice.

Regards

20 Oct
1 year ago

maximaexchen left a reply on Problem With Dusk Setup

Nobdy?

Too simple? Overseen something? Have a link?

Regards

19 Oct
1 year ago

maximaexchen started a new conversation Problem With Dusk Setup

Hey,

I try to setup testing with Dusk. Project is on a local mac with virtualhost testproject.dev (with Dnsmasq)

I cannot figure out how to configure the driver.

Defaults in DuskTestCase

/**
     * Prepare for Dusk test execution.
     *
     * @beforeClass
     * @return void
     */
    public static function prepare()
    {
        static::startChromeDriver();
    }

    /**
     * Create the RemoteWebDriver instance.
     *
     * @return \Facebook\WebDriver\Remote\RemoteWebDriver
     */
    protected function driver()
    {
        $options = (new ChromeOptions)->addArguments([
            '--disable-gpu',
            '--headless'
        ]);

        return RemoteWebDriver::create(
            'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
                ChromeOptions::CAPABILITY, $options
            )
        );
    }

And the Test:

/** @test */
    public function testIsLoggedInAdmin()  {

        $user = User::where('email', '=', '[email protected]')->firstOrFail();

        Auth::login($user);

        $this->browse(function ($browser) use ($user) {
            $browser->visit('/')
                ->assertSourceHas('<nav class="nav navbar-nav ml-auto">');
        });
    }

I always get a 404-Page.

Where can I tell Dusk to browse http://testproject.dev

testproject.dev is set in .env and config/app.php

Some advices?

Thanks in advance and regards.

12 Oct
1 year ago

maximaexchen left a reply on Strange Behavior After Migration

Ah ok. Makes sense. Thanks a lot for the explanation.

maximaexchen left a reply on Strange Behavior After Migration

in the controller

 public function index()
    {

        $clientId = Session::get('client_id');
        $client =  Client::whereId($clientId)->firstOrFail();
        $persons = Person::where('client_id', $clientId)->get();

        return view('manager.account.clients.person.index', compact('persons'));
    }

maximaexchen started a new conversation Strange Behavior After Migration

Hey there.

I made a new migration

 php artisan make:model Models/Person -mcr

Strangely a migration file with the name "2017_1011_121554_createpeoples_table.php" was created. Model and controller had the correct term Person. Now if a call a view in wich the person Model is called I get the error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'belabimba.people' doesn't exist (SQL: select * from `people` where `client_id` = 3)

I could not figure out why still table people is addressed. When I put

protected $table = 'persons';

to the model everything is fine. I try to understand what is going on. Is person somehow reserved? Is it cached somewhere I could not find? I also renamed the migration file manually to persons and did a migration:refresh. No effect. Any advice where to look.

Regards and thanks advance Marcus