ZetecVan

Experience

29,090

10 Best Reply Awards

  • Member Since 4 Years Ago
  • 286 Lessons Completed
  • 8 Favorites

20th February, 2018

ZetecVan left a reply on `spark New` No Longer Works For V5 • 7 months ago

I had this last night. That is exactly what I did to fix.

22nd December, 2017

ZetecVan started a new conversation How Do You All Configure Your Mailboxes? • 8 months ago

I've just gone live with a side project. Site emails go through Mailgun. I want to be able to configure a mailbox so I can receive emails. At the moment I have a couple of Routes set up within mailgun to route them to a gmail account. This isn't ideal for me and would like to have a mailbox I can log into to pick up and send emails from that domain.

Someone suggested using Migadu, so I've looked into that and it looks ideal. But the question is, how do I configure Mailgun and/or my DNS Records so I receive mail into Migadu?

Or am I doing this wrong and there's a better solution.

23rd November, 2017

ZetecVan started a new conversation Queues - Redis/Horizon Vs Beanstalkd • 9 months ago

My project requires me to parse an xml file, and store the data in a couple of mysql tables. While developing, I've been using Beanstalkd to fire a job to store each xml 'record' and then once all the xml has been parsed, I've read that table, firing off a job to update other records/tables based on that record.

It runs quite smoothly, although can take a while because of the number of records.

Tonight I thought I'd give Horizon and Redis a go. I switched it out and triggered the job to parse. That went through quicker than Beanstalkd. Then it automatically triggered the rest of the processing. It processed the first record, and then just sat there for about five minutes. I was checking everything to see why when the next job kicked in.

So instead of each job taking just a second, they're taking a random time from a second to a minute or so. All the job is doing is reading the parsed record and updating a couple of existing records or creating a couple of new ones.

Has anyone else experienced this sort of behaviour?

9th November, 2017

ZetecVan left a reply on Gatekeeper • 10 months ago

But what's it for....?

3rd October, 2017

ZetecVan left a reply on Importing Large CSV Or TXT Files • 11 months ago

There is this that will help you import CSVs: http://www.maatwebsite.nl/laravel-excel/docs/import

I've not worked with it, although I did look at it for something I was going to do.

One of my projects imports an XML file with 26,000 rows. For that I parse the XML, and read though it. For every record I fire off a job that saves it to the database. It only takes a few seconds for the 26000 rows to be read, then the records are saved in the background.

28th September, 2017

ZetecVan left a reply on What Music Do You Listen To When You're Programming? • 11 months ago

Just like @mcstepp I tend to listen to stuff I don't know, usually with no words, so I don't get distracted and start singing/humming along. Quite often it's classical music, or piano. A few of Spotifys 'Concentration' type playlists are terrible, and repetitive.

22nd September, 2017

ZetecVan started a new conversation Component Within A Component Props • 11 months ago

I have created a 'like' component, which is passed a prop of the id of the thing being liked, and whether it is currently liked. It works when it's stand alone, but when I put it within another component, it doesn't work out whether it's already liked. Here's the code for the component.

        <favorite
            :post={{ $post->id }}
            :favorited={{ $post->favorited() ? 'true' : 'false' }}
        ></favorite>

I think my issue is that the parent component does an axios call to an internal api, and that returns whether it's liked or not (amongst other things). I put a console.log in the child components mounted method to output the value of 'favorited' prop, and it returns undefined, however, looking at that same prop in Chrome Vue Tools, it's populated properly.

<script>
    export default {
        props: ['post', 'favorited'],

        data: function() {
            return {
                isFavorited: '',
            }
        },

        mounted() {
               console.log(this.favorited)        // Returns undefined
           this.isFavorited = this.isFavorite ? true : false;
        },

        computed: {
            isFavorite() {
                return this.favorited;
            },
        },

        methods: {
            favorite(post) {
                axios.post('/favorite/'+post)
                    .then(response => this.isFavorited = true)
                    .catch(response => console.log(response.data));
            },

            unFavorite(post) {
                axios.post('/unfavorite/'+post)
                    .then(response => this.isFavorited = false)
                    .catch(response => console.log(response.data));
            }
        }
    }
</script>

It's as if the component is mounted, before the parent component is fully loaded. Does anyone know how to solve this?

8th September, 2017

ZetecVan left a reply on Best Way To Deal With Public API Routes • 1 year ago

Are your api routes using the auth:api middleware? Is the api designed to be publicly accessible or is it only for logged in users?

The api for my app is only to be consumed by vue. Some of the fields in the transformers are only available to logged in users, so I created a new middleware (based on the auth middleware) that still allows non-logged in users to consume the api, but with "Log In" returned against some fields.

ZetecVan left a reply on Always Free Plan (no Trial), But With Possibility To Subscribe To Paid Plans • 1 year ago

This is something I'll need to do in the future. I'm coding my app and haven't given thus much thought as I assumed it would be possible.

Why can't a user upgrade to a paid plan if they choose the free initially?

ZetecVan left a reply on Vue Laravel And Laravel Passport • 1 year ago

I have started using Passport on my latest project.

I have created one Laravel App. I am creating API endpoints (with the routes in the API routes file, in the Auth & API middleware group).

These are consumed by the VueJS front end. It allows me to be able to determine the signed in user without having to create tokens that would be used if I was using an external client to access the api. (details at the end of the passport install page: https://laravel.com/docs/5.5/passport)

So the answer is, no you don't need to create two different web apps.

1st September, 2017

ZetecVan left a reply on I Have A Technical Laravel Test • 1 year ago

Congratulation! Nice work on the app.

31st August, 2017

ZetecVan left a reply on I Have A Technical Laravel Test • 1 year ago

How long did you get to do the test? Did you complete it? And did you have access to the internet?

22nd August, 2017

ZetecVan left a reply on Package Recommendation, Wordpress Like Settings In Laravel ? • 1 year ago

Laravel Voyager is a back end admin package that allows you to set up configuration options. Take a look at that.

https://laravelvoyager.com/

18th August, 2017

ZetecVan left a reply on Where To Store Settings Data • 1 year ago

I would probably use the cache.

https://laravel.com/docs/5.4/cache

Cache::put('key', 'value', $minutes);

and

Cache::add('key', 'value', $minutes);

11th August, 2017

ZetecVan started a new conversation Queues, Events And Status Updates • 1 year ago

I am developing a web app where a user will has a list of jobs on his dashboard. These jobs run periodically on a queue, or can be triggered manually with a button. I have a 'Last Run' column. When the job is running I want to be able to change the value to 'Running'. When it finishes, i want to be able to broadcast a message to that user and update the Last Run date and time.

I am ok with the broadcast message. I need to get my head round how to update the job status value when it's running. (I'm not necessarily after code, just 'do this, then this then this' will be fine). Polling the database every few seconds for the status would be inefficient, so what alternatives are there?

I'm using Laravel 5.4 and Vue 2.0.

13th June, 2017

ZetecVan left a reply on Strange Behaviour When Migrating • 1 year ago

I can be stupid lots of times in one day when it comes to code... :-)

6th June, 2017

ZetecVan left a reply on Broken Link • 1 year ago

Ah yes. All the links on the top of the page go to Google.

30th May, 2017

ZetecVan left a reply on Socialite Connect Multiple Social Accounts With Different Emails • 1 year ago

This is something I will have to be doing for a project I'm planning. Once you've linked one social account, are you logging the user in? If so, any future social accounts that are linked can be linked to the currently logged in user.

26th May, 2017

ZetecVan left a reply on Polymorphism: Why Should I Violate Database Design? • 1 year ago

This thread was started a year ago. Hopefully @tylernathanreed has found a solution.

12th May, 2017

ZetecVan left a reply on Laravel Frustration • 1 year ago

I'm glad you're all coming out as old. I'm 47 was was beginning to think I was the oldest here.

ZetecVan left a reply on Laravel 5.4 - How To Create Separate Login For Admin And User • 1 year ago

Also, look for the Laravel Voyager extension. That provides an admin login and panel.

19th April, 2017

ZetecVan left a reply on API Authentication • 1 year ago

So I take a break for ten minutes and it comes to me.

Change the middleware in routes/api.php to just api.

Then in the transformer method,

        if ( Auth::guard('api')->user()) {
            // additional data goes here.
        }

ZetecVan started a new conversation API Authentication • 1 year ago

I have an API which I need to work for non-authenticated users, but if the user is authenticated, to return extra information.

I am using Laravel 5.4, Spark, and have installed Fractal for transformers.

My API routes are

Route::group([
    'middleware' => 'auth:api'
], function () {

    Route::get('/categories/{categorySlug}/{subcategorySlug?}', 'API\[email protected]'); // Gets file

});

So for a logged in user this returns the right results. For a non-logged in user I get "Unauthenticated".

I can't put the Route::get outside the Route::group closure as it doesn't run the auth to get the user.

Is the solution to create some new middleware to replace the auth?

17th April, 2017

ZetecVan left a reply on Passport Returns An Empty User For Authenticated User • 1 year ago

Ok so I created a new laravel project, did the auth scaffolding, installed Passport, did the api call and it worked as expected.

So then I installed Spark, and it stopped working. It's doing the same as above. So the cause is within spark...

ZetecVan started a new conversation Passport Returns An Empty User For Authenticated User • 1 year ago

I'm creating an internal API that needs to know if a user is authenticated or not. I'm using Laravel 5.4 and Spark 4.0. I've installed Passport as per the docs.

There is a video I found (https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/13) where Taylor explains Passport. About 3/4 through he explains about consuming your own API for authenticated users. I've followed that, but am getting an empty response from the return $request->user() part, even though I'm logged in.

Here's some code:

Route::group([
    'middleware' => 'auth:api'
], function () {

     Route::get('/user', function() {
         return['username' => 'test'];
     });
});

Route::get('/user', function (Request $request) {
    return $request->user();
});

So it's not authenticating via the middleware auth:api, and it's hitting the /user outside the middleware closure.

In my vuejs component I have

<script>
    export default {
        mounted() {
            console.log('Component mounted.')
        this.$http.get('/api/user')
            .then(response => {
                console.log(response.data);
            });

        },
        ready(){
        }
    }
</script>

and in my App.js I have

Vue.http.headers.common['Accept'] = 'application/json';
Vue.http.headers.common['X-CSRF-TOKEN'] = Spark.csrfToken;

I can see through Chrome Devtools that there is a Cookie:laravel_token as explained in the video, but my reponse.data is empty.

Can anyone help?

16th April, 2017

ZetecVan left a reply on Consuming An Internal API With Spark. • 1 year ago

Thanks @cronix. I thought it was that one before I asked, but it's not. I'm sure in the one I was thinking of he did something in the controller to show whether it was authenticated or not. Like a Auth::user().... although I could be imagining the whole thing...

ZetecVan started a new conversation Consuming An Internal API With Spark. • 1 year ago

I am using Vue Tables 2 to call an internal API to list some data. I want the API to retrieve more data for logged in users (ie: some values are to be unavailable to non-logged in users, to encourage them to sign up).

In the Spark docs there is this:

Spark makes it entirely painless to consume your API in this way. Simply make requests to your > API routes using your JavaScript framework as normal. You do not need to pass any token or credentials. All of the authentication will be handled automatically by Spark, which generates "transient", short-lived API tokens behind the scenes automatically when users load your application's pages. These API tokens are automatically refreshed in the background by Spark.

I remember seeing a video a while ago where (I think) Taylor demonstrates this functionality. Can anyone point me in the direction of the video, or suggest any way to do this.

1st April, 2017

ZetecVan left a reply on How To Store Nested Json To Database? • 1 year ago

Is it a mySql type relational database, and you're wanting to store each value to a different field?

If not, and you want to store that object in a single field, you can just populate the field you want to save it in by:

$table->field =  serialize(json_decode($json_object);

then saving it. However that's probably not ideal.

22nd March, 2017

ZetecVan left a reply on How To Import An Existing Database • 1 year ago

If you have an existing database, you don't need to do the migrations. You could just point the env details to the database you want to use.

However, I'd probably create a new database and the tables using migrations, and then export the data from the existing database using MySQL Workbench and import it into the new database, because I'm ocd like that.

ZetecVan left a reply on Saving Twice To Database • 1 year ago

@Shiva Are you wanting the Ajax to POST the form. If you add that $.ajax call back in, and add event.preventdefault(); after the $(".add-form").submit(function(event){ line, it will stop the form being submitted through the html.

ZetecVan left a reply on Saving Twice To Database • 1 year ago

You won't need the

if($validation->passes()){

because the failure has already done a return, so if it gets to that point it must have passed.

If you comment out the sync line, does it only save it the once?

3rd March, 2017

ZetecVan left a reply on Vue Does Not Work • 1 year ago

I had a frustrating issue with a component I created the other day. I can't remember what the exact message was, as I'd had the 'are you sure you've registered' message during debugging.

It turned out, I hadn't closed a

tag in the line before <my-component>.

27th February, 2017

ZetecVan left a reply on L5.4 Styles Is Not A Function • 1 year ago

Ok, so I have found out that there's a function .combine that works.

https://mattstauffer.co/blog/introducing-laravel-mix-new-in-laravel-5-4

ZetecVan started a new conversation L5.4 Styles Is Not A Function • 1 year ago

I'm migrating a 5.3 app to 5.4. When running npm run dev, I get

/home/michael/Code/oispark/webpack.mix.js:36
    .styles([
     ^

TypeError: mix.styles is not a function

This is my css section:

mix.styles([
        'resources/assets/css/font-awesome.css',
        'resources/assets/css/styles.css',
        'resources/assets/css/custom.css',
        'resources/assets/css/responsive.css',
    ], 'public/css/styles.css');

There's nothing in the docs that say you have to do anything else: https://laravel.com/docs/5.4/mix#plain-css

Does anyone have any ideas?

24th February, 2017

ZetecVan left a reply on Nested Resource : Missing Required Parameters • 1 year ago

I think your blade route should be an array if passing multiple parameters.


<li><a href="{{ route('admin.startups.usecases.show',["startup_id" => $startup->id, "usecase_id" => $usecase->id]) }}">Show</a></li> 

ZetecVan left a reply on Nested Resource : Missing Required Parameters • 1 year ago

I think it's the order your routes are appearing.

|        | DELETE    | admin/startups/{startup}                         | admin.startups.destroy          | App\Http\Controllers\[email protected]                             | web,admin,auth:admin |

appears above

|        | DELETE    | admin/startups/{startup}/usecases/{usecase}      | admin.startups.usecases.destroy | App\Http\Controllers\[email protected]                             | web,admin,auth:admin |

So when it's looking for a route, it finds the one with one parameter first.

Try manually adding the show, edit and delete routes for the startups manually above the resources just to see...

Route::get(admin/startups/{startup}/usecases/{usecase}', '[email protected]')->name('admin.usecases.show');

ZetecVan left a reply on So I Have An Issue With Nested Foreach Loops.. • 1 year ago

No problem! Glad it's sorted.

23rd February, 2017

ZetecVan left a reply on So I Have An Issue With Nested Foreach Loops.. • 1 year ago

This should work

    foreach($sales['product_id'] as $key => $value)
    {
      if( !empty($sales['cookies'][$key] ) ){
        $invoice->products()->attach( $product_id, ['qty_sold' => $sales['cookies'][$key] );
     }
    }

ZetecVan left a reply on So I Have An Issue With Nested Foreach Loops.. • 1 year ago

I think the problem is that you're reading though the $sales array.

Try

// Save the record.
        $invoice->save();

        // Now input the product sold and the quantity into the pivot table..
        foreach( $sales['product_id'] as $product_id ){          
                if( !empty($sales['cookies'] ) ){
                    $invoice->products()->attach( $product_id, ['qty_sold' => $sales['cookies'] );
                }
        }

21st February, 2017

ZetecVan left a reply on Upgrading A Messy 4.2 App To 5.4 • 1 year ago

I'm currently migrating an old 4.2 app (with no tests) to 5.4.

I'm taking @ohffs method of migrating most of the code and re-writing the payments part, as it's now going to be using Spark instead of using Paypal (which was a nasty way to do it)

14th February, 2017

ZetecVan left a reply on Get Latitude And Longitude Dynamiclly From Database • 1 year ago

I came across this tutorial yesterday, as I'll be planning on doing something similar soon.

http://www.piedcode.com/tutorial-creating-a-webapp-with-google-maps-and-laravel/

It uses a javascript library that the guy wrote.

10th February, 2017

ZetecVan left a reply on Multitable Forms/Inline Editing • 1 year ago

Thank you @christianTorino, that is very useful. I'll have a proper look at in in a while.

Ciao

8th February, 2017

ZetecVan started a new conversation Multitable Forms • 1 year ago

Hi all

I have an existing app that I'm re-writing to use vuejs to make the user experience a bit more slick. The app lists businesses, along with their address, opening times, photos, tags and contact details. Each of these elements are in their own table.

It's all currently maintained by me in the admin section. Each table has their own form. I'm re-writing it to use vue and let the customer maintain it.

I'm thinking about attempting to use in place editing. ie: It shows the business as it would on the front end of the site, and if they hover over an editable field it allows them to click it and it becomes editable.

Does anyone have any experience of doing this in vuejs? Can anyone point me in the right direction? Or does anyone have any alternative suggestions?

Cheers

ZetecVan left a reply on Codeigiter To Laravel • 1 year ago

I ended up recoding an old Codeigniter project from scratch. It highlighted how bad I coded back then...

1st February, 2017

ZetecVan left a reply on Custom Permalink Per Article • 1 year ago

There is also a package called Sluggable which will handle the sluggifying for you.

https://github.com/cviebrock/eloquent-sluggable

18th January, 2017

ZetecVan left a reply on Laravel Homestead - Installation - Timeout • 1 year ago

For anyone who is having the same problem, but the solution above doesn't solve it (like in my case), you could try adding

config.vm.provider :virtualbox do |vb|
  vb.gui = true
end

to your vagrantfile. This fixed it when I was having problems recently.

20th December, 2016

ZetecVan left a reply on Blade Template Just Not Working • 1 year ago

I had this happen with me, and after hours of trying I couldn't it out, so created a new project (laravel new project) and put the code in there and everything worked ok. As @ejdelmonico says, it may be a bad install.

16th December, 2016

ZetecVan left a reply on Notification Bug • 1 year ago

I noticed that earlier today too

ZetecVan left a reply on Should This Code Be In The Controller? (google Charts Back-end) • 1 year ago

@OhFFS, I think it's my crowning achievement. I came up with a solution that someone else thinks is the way to do it!

ZetecVan left a reply on Should This Code Be In The Controller? (google Charts Back-end) • 1 year ago

I'm using consoletvs/charts for a project and I'm using presenters. There are multiple charts per page, but all the same style. I can't show you the actual code (as I don't have it to hand) but basically the controller just gets the data.

Then in the view I have

$product->present()->chart1;
$product->present()->chart2;
$product->present()->chart3;

The chart1/2/3 in the presenter are just wrappers to call a private function in the presenter which calls consoletvs/charts with the data.

I can show you the actual code in a few hours when I'm in front of my dev machine.

Edit Your Profile
Update

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