rrrankin

IT Manager at Smith-Blair

Experience

14,300

3 Best Reply Awards

  • Member Since 3 Years Ago
  • 165 Lessons Completed
  • 0 Favorites

14th September, 2018

rrrankin left a reply on Resource On Dashboard • 5 days ago

Thanks @ricardo. Creating a card or a tool to duplicate something that already exists as a resource doesn't seem very DRY. There must be some way to display an existing resource on the dashboard without having to completely recreate it.

rrrankin started a new conversation Resource On Dashboard • 5 days ago

On the Laravel Nova home page, the screenshot of the Nova dashboard appears to be displaying the User resource. I have combed through the docs and I'm either missing it or what I'm seeing is not actually a resource. May it's a custom card? Or a tool?

Does anyone know how to display a resource on the dashboard?

8th September, 2017

rrrankin left a reply on Pass Variable From Controller To Model's HasMany Relationship • 1 year ago

Thanks @tykus. That works great. I didn't realize that I could place the closure in line like that. So, as an academic exercise, would you mind explaining why you don't agree with the approach? I'm open to learning and doing this differently.

rrrankin left a reply on Pass Variable From Controller To Model's HasMany Relationship • 1 year ago

I had already tried that and receive this error:

Call to undefined relationship [responsesCount($event_id)] on model [App\Models\School]

I came a little closer (I think) by doing this: Event::with(['field', 'schools.responsesCount' => $eventId]) which results in another error, Type error: Argument 3 passed to Illuminate\Database\Eloquent\Builder::eagerLoadRelation() must be an instance of Closure, integer given.

I'm trying to research that now but not understanding how I would convert the responseCount method to a closure.

rrrankin started a new conversation Pass Variable From Controller To Model's HasMany Relationship • 1 year ago

As you can see in the School model, I have hard-coded an event_id of '2' in responsesCount(). This all works as expected and I get the correct response, but obviously this needs to be dynamic. Is there a way to pass a variable (the event id in this case) from the EventController to the School model?

School.php

public function responses() {
        return $this->hasMany(
            Student::class, 'school_id');
    }

public function responsesCount(){
        return $this->responses()
            ->selectRaw('count(students.id) as aggregate, school_id')
            ->where('students.event_id', 2) . // Need to somehow pass dynamic event_id here
            ->groupBy('school_id');
    }

public function getResponsesCountAttribute()
    {
        if ( ! array_key_exists('responsesCount', $this->relations)) $this->load('responsesCount');
        $related = $this->getRelation('responsesCount')->first();
        return ($related) ? $related->aggregate : 0;
    }

EventsController.php

$event = Event::with(['field', 'schools.responsesCount'])
            ->where('team_id', $teamId)
            ->where('event_id', $event_id)
            ->orderBy('event_date', 'desc')
            ->first();

10th May, 2017

rrrankin left a reply on Table Seeder With Random Number Of Related Models • 1 year ago

Thanks @alOmie. saveMany was the key to inserting multiple records and the rand() function helped as well.

9th May, 2017

rrrankin started a new conversation Table Seeder With Random Number Of Related Models • 1 year ago

I have the following code in a UserTableSeeder file.

factory(App\User::class, 12)->create()->each(function($users) {
    $users->posts()->save(factory(App\Post::class)->make());
});

This works as expected, creating 12 user records and a single post record for each of the 12 users.

What I can't seem to figure is how to create several post records for each user, or, even better a random number of post records for each user with a max of 5.

Any suggestions?

13th October, 2016

rrrankin left a reply on Can Someone Explain This Syntax • 1 year ago

Thank you @willvincent !

rrrankin started a new conversation Can Someone Explain This Syntax • 1 year ago

I am looking at the spark to do sample app and in the home.js file there is a delete method as follows

delete(task) {
            this.$http.delete('/api/task/' + task.id);

            this.tasks = _.reject(this.tasks, t => t.id == task.id);
        }

Could someone explain the _.reject syntax? I don't find this in the docs.

27th September, 2016

rrrankin left a reply on Why Does Spark Keep Hitting /coupon/user/{id} With A 404? • 1 year ago

Have a look at https://github.com/laravel/spark/pull/265

Removing abort(404) from the CouponController prevents the error message from displaying in the console. If a coupon is not found for the user, a 404 is thrown. According to @themsaid (https://github.com/laravel/spark/issues/305) this is normal, expected behavior.

rrrankin left a reply on Issues With Google Maps / MapBox In Vue Component • 1 year ago

You might want to check out vue-google-maps. I have used this in a project and it works very well.

https://github.com/GuillaumeLeclerc/vue-google-maps

9th September, 2016

rrrankin started a new conversation Laravel Installer Version • 2 years ago

I am trying to install spark 2.0. The documentation indicate that I should make sure my version of the installer is >= 1.3.4. My current version of the installer is 1.3.3. I tried to run composer global update which tells me there is nothing to update. I also tried removing the installer and running composer global require "laravel/installer". Doing this indicates that version 1.3.4 is being installed, but when I run laravel -V again, it is still at version 1.3.3. Does anyone know how to get version 1.3.4 to install?

31st August, 2016

rrrankin left a reply on Unique Values From Array • 2 years ago

@compmeist - Thanks for replying. I've tried to integrate your solution in every way I know how but still can't get a unique list of zip codes. Would you mind explaining a bit further?

30th August, 2016

rrrankin started a new conversation Unique List Values • 2 years ago

I am creating a list of radio buttons to use as a filter for addresses by zip code. The filter is working, but I don't understand how to create the list of unique value radio buttons from the locations array.

<div class="radio">
  <label>
    <input type="radio" name="zip_code" v-model="zip_code_list" value="all"> All
  </label>
</div>
<div class="radio" v-for="location in locations">
  <label>
    <input type="radio" name="zip_code" v-model="zip_code_list" value="{{ location.zip_code }}"> 
      {{ location.zip_code }}
  </label>
</div>

<hr />

<ul v-for="location in locations | fetchLocationsByZipCode">
  <li>
    {{ location.street_address }}
    {{ location.zip_code }}
  </li>
<ul>

new Vue({
    el: 'body',
  data() {
    var locations = [
      {street_address: '123 Oak', zip_code: '75503'},
      {street_address: '456 Poplar', zip_code: '75503'},
      {street_address: '234 Birch', zip_code: '71854'},
      {street_address: '678 Pecan', zip_code: '71854'},
      {street_address: '285 Maple', zip_code: '75501'},
      {street_address: '965 Walnut', zip_code: '75501'},
      {street_address: '724 Pine', zip_code: '75503'}
    ];
    return {
        zip_code_list: 'all',
      locations: locations
    }   
  },
  filters: {
        fetchLocationsByZipCode: function(locations) {
            if (this.zip_code_list == 'all') return locations;
                return locations.filter(function(location) {
                    return location.zip_code == this.zip_code_list;
      }.bind(this));
        }
    }
});

Here is a fiddle if that is more convenient.

7th July, 2016

rrrankin left a reply on How To Show My Only Blog Who Related With Tags • 2 years ago

You don't need to add anything to your blogs table, but in your blog model, make sure you have something like this:

use Cviebrock\EloquentTaggable\Taggable;

class blog extends Eloquent
{
    use Taggable;
}

rrrankin left a reply on How To Show My Only Blog Who Related With Tags • 2 years ago

You may also want to try this:

$blogs = blog::withAnyTags($slug);

rrrankin left a reply on How To Show My Only Blog Who Related With Tags • 2 years ago

Is blogs model returning any data at all?

dd($blogs)

rrrankin left a reply on Format JSON Data • 2 years ago

OK, I got it. This is what I ended up with:

$commodities = Commodity::groupBy('recv_utime')
            ->where('commodity_code_type', $commodity_code)
            ->selectRaw('recv_utime as recv_utime, round(sum(ap_amount_paid),0) as spend')
            ->orderBy('recv_utime')
            ->get();

        $chart_data = [];

        $commodities->map(function($commodity) use (&$chart_data) {
            $chart_data[] = array_flatten($commodity->toArray());
        });

        return json_encode($chart_data, JSON_NUMERIC_CHECK);

I think part of the issue was making use of a raw query. I'm hitting an Oracle database and that seems to be a bit tricky anyway. So, once I created a model and modified the query the data was returned in a form that allowed the original suggestion from @d3xt3r to function properly. If I'm off on that or if anyone sees some glaring issue, please let me know. It's all a learning process. Thanks to all for helping.

rrrankin left a reply on Format JSON Data • 2 years ago

Thanks all for helping. I am now get error 'Call to a member function map() on array'. I'm guessing because query builder is returning an array and not a collection. Not sure how to get around this.

rrrankin left a reply on Format JSON Data • 2 years ago

This seems to get me a bit closer. At least the square brackets are showing up

$parsedData = array();
        foreach ($orders as $k => $v) {
            $parsedData[] = array(json_encode($v, JSON_NUMERIC_CHECK));
        }
        return $parsedData;

Returns the follwing:

[
    ["{\"utime\":1396414800,\"spend\":13192}"],
    ["{\"utime\":1396501200,\"spend\":2024}"],
    ["{\"utime\":1396587600,\"spend\":12053}"],
    ["{\"utime\":1396933200,\"spend\":293}"],
    ["{\"utime\":1397019600,\"spend\":1133}"]
]

rrrankin left a reply on Format JSON Data • 2 years ago

That removed the additional array brackets, but still returns array keys, curly brackets, and strings instead of numbers.

[
    {"utime":"1396414800","spend":"13192"},
    {"utime":"1396501200","spend":"2024"},
    {"utime":"1396587600","spend":"12053"},
    {"utime":"1396933200","spend":"293"},
    {"utime":"1397019600","spend":"1133"}
]

rrrankin left a reply on Format JSON Data • 2 years ago

Thanks for replying @tomo_pongrac. Your suggestion returns data similar to my original result.

[
    [
        {"utime":"1396414800","spend":"13192"},
        {"utime":"1396501200","spend":"2024"},
        {"utime":"1396587600","spend":"12053"},
        {"utime":"1396933200","spend":"293"},
        {"utime":"1397019600","spend":"1133"}
    ]
]

rrrankin started a new conversation Format JSON Data • 2 years ago

I am tyring return data for use in a Highstock chart but the data being returned is not formatted correctly for the chart. Below is my controller:

$sql = "select (to_date(receipt_date,'YYYY-MM-DD HH24:mi:ss')
                  - to_date('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss')) * 24 * 60 * 60
                  - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))* 3600 as UTIME
                  , ROUND(SUM(ap_amount_paid)) as SPEND
              FROM webapp.mv_purchasing
              WHERE commodity_code_type = 'Steel'
              GROUP BY (to_date(receipt_date,'YYYY-MM-DD HH24:mi:ss')
                  - to_date('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss')) * 24 * 60 * 60
                  - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))* 3600
                ORDER BY (to_date(receipt_date,'YYYY-MM-DD HH24:mi:ss')
                  - to_date('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss')) * 24 * 60 * 60
                  - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))* 3600";
        $orders = DB::connection('oracle')->table(DB::raw("($sql) orders"))->get();
        return $orders;

The data being returned appears as follows:

[
    {"utime":"1396414800","spend":"13192"},
    {"utime":"1396501200","spend":"2024"},
    {"utime":"1396587600","spend":"12053"},
    {"utime":"1396933200","spend":"293"},
    {"utime":"1397019600","spend":"1133"}
]

But I need to return the data like this:

[
    [1396414800,13192],
    [1396501200,2024],
    [396587600,12053],
    [1396933200,293],
    [1397019600,1133]
]

30th June, 2016

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

Thanks again! Moving on to making the start and end dates dynamic!

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

Here is what I - er, you - ended up with. Works perfectly, much more readable, and I've learned more in past hour with you than I've learned on my own in the last three days!!!

<template>

<h4>Orders Booked by {{ category.title }} </h4>

<div v-for="cat in categories">
    <label>
        <input type="radio"
             :value=cat
                         v-model="category"
                         v-on:change="fetchOrdersBooked()">
                         {{cat.title}}
    </label>
</div>

</template>

<script>
    export default {
        data() {
            var categories = [
                { name: 'booked_by', title: 'Agent'},
                { name: 'salesperson', title: 'Salesperson'},
                { name: 'customer_name', title: 'Customer'},
                { name: 'product_family', title: 'Product Family'},
                { name: 'market', title: 'Product Market'}
            ];
            return {
                start_date: '2016-06-29',
                end_date: '2016-06-29',
                categories: categories,
                category: categories[0],
                booked: []
            }
        },
        ready: function () {
            this.fetchOrdersBooked();
        },
        methods: {
            fetchOrdersBooked: function(){

                var url = '/api/orders-booked/'
                        + this.category.name
                        + '/' + this.start_date
                        + '/' + this.end_date;

                var resource = this.$resource(url);

                resource.get().then(function (orders) {
                    this.$set('booked', orders.data);
                }.bind(this));
            }
        }
 }
</script>

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

Ahh! I didn't know I could do that lol! So I've made those changes and now the query is failing. I believe I need to change how this.category is called in var resource of the fetchOrdersBooked method and have tried several variants with no success. Am I on the right track?

FYI, I've also changed picked to category as suggested.

fetchOrdersBooked: function(){
                var resource = this.$resource('/api/orders-booked/' + this.category +
                    '/' + this.start_date + '/' + this.end_date);

                resource.get().then(function (orders) {
                    this.$set('booked', orders.data);
                }.bind(this));
            }

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

OK. I 'almost' see. Still not sure where this bit goes though. I the fetchOrdersBooked method? And what goes into var categories?

var categories = [ ... ];

return {
    categories:categories,
    picked:categories[0]
}

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

I'm sorry, not sure I understand. It looks like you are changing :value from cat.name to cat? When I do that I get this in the console:

app.js:2822 [Vue warn]: Error when evaluating expression "function title() {
            var picked = this.picked;
            return this.categories.filter(function (category) {
                return category.name == picked;
            }.bind(this)).shift().title;
        }": TypeError: Cannot read property 'title' of undefined (found in component: <orders-booked>)

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

@davestewart - I didn't see the edit and now have a working solution! Thanks so much for helping me with this. I wish I could double accept your answer(s)!

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

@davestewart - Got it! I changed

<h1>{{ title }}</h1>

to

<h1>{{ title.title }}</h1>

and all is well!

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

@davestewart - OK, I think I understand the why behind the solution, but it is returning [object Object].

rrrankin left a reply on Setting Checked State For Default Radio Button • 2 years ago

@davestewart - Thanks! This worked perfectly and I also made changes based on your observations and preferences. So here is what I ended up with:

<template>
<div v-for="cat in categories">
    <label>
            <input type="radio"
                                value={{cat.name}}
                                v-model="picked"
                                v-on:change="fetchOrdersBooked()">
                            {{cat.title}}
                 </label>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                start_date: '2016-06-29',
                end_date: '2016-06-29',
                picked: 'booked_by',
                categories: [
                    { name: 'booked_by', title: 'Agent'},
                    { name: 'salesperson', title: 'Salesperson'},
                    { name: 'customer_name', title: 'Customer'},
                    { name: 'product_family', title: 'Product Family'},
                    { name: 'market', title: 'Product Market'}
                ],
                booked: []
            }
        },
        ready: function () {
            this.fetchOrdersBooked('booked_by');
        },
        methods: {
            fetchOrdersBooked: function(){
                var resource = this.$resource('/api/orders-booked/' + this.picked +
                    '/' + this.start_date + '/' + this.end_date);

                resource.get().then(function (orders) {
                    this.$set('booked', orders.data);
                }.bind(this));
            }
        }
</script>

One remaining question though: How would I pass the categories.name to a page title since that would be outside the v-for loop? For example, when radio booked_by is checked, return Agent, salesperson return Salesperson, etc. 

rrrankin started a new conversation Setting Checked State For Default Radio Button • 2 years ago

I have a component that builds a series of radio buttons based on an array. Each radio has a v-on:click event that makes returns data. All this works fine, including loading the default data and the click events are firing and returning the correct data as well. My struggle is that I can't seem to get the default view radio button to a checked state. The data is there, but the button is not checked. If any of the radio buttons are clicked after the initial page load, the appropriate button is checked.

<template>
...
<div v-for="cat in categories">
    <input type="radio" id="{{cat.name}}"
                            value={{cat.name}}
                            v-model="picked"
                            v-bind:value="{name: cat.name, title: cat.title}"
                            v-on:click="fetchOrdersBooked(cat.name)"
                            :checked="picked === cat.title">
          <label for="{{cat.name}}">{{cat.title}}</label>
    ...
</div>

</template>

<script>
    export default {
        data() {
            return {
                start_date: '2016-06-29',
                end_date: '2016-06-29',
                picked: 'Agent',
                categories: [
                    { name: 'booked_by', title: 'Agent'},
                    { name: 'salesperson', title: 'Salesperson'},
                    { name: 'customer_name', title: 'Customer'},
                    { name: 'product_family', title: 'Product Family'},
                    { name: 'market', title: 'Product Market'}
                ],
                booked: []
            }
        },
        ready: function () {
            this.fetchOrdersBooked('booked_by');
        },
        methods: {
            fetchOrdersBooked: function(category){
                var resource = this.$resource('/api/orders-booked/' + category +
                    '/' + this.start_date + '/' + this.end_date);

                resource.get().then(function (orders) {
                    this.$set('booked', orders.data);
                }.bind(this));
            }
        },
        watch: {
            picked: function(name) {
                this.$dispatch('picked', name);
            }
        }
    }
</script>

29th June, 2016

rrrankin left a reply on Computed Total • 2 years ago

@clay - Thanks for sharing this! Sorry for the late reply. I've been travelling. I am going to try to implement this today using your suggestions. Thanks again!

22nd June, 2016

rrrankin left a reply on Computed Total • 2 years ago

Adding this line to the controller seems to have solved my problem. Not sure if this is best practice or not though.

$orders = DB::connection('oracle')->select($sql);
// Added this line
$orders = json_encode( $orders, JSON_NUMERIC_CHECK );

return $orders;

@clay - thanks for pointing me in the right direction!

rrrankin left a reply on Computed Total • 2 years ago

I confirmed your theory and you are right. If my array looks like this, the computed total fails as described above:

[
    {"agent":"Bob", "dollars":"3"},
        {"agent":"Kevin", "dollars":"6"},
        {"agent":"Sally", "dollars":"5"}
]

but removing the quotes from the dollars data works and I get the computed total

[
    {"agent":"Bob", "dollars":3},
        {"agent":"Kevin", "dollars":6},
        {"agent":"Sally", "dollars":5}
]

I'm just not sure how to go about removing the quotes from dollars data and keeping the quotes around the agent data.

rrrankin left a reply on Computed Total • 2 years ago

Thanks @clay. That makes sense, but I'm not sure how to do that. Here is the contoller that is being called by the Vue component. Should I make a change there?

public function agent()
    {
        $start_date = strtoupper(Carbon::now('America/Chicago')->format('Y-m-d'));
        $end_date = strtoupper(Carbon::now('America/Chicago')->format('Y-m-d'));

        $sql = "SELECT BOOKED_BY as AGENT
                    , COUNT(DISTINCT(ORDER_NUMBER)) as ORDERS
                    , ROUND( 100 * ratio_to_report(COUNT(DISTINCT(ORDER_NUMBER))) OVER (), 1) PERCENT_ORDERS
                    , COUNT(DISTINCT(LINE_NUMBER)) as LINES
                    , ROUND( 100 * ratio_to_report(COUNT(DISTINCT(LINE_NUMBER))) OVER (), 1) PERCENT_LINES
                    , SUM(EXTENDED_DOLLARS as DOLLARS
                FROM webapp.orders
                WHERE booked_date between '$start_date' and '$end_date'
                AND ((SUBSTR(order_number,1,1) = '7') or (SUBSTR(order_number,1,1) = '1'))
                GROUP BY BOOKED_BY";

        $orders = DB::connection('oracle')->select($sql);
        return $orders;
    }

rrrankin started a new conversation Computed Total • 2 years ago

I am trying to return a total (sum) of dollars in the footer row of a table. Below is the Vue component. The component works fine in terms of populating the table but the computed property is returning an array instead of a single total.

So, for example, the table rows might contains 3,6,5 and the component returns 0,3,6,5 instead of 14. I hope that makes sense. Thanks in advance for any advice.

<script>
    export default {
        data() {
            return {
                booked: []
            }
        },
        created: function () {
            var resource = this.$resource('/api/orders-booked-product');

            resource.get().then(function (orders) {
                this.$set('booked', orders.data);
            }.bind(this));

        },
        computed: {
            totalDollars: function (){
                var totalDollars = 0;

                this.booked.forEach(function(order) {
                    totalDollars += order.dollars;
                });

                return totalDollars;
            }

        }
    }
</script>
<th class="text-right">{{ totalDollars | currency }}</th>

12th May, 2016

rrrankin left a reply on Vue.js Component Object • 2 years ago

This is what I ended up with (using vue resource). Not sure if v-for is the best way to accomplish this since there will only ever be one record returned, but it seems to work.

'''

${{ book.booked_dollars }}

ORDERS BOOKED TODAY

export default { data: function(){ return { booked: [] }; }, created: function() { var resource = this.$resource('api/ordersBooked'); resource.get().then(function(orders) { this.$set('booked', orders.data); console.log(orders.data); }.bind(this)); } };

'''

11th May, 2016

rrrankin started a new conversation Vue.js Component Object • 2 years ago

I am trying to use a vue.js component to perform an ajax call and return data. The console log outputs this:

[Object]
0
:
Object
__ob__
:
Observer
dollars
:
"265447"
get dollars
:
reactiveGetter()
set dollars
:
reactiveSetter(newVal)
__proto__
:
Object
__ob__
:
Observer
length
:
1
__proto__
:
Array

But I am having trouble understanding how to render the dollar variable in my view template, which currently returns [object Object]. Here is my component file:

<template>
    <div class="dashboard-stat2">
        <div class="display">
            <div class="number">
                <h3 class="font-blue-sharp">${{ booked }}</h3>
                <small>ORDERS BOOKED TODAY</small>
            </div>
            <div class="icon"><i class="icon-basket"></i></div>
        </div>
    </div>
</template>

<script>
    export default {
        data: function(){
            return {
                booked: []
            };
        },
        created: function() {
            $.getJSON('api/ordersBooked', function(orders) {
                console.log(orders);
                this.booked = orders;
            }.bind(this));
        }
    };
</script>

27th April, 2016

rrrankin left a reply on 2 Laravel Projects And Homesteads One Machine • 2 years ago

You only need one homestead.yaml file. Your projects should all be under one main folder, for example:

LaravelPojects
    Project1
    Projects2

Then your homestead.yaml file should reference both projects

folders:
    - map: ~/LaravelProjects
      to: /home/vagrant/Code

sites:
    - map: myproject1.laravel.dev
      to: /home/vagrant/Code/myproject1/public

    - map: myproject2.laravel.dev
      to: /home/vagrant/Code/myproject1/public

Each Laravel folder will have it's own .env file, but that is for the Laravel framework, not homestead

26th April, 2016

rrrankin left a reply on Ln -s /path/to/storage/app/public /path/to/public/storage • 2 years ago

I finally figured this out. I am using Vagrant/Homestead on a Windows host. The command is failing from within the homestead vm because it cannot create the symlink on the windows file system. I found a Windows Sysinternals utility called Junction (https://technet.microsoft.com/en-gb/sysinternals/bb896768.aspx) and used it to create the symlink (er, Windows Junction) as follows. The junction executable, in my case, was copied to the C: root, then:

C:\>junction "C:\path\to\project\public\storage" "C:\path\to\project\yardsales\storage\app\public"

Junction v1.06 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

Created: C:\path\to\project\public\storage
Targetted at: C:\path\to\project\storage\app\public

Gave my spark page a refresh and now I can see user images.

rrrankin left a reply on Creating Google Map Markers From AJAX Data • 2 years ago

Yes, I see a reference to the wiki but the link is missing.

rrrankin left a reply on Ln -s /path/to/storage/app/public /path/to/public/storage • 2 years ago

I can't seem to get this to work at all (using vagrant/homestead). This command:

vagrant@homestead:~/Code/yardsales/storage/app/public$ ln -s ~/Code/yardsales/storage/app/public ~/Code/yardsales/public/storage

returns:

ln: failed to create symbolic link ‘/home/vagrant/Code/yardsales/public/storage’: Operation not supported

22nd April, 2016

rrrankin left a reply on Creating Google Map Markers From AJAX Data • 2 years ago

Yes, but I couldn't get it working either nor could I find any documentation on it.

21st April, 2016

rrrankin started a new conversation Creating Google Map Markers From AJAX Data • 2 years ago

I am attempting to populate a google map with markers from an ajax call. In the view, I can render a list and a map with no makers. I have a date selector in the view and when I change the date, the list is updated, but still no markers on the map. So, basically, vue is getting the data (which includes lat and lon) and basically everything is working except getting the markers on the map.

Here is the Vue script .

$(document).ready(function() {
        $('#eventDate').datepicker({
            todayHighlight: true,
            format: 'yyyy-mm-dd',
            autoclose: true
        });
    });

    Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').value;

    Vue.component('events', {
        template: '#events-container',
        data: function(){
            return {
                list: []
            };
        },
        created: function(){
            this.fetchEvents();
        },
        methods: {
            fetchEvents: function(date) {
                if (! date ){
                    var date = moment().format('YYYY-MM-DD');
                }
                var resource = this.$resource('api/events/{event_date}');
                resource.get({event_date: date}, function(events){
                    this.list = events;
                }.bind(this));
            },
            createMap: function(){
                this.map = new google.maps.Map(this.$els.map, {
                    center: { lat: 33.425946, lng: -93.910193},
                    zoom: 10
                });
                return new google.maps.Marker({
                    map: this.map,
                    position: { lat: events.location.latitude, lng: events.location.longitude}
                });
            }
        },
        events: {
            MapsApiLoaded: function(){
                this.createMap();
            },
            'datechanged': function(date) {
                this.fetchEvents(date)
            }
        }
});

var app = new Vue({
        el: 'body',
        data: function(){
            return {
                event_date: ''
            };
        },
        methods: {
            init: function(){
                this.$broadcast('MapsApiLoaded');
            },
            dateChanged: function() {
                this.$broadcast('datechanged', this.event_date)
            }
        }
    });

And the View

<input id="eventDate" v-model="event_date" :change="dateChanged()">

<component is="events"></component>

<template id="events-container">
    <div class="col-md-8">
        <div>
                    <div id="map" v-el:map style="width: 100%; height: 350px;"></div>
                </div>
    </div>

      <div class="col-md-4">
        <h3 v-if="list.length">@{{ list.length }} Events</h3>
                <h3 v-if="!list.length">There are no events on this date.</h3>
        <ul class="c-content-list-1 c-theme c-separator-dot">
                    <li v-for="scheduled in list">
                                <span class="date">
                                    @{{ scheduled.event.location.latitude }}, @{{ scheduled.event.location.longitude }}
                                </span>
            </li>
        </ul>
    </div>
</template>

17th April, 2016

rrrankin left a reply on Spark Installer Error On Homestead • 2 years ago

THANK YOU!!! I've been trying to figure this out for several hours!

13th April, 2016

rrrankin left a reply on Using Vue To Refresh AJAX Data • 2 years ago

@ratiw - Thanks! This solutionworked perfectly!

12th April, 2016

rrrankin started a new conversation Using Vue To Refresh AJAX Data • 2 years ago

I am trying to use a date picker component to fetch ajax data via a Laravel route. On initial page load, data is being fetched from the db via the route and all is working. When I select a new date, @{{ event_date }} in

is updated with a new date from the component but I just don't understand how to pass the selected date to the fetchEventList method and load the new data. I may be approaching this all wrong so if anyone could provide some direction I would really appreciate it!

Blade

<input id="eventDate" v-model="event_date">

<h1>Events on @{{ event_date }}</h1>

<events></events>
                    
<template id="events-container">
    <ul class="list-group">
        <li class="list-group_item" v-for="scheduled in list">
                <span class="date">@{{ scheduled.event_date }}</span>
        </li>
    </ul>
 </template>

Route

Route::get('api/events/{event_date}', 'ApiController@getEvents');

Script

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.21/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/0.7.0/vue-resource.min.js"></script>
<script>
        Vue.component('events', {
            template: '#events-container',
            data: function(){
                return {
                    list: []
                };
            },
            created: function(){
                this.fetchEventList();
            },
            methods: {
                fetchEventList: function() {
                    var today = moment().format('YYYY-MM-DD');
                    var resource = this.$resource('api/events/:event_date');

                    resource.get({event_date: today}, function(events){
                        this.list = events;
                    }.bind(this));
                }
            }
        });

        new Vue ({
            el: 'body',
            data: {
                event_date: moment().format('YYYY-MM-DD')
            }
        });
    </script>

26th February, 2016

rrrankin left a reply on Check If User Is Verified Before Resetting Password • 2 years ago

Thanks a lot for your help @BrennanHoeting! I think I have everything refactored and working properly now.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.