andyg1

andyg1

Member Since 5 Years Ago

Experience Points 13,070
Experience Level 3

1,930 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 276
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.

26 Apr
1 year ago

andyg1 left a reply on How Can I Display A Holding Page For All Requests?

Thank you. I knew it can't have been complicated. It was a case of getting the regex correct.

andyg1 started a new conversation How Can I Display A Holding Page For All Requests?

Preface: it's Laravel 4.0

I want to stop all access to the site and display a single holding page for requests.

I would have thought I could put something at the top of my routes file to make all requests return a single view....

andyg1 left a reply on What Role Does The Migration Table Have?

FTW:

  • the filenames in the migrations folder are checked against the names in the 'migration' column of the DB table. This identifies what needs to be run in the next batch.

  • the batch number is incremented each time a migrate command is run. Any new files in the migrations folder will now entered into the DB table, with a batch number incremented by 1. E.g. if there were two new files, their batch number would both be e.g. 3 (if the last batch was 2)

  • the rollback command will "undo" the most recent, i.e. highest batch number. It calls the "down" method on the migration file. You can specify the number of batches to rollback

Things I've learned: If a migration fails, you need to identify what happened to the database entry. If an entry was created, but the operation failed, then you may have to remove some (or all) rows in the migrations table.

06 Apr
1 year ago

andyg1 left a reply on Route Model Binding - Optional RouteKeyName

Agreed @martinbean - their way introduces a dependency (the URL prefix) into the model. I'd rather keep responsibilities separate and have route logic where it belongs. Your suggestion is cleaner. Thanks

05 Apr
1 year ago

andyg1 started a new conversation Route Model Binding - Optional RouteKeyName

On my front-end I am using the slug field to access the objects e.g.

site.dev/slug-of-title/

and have set it using the getRouteKeyName() method.

On my admin side of the site, I am building the CRUD pages for all these things. I wanted my URLs to be the simple ones e.g.

site.dev/admin/object/1
site.dev/admin/object/3/edit

etc

But the system is still expecting to access the resource from the slug, not the id.

Is it possible to optionally override this so I don't have the slug-ified URLs for my admin section?

(I should state that I am using resource controllers...) Thanks

28 Mar
1 year ago

andyg1 left a reply on Resource Routes, Route Model Binding, And Inheritance

To answer my own question, it seems there seems to be a way this can be done without violating the Liskov Substitution Principle, as per this discussion:

https://stackoverflow.com/questions/36079651/silence-declaration-should-be-compatible-warnings-in-php-7/36081214

where you can declare you child class methods as such:

public function index(User $user = null)

I am not about to pass judgement on the elegance nor best-practices of this approach, but it gets me through the block I was having...

andyg1 left a reply on Resource Routes, Route Model Binding, And Inheritance

@Helmchen

which should be handled by the model itself and/or a dedicated Filter, not the controller :)

Fair point, but probably overkill for the size of the thing I am working on.

andyg1 left a reply on Resource Routes, Route Model Binding, And Inheritance

Further reading indicates that what I thought was possible actually isn't in PHP, and has been made strict in PHP7:

https://laracasts.com/discuss/channels/laravel/controller-inheritance

andyg1 left a reply on Resource Routes, Route Model Binding, And Inheritance

If the index view for PostController and UserPostController have some filter tools e.g. for ordering by date, filtering by year, etc. Then that is shared logic between the controllers.

andyg1 started a new conversation Resource Routes, Route Model Binding, And Inheritance

Assume two resource routes such as this:

Route::resource('/posts', 'PostController');
Route::resource('/{user}/posts', 'UserPostController');

Clearly the two controllers will share some logic e.g. the delete method. As well as any helper methods I have in my PostController.

I am using Route Model Binding to automagically resolve the User model for use in the second set of resource routes. I would like the UserPostController to inherit from the PostController. But, if I extend the parent the child class methods are now incompatible with the parent, as illustrated here:

public function index() // from the PostController

and

public function index(User $user) // from the UserPostController (incompatible with parent)

My question is, how can I best make use of resource controllers, inheritance and the Route Model Binding without duplicating loads of code or redefining loads of methods?

Thank you

23 Mar
1 year ago

andyg1 left a reply on Accessing Just The Name Of The Resource, Not The Whole Named Route

For those still interested in this thread....

I had to take it a step further to cover cases where you might have:

foo.bar.index

for example if you have added the "as" => "foo" flag to your resource route, which prepends the value.

Instead of using the array_first as suggested above, I had to explode, slice and then implode the parts. I couldn't see another why of doing that.... so, in addition to the getResourceName() method, I'd like to see an array_not_last helper too. (Unless there is a way already)

andyg1 left a reply on Accessing Just The Name Of The Resource, Not The Whole Named Route

Okay, I think I have arrived at the solution with your help. Thank you!

Using your approach, I included the variable with View::share in the constructor of my parent controller.

This strikes me as something that would be useful in the core, no? Most of the methods are already there.

Then it could be used something like: request()->route()->getResourceName()

andyg1 left a reply on Accessing Just The Name Of The Resource, Not The Whole Named Route

Thanks. Yes, that's certainly a way of achieving it. That introduces a dependency though, doesn't it?

If I decide to change the name of my route resource i.e the URL, then I also have to update the variable definition in the controller.

I would have hoped (and assumed) there was a more elegant way of doing it.

22 Mar
1 year ago

andyg1 started a new conversation Accessing Just The Name Of The Resource, Not The Whole Named Route

I have two controller classes, one which extends the other. They share some views in common. I want to be able to generate links in the views conditionally on which controller is serving that view, to avoid duplication of code.

Assume that both controllers are resource controllers, and have names MyController and MySubController, such that they have named routes:

mycontroller.index
mycontroller.show
...
mysubcontroller.index
mysubcontroller.show
....

Then I wondered if I could use something similar to this in the code for the view:

route('{resourceName}.index')
route('{resourceName}.show', [...])

And it will resolve to the correct controller in the link. Or a better way of achieving it. Thanks.

12 Mar
1 year ago

andyg1 left a reply on Composer Create-project Gives [ErrorException] Mkdir(): Permission Denied

One way I have found of making this work is to come out of the Vagrant console (i.e. log out of the SSH connection) then to create the directory in the native file system (in this case macOS) then reprovision the Vagrant box (which has the new folder as one of its configured folders to serve) and then login again with the SSH and run the create-project command again.

andyg1 left a reply on Composer Create-project Gives [ErrorException] Mkdir(): Permission Denied

Is that really the right thing to do? Seems like a sledgehammer and nut solution.

andyg1 started a new conversation Composer Create-project Gives [ErrorException] Mkdir(): Permission Denied

I am SSHed into the vagrant homestead machine and am trying to create a new laravel project with the create-project command. I receive the mkdir() Permission denied error.

The folder I am in has the owner and group of vagrant. Is this because composer does not have the right permissions?

09 Mar
1 year ago

andyg1 started a new conversation What Role Does The Migration Table Have?

What gets stored in the migrations table, and how does Laravel use it to determine the migration status?

Additionally, what specifically do the commands refresh, reset and rollback have on that table?

(The reason I ask is for when I might need to recover from a migration operation that has failed part way through...)

Thank you

andyg1 started a new conversation Is It Sensible To Go To 5.6?

I am tasked with upgrading a legacy system (v4.0) to at least a version with documentation and LTS. (I am not worried about the fact this will be a significant refactor!)

My question is what version to go to? I'd like to go to 5.6 but I also want to take advantage of: existing packages, such as admin dashboards; tutorials; general support (Stackoverflow, etc)...

What are people's thoughts? Pros and cons?

19 Oct
1 year ago

andyg1 left a reply on Changing The Order Of Route Parameters When Passing To The Controller Method

@Dunsti this is was what I wanted to do, I just didn't know what the correct syntax was. Much appreciated. Thanks :)

13 Oct
1 year ago

andyg1 started a new conversation Changing The Order Of Route Parameters When Passing To The Controller Method

Assume I have routes:

/list/{bar}
/{foo}/list/{bar}

Where the second is more specific. And I have two controllers, BarController and FooBarController, where the latter extends the former for shared functionality.

Now, my understanding the route parameters is that they are passed to controller methods in the order they appear in the ULR parameters i.e.

for [email protected] the method will look like this:

function edit($foo_param, $bar_param)

what I'd like to do is have this edit method declared in the parent BarControlller only, but that requires something like this:

'function edit($foo_param = null, $bar_param)`

which won't work - because of the order the parameters, $foo_param will never be null. What I want to do is flip the order of the parameters, so I have behaviour like this:

function edit($bar_param, $foo_param = null)

without changing the URL format.

Is it possible to manipulated the variables before sending them to the controller? Perhaps with a closure or something?

Thanks!

04 Oct
1 year ago

andyg1 left a reply on Grouping Controllers And Sending Parameters To Views

The way I have begun to tackle this is:

  • defining routes that match the pattern I need
  • all these matching routes go through the one generic controller
  • generic controller handles the generic views

The concept I am struggling with now is how to define the array of settings. Where should this be defined? In the generic controller? As some sort of global config?

Each time this controller is used, I need to check that the segment(1) of the URL is valid i.e. exists in the setting array. How is this best achieved?

I should say I am using Laravel 4.0 (don't ask!!).

03 Oct
1 year ago

andyg1 started a new conversation Grouping Controllers And Sending Parameters To Views

I've inherited a system that has a lot of duplication of code. All the controllers and views are 95% the same.

The routes are along the lines of:

/abc/create /abc/edit

/def/create /def/edit

/ghi/create /ghi/edit

The principle difference in the controllers is that they pre-condition DB queries with a WHERE column_name = abc (for example)

The principle difference in the views is that have different titles, different navigation, target URLs for forms, etc

To me, it makes sense to use the URL parameter to pass a parameter to a standard controller, which then passes the parameter to a standard view. The parameter isn't just a single dimension though. It might be more like:

[
'abc' => array(
    'url' => 'abc',
    'short_title' => 'ABC',
    'long_title' => 'A big cat'
),
'def' => array(
    'url' => 'def',
    'short_title' => 'DEF',
    'long_title' => 'Dogs eat fish'
),
...
]

How would I go about using the URL and grouped routes to 1) detect the initial "section" and 2) get the associated variables to the view from, perhaps, a multidimensional array, as described above.

Thanks for your help.

10 Aug
2 years ago

andyg1 left a reply on Best Website For Displaying My Portfolio

Thanks for the input. I am just going to upload some screenshots to my LinkedIn profile.

07 Aug
2 years ago

andyg1 left a reply on Best Website For Displaying My Portfolio

If time was a luxury then I'd definitely follow that approach. Right now I am just wanting to throw something up there quick and dirty (okay, maybe not dirty) just to supplement job applications.

andyg1 started a new conversation Best Website For Displaying My Portfolio

I am looking to have an online "portfolio" kind of page that I can use to supplement my resumé when applying for jobs. Just as a github account can be linked to via my CV, I want an equivalent for screenshots of things I have been working - so visual, as opposed to code. What sites would people recommend for this? Ideally free. And I suppose a nice vanity URL would look best / be easier to read on a resumé. Thanks!

01 Jun
3 years ago

andyg1 left a reply on Laravel 5.1 & Selenium

BUMPing this.

It took me all morning to work out that the Laracasts/integration package was mostly in the 5.1 core now - Jeffrey really needs to mark the https://laracasts.com/series/intuitive-integration-testing/ series as archived.

But I am still trying to find an easy solution to testing JS based views with, for example, selenium - as per the video series.

In my quest, via many google searches, I read somewhere that Codeception includes selenium. Is using that going to give us what we want?

18 May
3 years ago

andyg1 left a reply on TDD = No Stress

@i960 I feel your pain. I came across this thread whilst trying to convince myself to do TDD (or any tests in fact). Having read quite about it for a couple of days now:

There is a bug in my controller because I forgot about one detail.

That's okay. We all miss things. But getting into the swing of TDD it will teach you to think about these things more and more. You become a better a programmer as a result of continuously writing tests. It forces you into that mindset.

If I can write buggy code, I can also write buggy tests, and the result is the illusion that my code is working perfectly when it's not.

When you discover a bug you can then write a test to recreate that bug. Once you've recreated it you will see the path to how to fix it, and may even give you some refactoring as a benefit.

It seems to me that the overall benefit is that you make really well-structured code. As you said with Git, you can't envisage a time without it. Once that switch is flicked with TDD then you should feel the same way.

Just my 2 cents.

I year has passed since your original message @i960 , I wonder how your TDD world looks now...?

09 May
3 years ago

andyg1 left a reply on Vue.js With Vuex / Flux Series

+1 for this

15 Apr
3 years ago

andyg1 left a reply on What Is The Location Context Of The File Class?

If I call:

File::put("output.txt", "Contents")

from tinker, it drops the file in the top directory, i.e. where I called artisan tinker from.

If I call it from inside a route closure, for example:

Route::get('/', function () {
    File::put("output.txt", "Contents");
});

it puts in into the public directory. So the File class must be reacting to the script location that is calling it.

andyg1 left a reply on Feed Page Design For Social Networking

@tisuchi I'm using GetStream on 5.1, so I don't see why there would be a problem.

andyg1 left a reply on Feed Page Design For Social Networking

I am working on a similar feed feature for my own project. Whilst it can be done within your own system, I suggest farming that out to a third party. I chose https://getstream.io/ The advantages are that they handle all the complex aggregation of your feeds, and the associated latency in fetching it.

They have a wrapper for use in Laravel, although having used it for a while I am tempted to write my own.

Unless you NEED to write your own feed functionality, this would definitely be the quickest route to a production ready feed.

andyg1 started a new conversation What Is The Context Of The File Class?

I am using a file helper class, which essentially wraps the File:: facade When I call a method in my helper from a controller, it correctly returns a list of files from a directory. When I call it from somewhere else, e.g. tinker or from a factory (for seeding) it can't find the files. It is as if the context of the File:: class is dependent on where it is called from:

/* from the controller, it is able to find images from /public/img/cover-images/ */
$image = (new \App\Helpers\RegistrationHelper)->getCoverImages();

but from a factory, or from tinker, the same method returns no results.

The helper method essentially ends up calling: return \File::files($dir);

where $dir is a config variable "img/cover-images"

The context of where I am calling it from seems to impact on the path... Can someone shed some light on this please? Thank you in advance.

11 Mar
3 years ago

andyg1 started a new conversation Making Use Of Database Integrity Violations For User Registration

I'm looking at building a custom exception that handles database integrity violations and now wonder if this is a sensible approach...

What set me off down this path was that I am providing logins with Socialite, where existing users are logged in, and new users are created in the DB. However, if you try and login with a different provider and the email address is the same then (because of the restriction on the database field for email) an Integrity Violation is thrown.

I wanted to catch it (type QueryException, with code 23000) and parse the message and turn it into a useful view that renders something like "Your email address is associated with a different provider, please try Facebook login instead of twitter".

Does this sound like a sensible strategy i.e. using the QueryException to catch this situation? Or am I better just handling all this in the code that registers new users - my User Repository?

(I was thinking the former was better because I can extend the functionality for different types integrity violations, not just email clashes)

I'm interested to hear how others have approached this problem. Thanks

03 Sep
3 years ago

andyg1 left a reply on If I Deploy With Forge, What Else Will I Need?

Thanks.

Having watched a few videos on Forge I am also a little confused about the queues. Like with the hosting (Digital Ocean), will I still need my own account for queues i.e. beanstalkd / iron.io?

andyg1 started a new conversation If I Deploy With Forge, What Else Will I Need?

Neebie question: From what I can establish, Forge just makes the deployment of an app easy. I will still need to pay for hosting, correct? A lot of people seem to be liking Digital Ocean.

I am trying to get some cost estimates of a project. What else will I need? I'm considering:

  • mailgun for email
  • pusher for notifications
12 Aug
3 years ago

andyg1 left a reply on What Frontend Framework Would You Choose For A Slick Web App?

@Francismori7 the secret is to do with the data-remote="data-remote" attribute on the form. If you dig into Jeff's JS code you'll see what's going on - he uses that attribute to attach a AJAX JS helper to anything with that attribute value. This Laracast shows you more or less what he's done: https://laracasts.com/lessons/javascript-conveniences

11 Aug
3 years ago

andyg1 left a reply on Customer Insights / CRM E.g Trak.io

I've just seen that plans for trak.io "start from $20,000 per year"! That rules that out.

andyg1 started a new conversation Customer Insights / CRM E.g Trak.io

About a year ago Jeffrey did a Laracast on integrating trak.io. I wonder if anyone is using this in production?

Alternatively, what are people's views on any similar packages?

I am building an application where tracking of customer behaviour is core to the marketing, so the options are 1) build it myself or 2) farm that out to a good, affordable third-party.

Thanks

10 Aug
3 years ago

andyg1 left a reply on What Frontend Framework Would You Choose For A Slick Web App?

@kayyyy I've watched a few of the Vue videos now. I like it, but it's still two-way binding, and that's where the React / Flux architecture wins for me.

@Ruffles - sound advice to go with whatever framework I'm comfortable with, but at this stage they (the ones discussed) are all new to me, in which case the learning curve is important. Vue looks the simplest to pick up, although am not sure how the maintainability will stack up once my site starts to scale. Another consideration is what experience I'll gain at the end of the project - I feel like React might be a stronger addition to the resume... :-/

It'd be interesting to know what @JeffreyWay uses here on Laracasts for his "slickness", such as these like buttons, report buttons, and the buttons on the video areas.

09 Aug
3 years ago

andyg1 left a reply on What Frontend Framework Would You Choose For A Slick Web App?

My issue with Angular is the learning curve. I started to look into it around December 2014, and whilst I understood it and got the concepts I was already seeing a huge learning curve, as well as hearing talk of Angular 2.0 not being backwardly compatible. Then I read somewhere that even though it is backed by Google they don't actually use it for any of their systems, which is where React stood out for me i.e. Facebook use it in production.

The additional benefit to React was the existence of React Native, which felt like if I ever wanted to move to making mobile apps I wouldn't be learning something brand new again.

In the old days, I would've just built most of the site with serverside templates, in the traditional fullpage reloads manner. Then drop a few bits of jQuery here and there to get some asynchronous slickness. But now I wonder if there's a better way to achieve that slickness - quicker to produce, easier to maintain and debug, more reusable, more performant, etc.

I've seen the videos here on Vue. I might give them a proper look over...

08 Aug
3 years ago

andyg1 started a new conversation What Frontend Framework Would You Choose For A Slick Web App?

Hi everyone,

I'm starting from scratch on building a fairly big project that I want to be really slick and modern feeling, in order to differentiate myself from the competition.

Obviously I want laravel as the backend, but I am after some advice on the what JS framework to use on the frontend and how to organise it all in laravel. I want the result to be pretty slick, but not quite a single-page app. I guess like Facebook - where some interactions involve no page refreshes, and some do.

When I've looked at some MVC-style JS frameworks I can't conceptualise how they would interact with laravel. It feels to me like I'd be duplicating the business logic in both the frontend and the backend - e.g the models, the validation, error handling.

Now I'm drawn to React, with the Flux pattern. But I haven't seen any examples of how people have persisted data with these and laravel.

I welcome other people's input and experience on these matters. Thanks

03 Dec
4 years ago

andyg1 left a reply on What Starting Points Do People Use For Brand New Projects?

Here's a really good video about how the time is now to start using HTML5 and forget about the older stuff. It's ready, he says: http://vimeo.com/112788089

02 Dec
4 years ago

andyg1 left a reply on What Starting Points Do People Use For Brand New Projects?

Looks like I've got about a year to wait for Angular 2, so I'll be cracking on with this. I want to get the front-end dev done, using mockup APIs so I don't have to write the business logic until I'm happy with Laravel 5. For the time being I'll just be using routing and the blade templating aspects of Laravel 4, hoping that the move won't be too much trouble in the new year.

Having looked at the tutorials on laracasts, plus some other reading, I think v5 is worth waiting for. This separation of front-end and back-end is intended to make the most of the time I'm waiting.

I welcome people's viewpoints of whether waiting for v5 is worth it...

01 Dec
4 years ago

andyg1 left a reply on What Starting Points Do People Use For Brand New Projects?

Good answers so far. Thanks

I'm the "client" because the site is my own project so I am thinking that I will stick with catering for the latest technologies, rather than the lowest common denominators. I'm looking to keep the development fast and lean, so expending resources on unnecessary things is something I want to avoid.

So far I've held off on the Laravel 5. I built the proof-of-concept prototype in Laravel 4 months ago, but now I'm starting again with the front-end, then plugging into a Laravel 5 when the release becomes official.

It's the headstarts on the front-end I am looking for right now so I can hit the ground running and worry more about my UX that setting up all my frameworks / templates / etc. Hence my questions about existing repositories that people might know of.

I've done a fair amount of reading on Angular and feel the time is right for it. I am not so worried about the SEO/indexing as my project will be membership only, behind closed doors.

andyg1 started a new conversation What Starting Points Do People Use For Brand New Projects?

I will be using Laravel as the back end for a brand new project and wondered what good practice starting points do people use when they begin a new project? I'm thinking along the lines of:

  • using front end frameworks like bootstrap
  • are things like Modernizr still necessary?
  • should I just HTML5 it with CSS3 and not worry about older browsers?
  • are there any pre-configured Laravel git repositories that offer an advantage over the official release?
  • I am planning on using AngularJS on the front end: discuss
  • LESS / SASS / grunt / gulp
  • are there any good Yeoman generators, or similar, that get the ball rolling quickly?

I want to give myself the best possible platform to built upon, and also potentially build myself a repository I can rely on time and time again for future projects (unless one exists already).

I welcome any advice, best-practice, criticisms and debate on the matter. Thanks :)