SteamDiesel

SteamDiesel

Member Since 2 Years Ago

Brisbane

Experience Points
11,820
Total
Experience

3,180 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
115
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 3
11,820 XP
Jul
17
3 months ago
Activity icon

Replied to Fresh Nova Install... Missing Resources Links

I just did the same thing. thanks for posting this!

Jun
04
4 months ago
Activity icon

Replied to My '@store' Request Feels Ugly Saving Currency In Decimal Format.

Things I've learned since posting this question. Don't store your currency as decimal values. Multiply and divide your stored values by 100 so that you can be certain your values are stored to the correct number of places and you don't end up with rounding issues. The smallest unit is a cent, not a dollar, so count the cents. Same with the odometer.

Jun
03
4 months ago
Activity icon

Replied to Tinkering With Json Array Request In The Controller (SOLVED)

Holy heck, you guys! I've had a breakthrough!

I read the php docs...

https://www.php.net/ArrayObject I transformed the array into an object inside the foreach() loop.

so here is the solve:

    public function store(Request $request)
    {
        //


        $address = new Address([
            'property_name' => $request->property_name,
            'unit' => $request->unit,
            'level' => $request->level,
            'street_number' => $request->street_number,
            'street_name' => $request->street_name,
            'street_type' => $request->street_type,
            'suburb' => $request->suburb,
            'state' => $request->state,
            'postcode' => $request->postcode,
            'country' => $request->country,
        ]);
        $address->save();

        foreach($request->tennants as $value){
            $person = new \ArrayObject($value, 2); // This fixed it.

            $address->tenant()->attach($person->id, [
                'status' => $person->status,
                'months' => $person->months
            ]);
        }

        return response()->json([
            'address' => $address
        ], 200);

    }

In summary, it was saying i was trying to get property of non-object. So I turned it into an object. if you see the php docs page, the options after the comma are:

/* Constants */ const integer STD_PROP_LIST = 1 ; const integer ARRAY_AS_PROPS = 2 ;

I suspect I could also turn the tenants array into an object, too... but I can't think of a reason to do that right now.

Happy dance. Learning is so fun. I hope this helps someone.

Activity icon

Started a new conversation Tinkering With Json Array Request In The Controller (SOLVED)

So I've got a SPA on the front end (VueJS) and Laravel backend 5.8.*.

I keep bumping into this problem, I'm sure there is a simple and common fix for it, but I have been unable to solve it with my usual google kung fu.

My objective: save a new street address, and at the same time send through the id of each tennant and attach them to the address with their own relationship info on the pivot table.

Example: address is 1 Rode road, Brisbane. michael lived here for 21 months and was boarding. Jenny lived here for 60 months and was the property owner.

I imagine I can save the address and then iterate through an array of people I send to the server as "tennants" to attach each of them after the address is created.

my request to store I get this error message: "Trying to get property 'id' of non-object"

On the front end:

saveAddress(){
// First I iterate through the people I want to attach, to the address, and I use this bit to convert the years and months into a single "months" value.
                var array = this.tenants.map((person) => {
                    return {
                        id: person.id,
                        name: person.first_name,
                        status: person.status,
                        months: +person.months + (person.years * 12)
                    }
                });

// then I send it through to the backend like this. note the tennants is the new array with the specific fields i want to send
                axios.post('/api/address', {
                    order: this.order,
                    property_name: this.property_name,
                    unit: this.unit,
                    level: this.level,
                    street_number: this.street_number,
                    street_name: this.street_name,
                    street_type: this.street_type,
                    suburb: this.suburb,
                    state: this.state,
                    postcode: this.postcode,
                    country: this.country,
                    tenants: array
                }).then(response=>{
                    console.log(response.data.address);
                }).catch(error=>{
                    console.log(error);
                });
            }

so I dd($request->input()) and get:

array:12 [
  "order" => null
  "property_name" => null
  "unit" => null
  "level" => null
  "street_number" => "1"
  "street_name" => "Rode"
  "street_type" => "Road"
  "suburb" => "Brisbane"
  "state" => "QLD"
  "postcode" => "4000"
  "country" => "Australia"
  "tenants" => array:2 [
    0 => array:3 [
      "id" => 1
      "status" => "Boarding Spouse"
      "months" => 21
    ]
    1 => array:3 [
      "id" => 2
      "status" => "Mortgage"
      "months" => 60
    ]
  ]
]

This is what my store method looks like in the AddressController:

    public function store(Request $request)
    {
        //
    // Save the new address
        $address = new Address([
            'property_name' => $request->property_name,
            'unit' => $request->unit,
            'level' => $request->level,
            'street_number' => $request->street_number,
            'street_name' => $request->street_name,
            'street_type' => $request->street_type,
            'suburb' => $request->suburb,
            'state' => $request->state,
            'postcode' => $request->postcode,
            'country' => $request->country,
        ]);
        $address->save();

    
// Iterate through the tenants 
// !!THIS SEEMS TO BE THE ISSUE!!
        foreach($request->tenants as $tenant){
            $address->tenant()->attach($tenant->id, [ //this is the line
                'status' => $tenant->status,
                'months' => $tenant->months
            ]);
        }
    
    // Return the newly saved address
        return response()->json([
            'address' => $address
        ], 200);

    }

Has anyone else found a solve for this?

I've been through the laravel docs here: https://laravel.com/docs/5.8/requests#retrieving-input

I haven't figured out how to iterate through the array in the controller to be able to use the key=>value pairs in a useful way.

but when I dd($tenant) in the foreach I get the first tenant array input, so that's something...

thoughts?

Apr
20
5 months ago
Activity icon

Replied to VueJS And Vuex Updating Computed Properties Fed By State Data

I've found a hack...

I'm leaving the rest of my code untouched but added a single line to the response of my postTask() method in the component. here it is:

            postTask(payload){

                axios.post('/api/task', {
                    task: payload.task,
                    assigned_to: payload.assigned_to,
                    deadline: payload.deadline,
                    model_id: payload.model_id,
                    task_type: payload.source
                }).then(response=>{
                    this.pushTask({task: response.data.task, source: payload.source});
                    this.task = '';
                    this.assigned_to = '';
                    this.deadline = '';

                    this.todo.unshift(response.data.task); // THIS LINE RIGHT HERE.

                }).catch(error=>{
                    console.log(error);
                });

            },

I'm still pushing to the "real" tasks array in the state through the pushTask Action, but I'm just directly plugging the new task into the computed array, too. There you have it... sometimes all it takes it 24 hours of code nightmares, googling and lurking through forums before you just implement an elegant hack in a single line.

Activity icon

Replied to Creating A Blog With Laravel And Vue

I would imagine you just need an author field and then the actual entry. Maybe a string field for a header image url, or just an image ID if you're going to reference a seperate image table. You can always add columns to your tables later if you think you need to. For comments you would have a seperate comments model and relationships (comments will be very similar to the blog post model, but with an extra field for the post_id they reference, or you could make your comments polymorphic and give users the ability to comment on other comments reddit-style). very exciting.

Activity icon

Replied to Property Or Method Is Not Defined On The Instance But Referenced During Render.

in your terminal use:

npm run watch

this will automatically compile your javascript every time you leave the editor. (I'm using git bash and php storm on windows 10, your environment may be different)

Also, if you're using homestead, remember to use npm run watch outside of that environment or it will throw countless frustrating compile errors.

Activity icon

Started a new conversation VueJS And Vuex Updating Computed Properties Fed By State Data

Hey team, I have a Tasks Component which I've resused across my app for 3 difference but similar models. The nature of the app means I may want one of each of these models to be 'loaded' in the state at the same time. When I open the view model page it shows the basic data already in the array from the index, and requests the rest of the realted models from the server to populate the components after the page loads (using vue-router).

So for example I have a model called File. a File can have many tasks, comments and other things associated with it.

My issue: I'm keeping the tasks in the state, and this is fine for things like comments which don't need to be filtered or sorted after loading them. But I display the tasks with computed properies which seperate the 'is_complete: 0' from the 'is_complete: 1' tasks.

Tasks component:

<template>
    <div class="card p-2 mb-2">
        <div class="p-2">

                <div class="row p-2">
                    <input class="form-control form-control-sm col-12"
                           placeholder="New task..."
                           v-model="task"
                    >
                </div>
                <div class="row p-2">
                    <select class="form-control form-control-sm col-md-4 pr-1" v-model="assigned_to">
                        <option selected>Myself</option>
                        <option v-for="user in taggedUsers" ></option>
                    </select>

                    <input class="form-control form-control-sm col-md-6 pl-1" type="datetime-local" v-model="deadline">
                    <div class="col-md-2">
                        <button class="btn btn-sm btn-outline-primary ml-auto"
                                @click.prevent="postTask({source,model_id,task,deadline})">Create</button>
                    </div>
                </div>

        </div>


            <div  class="card p-1 mb-1 col-lg-12">
                <div class="row" v-for="task in todo">
                    <div class="col-10">
                        <p :title="'assigned to ' + task.assigned_to.name + ' by ' + task.assigned_by.name + ' at ' + task.created_at">

                                {{task.task}} [assigned to {{task.assigned_to.name}}]
                            <br>
                            <span v-if="task.deadline">
                                <small>
                                    Due {{fromNow(task.deadline)}}
                                </small>
                            </span>
                        </p>
                    </div>
                    <div class="col-2">
                        <div>
                            <button class="btn btn-sm btn-light"
                                    @click.prevent="toggleDone(task,1)">
                                Done
                            </button>
                        </div>
                    </div>
                </div>
                <div>
                    Complete tasks:
                </div>
                <div class="row" v-for="task in complete" >
                    <div class="col-2">
                        <button class="btn btn-sm btn-light"
                                @click.prevent="toggleDone(task,0)">Undo</button>
                    </div>
                    <div class="col-10">
                        <p :title="'marked complete at ' + task.completed_at">
                            <s>
                                {{task.task}}
                            </s>
                        </p>
                    </div>


                </div>

            </div>

    </div>
</template>

<script>
    import {mapActions} from 'vuex'
    export default {
        name: "Tasks",
        props: {
            model_id: Number,
            source: String,
            tasks: Array,
            taggedUsers: Array
        },
        data(){
            return{
                task: '',
                assigned_to: '',
                deadline: '',

            }
        },

        computed:{
            todo(){

                var result = this.tasks.filter(function (task) {
                    return task.is_complete === 0
                });
                return result;
            },
            complete(){

                var result = this.tasks.filter(function (task) {
                    return task.is_complete === 1
                });
                return result;
            },
        },

        methods:{

            fromNow(time){
                return moment(time).fromNow();
            },

            postTask(payload){

                axios.post(TASK_URI, {
                    task: payload.task,
                    assigned_to: payload.assigned_to,
                    deadline: payload.deadline,
                    model_id: payload.model_id,
                    task_type: payload.source
                }).then(response=>{
                    this.pushTask({task: response.data.task, source: payload.source});
                    this.task = '';
                    this.assigned_to = '';
                    this.deadline = '';

                }).catch(error=>{
                    console.log(error);
                });

            },
            toggleDone(task,io){
                //io value 1 for complete and 0 to mark as incomplete
                var index = this.tasks.indexOf(task);
                axios.patch(TASK_URI + task.id, {
                    is_complete: io
                }).then(response=>{
                    toastr.success(response.data.message);
                    task.is_complete = io;

                }).catch(error=>{
                    console.log(error);
                });
            },
            ...mapActions(['pushTask'])
        },
    }
</script>

<style scoped>

</style>

So I thought I would be able to push the newly created task (along with the user info attached in the backend) to the existing task array and have it update in the view like my comments component

So here in my store.js i have this method

pushTask({commit, state}, payload){
            switch(payload.source){

                case 'Lead':
                    state.selectedLeadTasks.unshift(payload.task);
                    break;

                case 'Deal':
                    state.selectedDealTasks.unshift(payload.task);
                    break;

                case 'File':
                    state.selectedFileTasks.unshift(payload.task);
                    break;

            }
        },

I have confirmation that my state array is updating the selectedFileTasks Array, so up to this point everything works perfectly.

Now when I expect the reactivity in my vue component for tasks it causes me issues.

I feed the tasks into the component from the parent via props like this:

<tasks-component
                        v-bind:model_id="selectedFile.id"
                        v-bind:source="'File'"
                        v-bind:tasks="selectedFileTasks"
                >
                </tasks-component>

and of course the Tasks are mapped to the parent via ...mapState(['selectedFileTasks'])

I have seen people refer to Vue.set() or this.$set() to solve the problem. But I have no idea where you might put this, or if the computed properties I have used to seperate my 'is_complete' tasks is even the right way to do that.

The curent code I've posted is after changing from directly pushing to the task array through the props component.

What are your thoughts?

Mar
10
7 months ago
Activity icon

Replied to Spark: Register New User With Seperate Preferences Model

Thinking about it now... I agree, I could put it straight onto the landing-dashboard so it prompts them to do it first-order-of-business.

on the front end run something like: if ( !$presets ) { show preset form }

But also I could do the same IF check and, instead of rendering a form which the user could ignore and then I risk breaking their first time user experience, I could just run the create method when rendering the dashboard for the first time.

so in the back end on the route to return the '/home' view I can put: if ( !$presets ) {$presets = $user->presets ->create([ app default settings ])}

I'm much more confident with the vanilla Laravel or Vuejs than I am with Spark. Spark is magic.

But I like your suggestion to get to know Spark better. I'll tinker with the Spark::swap and see what I can achieve. Thanks for your help! :)

Mar
09
7 months ago
Activity icon

Replied to Spark: Register New User With Seperate Preferences Model

@KEL_ - I see what you're saying, and if it were as simple as a few fields that stay static I'd probably agree. But I want to give the user the ability to make and switch between multiple preset profiles, the first of which will be their default.

Activity icon

Started a new conversation Spark: Register New User With Seperate Preferences Model

Hey team,

I've got a Shiny new spark project, I'm trying to include a new entry for a realted UserPresets model when I create a new User. I've prefer to keep UserPresets seperate to the User model for sanity and so my app remains seperate to the spark billing and user control.

Has anyone else found a good spot to wedge a $user->presets->create(['user_id'=>$user->id]); into the spark register new user labrynth?

Nov
16
11 months ago
Activity icon

Replied to Homestead Hangs At SSH Auth Method: Private Key

@BULLBAOTOG - Yep. solved my problem. It said that it has discarded the insecure key and crated a new one. sick.

Jul
17
2 years ago
Activity icon

Started a new conversation My '@store' Request Feels Ugly Saving Currency In Decimal Format.

Hey team, my store method is chock full of IF-checks to wash the request before I save it, I have a flexible form which is intended to be very forgiving for users who store incomplete data. For instance, some of the fields would only be completed 10% of the time, but when they are needed, it's critical to include them, and the absence of data means something to the users, too. The data is vehicle sales contract fields, so lots of different fields in a general repeatable format.

To make matters more exciting, I'm working with currency and using decimals for the data fields. So all currency fields in my migrations look like this:

$table->decimal('vehicle_price',10,2)->nullable;

I had issues getting my form to submit when the store method looked like this:

    public function store(Request $request)
    {
        $user = Auth::user();

        $deal = new VehicleDeal;

        $deal->make = request('make');
    $deal->vehicle_price = request('vehicle_price');
        $deal->odometer = request('odometer',0);
        $deal->build_date = request('build_date');
        $deal->user_id = $user->id;
        $deal->team_id = $user->currentTeam()->id;

        $deal->save();
    return back();
    }

the above code was giving me errors when I left fields blank:

SQLSTATE[HY000]: General error: 1366 Incorrect decimal value: '' for column 'vehicle_price' at row 1 and SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '' for column 'build_date' at row 1

I decided to just switch the odometer to a string, as some users may input the "...km" at the end, and I'd like to forgive them for it.

Anyway, to solve this problem I just started including if statements for each currency and date field, like this:

    public function store(Request $request)
    {
        $user = Auth::user();

        $deal = new VehicleDeal;

        $deal->make = request('make');
        if(request('vehicle_price')){
            $deal->vehicle_price = request('vehicle_price');
        }

        $deal->odometer = request('odometer',0);

        if(request('build_date')){
            $deal->build_date = request('build_date'); 
        }
        

        $deal->user_id = $user->id;
        $deal->team_id = $user->currentTeam()->id;

        $deal->save();
        return back();
}

This is the abridged version of my code, the true version has 13 decimal fields like vehicle_price and 2 date fields.

That's a lot of if-checking. I wondered if there was a more efficient way to grab this data and put it into the database. I decided that decimal was a simpler solution to storing currency, due to currency being a decimal, and then it shouldn't require division and multiplication if it were stored as integers. However, I'm open to reviewing this decision.

Also, I'm using the laravelcollective/html blade form layouts, if that makes any difference.

Jul
16
2 years ago
Activity icon

Replied to Laravel Spark: “All My Teams” Billing

It depends on how you expect your users to behave within the app.

I hadn't considered this until reading your question. But I guess if you want to keep the billing as simple as possible, so for a company to have one account with multiple teams and users in it. You could just build out your app within the spark framework to have the teams you want. So spark would only be responsible for billing and user control, but data access is walled off to the outside world by the spark team for billing, then team data and users are walled off within your app.

You could just play with the words you use to describe these sub-teams. You can also change the way spark refers to "teams" to another, more fitting word, like "Organisation" or "account". And within the native spark teams, you could call your sub-team groups anything else, eg; "squad", "Wolfpack", "department", "team". You'd just make appropriate models, controllers, middleware, and routes to suit this need for sub-team groups.

Maybe, as an alternative, you could re-purpose the role intermediate column in the user_team table. Or even add a 4th column to refer to the team. But that might make it difficult and confusing if you want a person to have multiple roles and teams within the "organization".

Activity icon

Replied to Many To Many Working Oneway Only

What is the error?

Jul
14
2 years ago
Activity icon

Replied to (SOLVED) Stripe Error With Spark - Did Not Set A Valid Publishable Key

I've found a solution. I have my services.php stripe section setup with hard-coded stripe keys instead of referencing the .env file.

config/services Before Fix:

    'stripe' => [
        'model'  => App\User::class,
        'key'    => env('pk_test_xxxxxxxxxxxxx'),
        'secret' => env('sk_test_xxxxxxxxxxxxx'),
    ],

config/services After Fix:

    'stripe' => [
        'model'  => App\User::class,
        'key'    => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
    ],

I have no idea why I did this, but I recall following some instructions somewhere that told to hardcode the values. Which, now that I know more than I did a few days ago, would be terrible for security.

Activity icon

Replied to Is It Possible To Bill Per Team Created?

Forgive my laziness for not double checking this, but I thought I could only have either team or individual billing when I was tinkering with it. I decided to simplify my billing method to team billing only (which has shaded my bias, so take this advice with salt)

For my user base, there would be very few situations where a user wouldn't be a part of a team, and the data they generate would need to remain accessible only to members of those teams. Even if they were using the system as an individual, doing the same work, they'd still want to have additional user accounts (for customers and referrers), and making those people sign up on a billing plan would be difficult.

And then there is the matter of data access and sharing.

So if a staff member leaves one shop and goes to work in another shop. those 2 shops would have teams, and the user account remains in the system, but essentially dormant (and free) until it is invited to a new shop. If the user account is orphaned because the email account for the user is no longer monitored (employer provided email) then the account could be changed to a new email. but it wouldn't make a difference because data access is restricted via team checking middleware.

If the user leaves the shop and goes to work for themselves, they may want to add co-workers in future, so having the billing based on team size fit for my system needs (my pricing is aligned directly to the team size). And if an individual builds a business that outgrows them, they can just transfer the team (with users and data) to a new owner.

Activity icon

Replied to Amazon AWS Aurora

Yeah, I ended up going with RDS with MySQL 5.7, too. Was getting that string length error with 5.4 when I bashed the Aurora DB into existence.

I quickly abandoned the idea of hacking my shiny new 5.4 app to work with old MySQL.

Jul
11
2 years ago
Activity icon

Replied to Is It Possible To Bill Per Team Created?

I had the same question.

Do I think it will be better to bite the bullet? If I'm to recite the propaganda, Spark will save you about 3 months worth of coding. if (3 months of coding > $99){ 'Oh, my goodness, yes' }

Also, why not have a team subscription option with a team max of 1?

    Spark::teamPlan('Lone Wolf', 'Lone1')
        ->price(39)
        ->maxTeamMembers(1)
        ->features([
            'Just one user',
           'can join other teams when invited',
    'can create additional teams or expand this team'
        ]);

I see your post was submitted 3 days ago, have you made any more progress or changed anything since then?

Activity icon

Started a new conversation (SOLVED) Stripe Error With Spark - Did Not Set A Valid Publishable Key

Hey Team,

When I enter a credit card number (both test and my own) and try to submit for a subscription, using both the test API keys and my live API keys, in both my homestead and on the live forge server, I get the following error in my console:

js.stripe.com/:3 Uncaught Error: You did not set a valid publishable key. Call Stripe.setPublishableKey() with your publishable key. For more info, see https://stripe.com/docs/stripe.js

    at Function.Stripe.isDoubleLoaded.Stripe.utils.b.validateKey (js.stripe.com/:3)

    at Function.Stripe.token.b.create (js.stripe.com/:2)

    at Function.Stripe.card.c.createToken (js.stripe.com/:2)

    at o.subscribe (app.js:27)

    at Proxy.n (app.js:67)

    at click (eval at Ci (app.js:67), <anonymous>:2:25288)

    at HTMLButtonElement.t (app.js:67)

I have set my keys in the .env and config/services.php with both pk_live and sk_live set correctly. I thought the spark app was supposed to reference these values, so I don't know where it would be looking. all plans have been established in both the app/providers/SparkServiceProvider.php and the stripe plans panel. ID and name are the same, prices are the same. I have a coupon for 99% off, which I have been using, but that doesn't seem to be related. here's my SparkServiceProvider

namespace App\Providers;

use Carbon\Carbon;
use Laravel\Cashier\Cashier;
use Laravel\Spark\Spark;
use Laravel\Spark\Providers\AppServiceProvider as ServiceProvider;

class SparkServiceProvider extends ServiceProvider
{
    /**
     * Your application and company details.
     *
     * @var array
     */
    protected $details = [
        'vendor' => 'xxxxxxxxxx',
        'product' => 'xxxxxxxxxxx',
        'street' => 'xxxxxxxxx',
        'location' => 'xxxxxxxxxx',
        'phone' => 'xxxxxxxxxx',
    ];

    /**
     * The address where customer support e-mails should be sent.
     *
     * @var string
     */
    protected $sendSupportEmailsTo = '[email protected]';

    /**
     * All of the application developer e-mail addresses.
     *
     * @var array
     */
    protected $developers = [
        //
        '[email protected]'
    ];

    /**
     * Indicates if the application will expose an API.
     *
     * @var bool
     */
    protected $usesApi = false;

    /**
     * Finish configuring Spark for the application.
     *
     * @return void
     */
    public function booted()
    {
        Cashier::useCurrency('aud', '$');

        Spark::useStripe()->noCardUpFront()->teamTrialDays(10);

        //disabled so users can hot switch teams through native spark dashboard.
//        Spark::identifyTeamsByPath();

        Spark::useRoles([
            'fb' => 'User',
            'sales' => 'Sales',

        ]);

        Spark::useTwoFactorAuth();


        Spark::teamPlan('Beta 3', 'BETA3')
            ->price(149)
            ->maxTeamMembers(3)
            ->features([
                '3 team members',
                'Price fixed for 3 years (Beta plans only)',
                'all future features and upgrades'
            ]);

        Spark::teamPlan('Beta 5', 'BETA5')
            ->price(249)
            ->maxTeamMembers(5)
            ->features([
                '5 team members',
                'Price fixed for 3 years (Beta plans only)',
                'all future features and upgrades'
            ]);

        Spark::teamPlan('Beta 7', 'BETA7')
            ->price(349)
            ->maxTeamMembers(7)
            ->features([
                '7 team members',
                'Price fixed for 3 years (Beta plans only)',
                'all future features and upgrades'
            ]);

        Spark::teamPlan('Beta 10', 'BETA10')
            ->price(499)
            ->maxTeamMembers(10)
            ->features([
                '10 team members',
                'Price fixed for 3 years (Beta plans only)',
                'all future features and upgrades'
            ]);



    }
}

Attempted solutions: log out, restarted server, log back in.

I haven't touched the js that runs Spark, I didn't think I should need to. I've just deployed to AWS through Forge. I'm based in Australia. I'm using Stripe for payments with the native spark setup, Stripe account is activated. Laravel 5.4

Is there an undocumented step I should be following after adding the API keys to ensure the js for spark and stripe get my keys?

Jul
09
2 years ago
Activity icon

Replied to Amazon AWS Aurora

Hey Jason, I have the same question... did you get it going? I'm now asking you this question.

Jul
03
2 years ago
Activity icon

Replied to Adding Custom Fields To Spark User Registration

Hold up. This is embarrasing.... I hadn't imported my Carbon class, as per the resolution in this thread I found after better googling. (https://laracasts.com/discuss/channels/spark/adding-custom-field-to-registration)

Activity icon

Started a new conversation Adding Custom Fields To Spark User Registration

Hey Spark team! I'm trying to modify the user registration for spark. I want to stay within the Vuejs and native framework, so I'd prefer not to reference a model.

I've followed the instructions in [the documentation for adding registrations fields] (https://spark.laravel.com/docs/4.0/adding-registration-fields) but My new user registration form is saying errors but doesnt show specifics.

I'll go through it again and show the code below:

My Migration:

'''

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->tinyInteger('age')->nullable();
        $table->string('email')->unique();
        $table->string('password', 60);
        $table->rememberToken();
        $table->text('photo_url')->nullable();
        $table->tinyInteger('uses_two_factor_auth')->default(0);
        $table->string('authy_id')->nullable();
        $table->string('country_code', 10)->nullable();
        $table->string('phone', 25)->nullable();
        $table->string('two_factor_reset_code', 100)->nullable();
        $table->integer('current_team_id')->nullable();
        $table->string('stripe_id')->nullable();
        $table->string('current_billing_plan')->nullable();
        $table->string('card_brand')->nullable();
        $table->string('card_last_four')->nullable();
        $table->string('card_country')->nullable();
        $table->string('billing_address')->nullable();
        $table->string('billing_address_line_2')->nullable();
        $table->string('billing_city')->nullable();
        $table->string('billing_state')->nullable();
        $table->string('billing_zip', 25)->nullable();
        $table->string('billing_country', 2)->nullable();
        $table->string('vat_id', 50)->nullable();
        $table->text('extra_billing_information')->nullable();
        $table->timestamp('trial_ends_at')->nullable();
        $table->timestamp('last_read_announcements_at')->nullable();
        $table->timestamps();
    });
}

'''

My Modified form, having added the age in the register-common-form.blade field as per the instructions:

'''

@if (Spark::usesTeams() && Spark::onlyTeamPlans()) {{ ucfirst(Spark::teamString()) }} Name
        <div class="col-md-6">
            <input type="text" class="form-control" name="team" v-model="registerForm.team" autofocus>

            <span class="help-block" v-show="registerForm.errors.has('team')">
                @{{ registerForm.errors.get('team') }}
            </span>
        </div>
    </div>

    @if (Spark::teamsIdentifiedByPath())
        <!-- Team Slug (Only Shown When Using Paths For Teams) -->
        <div class="form-group" :class="{'has-error': registerForm.errors.has('team_slug')}" v-if=" ! invitation">
            <label class="col-md-4 control-label">{{ ucfirst(Spark::teamString()) }} Slug</label>

            <div class="col-md-6">
                <input type="text" class="form-control" name="team_slug" v-model="registerForm.team_slug" autofocus>

                <p class="help-block" v-show=" ! registerForm.errors.has('team_slug')">
                    This slug is used to identify your {{ Spark::teamString() }} in URLs.
                </p>

                <span class="help-block" v-show="registerForm.errors.has('team_slug')">
                    @{{ registerForm.errors.get('team_slug') }}
                </span>
            </div>
        </div>
    @endif
@endif

<!-- Name -->
<div class="form-group" :class="{'has-error': registerForm.errors.has('name')}">
    <label class="col-md-4 control-label">Name</label>

    <div class="col-md-6">
        <input type="text" class="form-control" name="name" v-model="registerForm.name" autofocus>

        <span class="help-block" v-show="registerForm.errors.has('name')">
            @{{ registerForm.errors.get('name') }}
        </span>
    </div>
</div>

    {{--Age
    This field has been added as per the --}}
<div class="form-group" :class="{'has-error': registerForm.errors.has('age')}">
    <label class="col-md-4 control-label">Age</label>

    <div class="col-md-6">
        <input type="text" class="form-control" name="age" v-model="registerForm.age" autofocus>

        <span class="help-block" v-show="registerForm.errors.has('age')">
            @{{ registerForm.errors.get('age') }}
        </span>
    </div>
</div>

<!-- E-Mail Address -->
<div class="form-group" :class="{'has-error': registerForm.errors.has('email')}">
    <label class="col-md-4 control-label">E-Mail Address</label>

    <div class="col-md-6">
        <input type="email" class="form-control" name="email" v-model="registerForm.email">

        <span class="help-block" v-show="registerForm.errors.has('email')">
            @{{ registerForm.errors.get('email') }}
        </span>
    </div>
</div>

<!-- Password -->
<div class="form-group" :class="{'has-error': registerForm.errors.has('password')}">
    <label class="col-md-4 control-label">Password</label>

    <div class="col-md-6">
        <input type="password" class="form-control" name="password" v-model="registerForm.password">

        <span class="help-block" v-show="registerForm.errors.has('password')">
            @{{ registerForm.errors.get('password') }}
        </span>
    </div>
</div>

<!-- Password Confirmation -->
<div class="form-group" :class="{'has-error': registerForm.errors.has('password_confirmation')}">
    <label class="col-md-4 control-label">Confirm Password</label>

    <div class="col-md-6">
        <input type="password" class="form-control" name="password_confirmation" v-model="registerForm.password_confirmation">

        <span class="help-block" v-show="registerForm.errors.has('password_confirmation')">
            @{{ registerForm.errors.get('password_confirmation') }}
        </span>
    </div>
</div>

<!-- Terms And Conditions -->
<div v-if=" ! selectedPlan || selectedPlan.price == 0">
    <div class="form-group" :class="{'has-error': registerForm.errors.has('terms')}">
        <div class="col-md-6 col-md-offset-4">
            <div class="checkbox">
                <label>
                    <input type="checkbox" name="terms" v-model="registerForm.terms">
                    I Accept The <a href="/terms" target="_blank">Terms Of Service</a>
                </label>

                <span class="help-block" v-show="registerForm.errors.has('terms')">
                    @{{ registerForm.errors.get('terms') }}
                </span>
            </div>
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-6 col-md-offset-4">
            <button class="btn btn-primary" @click.prevent="register" :disabled="registerForm.busy">
                <span v-if="registerForm.busy">
                    <i class="fa fa-btn fa-spinner fa-spin"></i>Registering
                </span>

                <span v-else>
                    <i class="fa fa-btn fa-check-circle"></i>Register
                </span>
            </button>
        </div>
    </div>
</div>

'''

Then I've modified the app.js in resources/assets/js/app.js and executed npm run dev, just in case.

'''

require('spark-bootstrap');

require('./components/bootstrap');

Spark.forms.register = { age: '' };

var app = new Vue({ mixins: [require('spark')] });

'''

Next, I did a copy and paste job from the instructions into the booted() method of app/Providers/SparkServiceProvider.php

'''

public function booted()
{
    Cashier::useCurrency('aud', '$');

    Spark::useStripe()->noCardUpFront()->teamTrialDays(65);

    Spark::identifyTeamsByPath();

    Spark::useTwoFactorAuth();

    Spark::validateUsersWith(function () {
        return [
            'name' => 'required|max:255',
            'age' => 'required|integer|min:1',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
            'vat_id' => 'max:50|vat_id',
            'terms' => 'required|accepted',
        ];
    });

    Spark::createUsersWith(function ($request) {
        $user = Spark::user();

        $data = $request->all();

        $user->forceFill([
            'name' => $data['name'],
            'email' => $data['email'],
            'age' => $data['age'],
            'password' => bcrypt($data['password']),
            'last_read_announcements_at' => Carbon::now(),
            'trial_ends_at' => Carbon::now()->addDays(Spark::trialDays()),
        ])->save();

        return $user;
    });


    //plans for subscriptions

    Spark::freeTeamPlan()
        ->features([
            'Free'
        ]);


    Spark::teamPlan('Big 3', 'provider-id-1')
        ->price(149)
        ->maxTeamMembers(3)
        ->features([
            '3 team members',
            'all future features and upgrades'
        ]);

}

}

'''

So now it's at the end of the page instructions. When I try to register a user I get

Something went wrong. Please try again or contact customer support.

I will want to change this from Age to dob, after I figure out what is going wrong. And, in fact, I will want to switch the new user reg form to show 'first_name', 'last_name', 'dob', 'mobile_number'.

I'm running Homestead latest version, installed fresh spark 4 a few days ago.

It's worth mentioning I'm a noob to webdev in general, but I'm forcing myself to absorb everything I can. I want to be proficient with Laravel and Vuejs.