ArchStanton

ArchStanton

Member Since 4 Years Ago

Experience Points 40,210
Experience Level 9

4,790 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 291
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.

21 May
1 year ago

ArchStanton started a new conversation Alternative To Full Path To Model

A simple one (hopefully), is there a nicer way to write this - without the full backslashed path.

\App\Product::all();

I am in the controllers namespace

namespace App\Http\Controllers;
03 May
1 year ago

ArchStanton started a new conversation Chunking A In Large Standalone Project

H,

I have a large vue standalone project and was wondering if I can leverage any features of Mix to make it run faster as my bundle.js is approaching 3mb

I have noticed I can chunk up the modules.

chunkFilename: mix.inProduction() ? 'dist/[name].[chunkhash].js' : 'dist/[name].js'

this produces a load of ordered js.

0.js
1.js
2.js

But how do I get this into the html on a standalone (non-laravel) project?

01 May
1 year ago

ArchStanton started a new conversation Creating A Pattern Library/ Style Guide

Hi,

Does anyone have any pattern library generator suggestions? I have looked at Pattern Lab (the nav is a bit ugly and I don't have the time to muck around with it) and Astrum which looked good for html but a bit basic and no sass, only css by the looks of it.

I also found https://github.com/vue-styleguidist/vue-styleguidist which looks good for vue components but maybe just adding a level of complexity I do not need.

Any suggestion either paid or open source would be appreciated very much.

I am ideally looking for something which can toggle the html sass on and off for easy cut and paste.

23 Apr
1 year ago

ArchStanton started a new conversation Watching A Php Unit

Hi,

When I setup vue I like to setup a watcher when writing my tests can this be done with laravel/phpunit?

Thanks,

28 Feb
1 year ago

ArchStanton started a new conversation Dynamic Loading Of Data - Vuejs

I have 3 different language files.

import { french } from '../fr/data.js';
import { englishUS } from '../us/data.js';
import { englishUK } from '../uk/data.js';

I load them all in and then just switch in the data I need based on a global language variable. ($root.language)

mounted() {

//switch statement based on $root.language

}

Is there a better way to make this more dynamic and only import the file I need?

ArchStanton left a reply on Controlling Child From A Parent

@ejdelmonico - I used Vuex. With a getter.

I have had some inconsistent results with event buses in the past, in Firefox if I remember.

09 Feb
1 year ago

ArchStanton left a reply on Controlling Child From A Parent

Thanks but I still would like to know how to emit an event from a parent that is caught by the child.

I am not 100% sure you are correct

https://i.stack.imgur.com/5MRvB.png

ArchStanton started a new conversation Controlling Child From A Parent

I have a child (it is a count down) component which I want to start/stop/reset from the parent.

At the moment I am watching for a change in the prop.

watch: {
        action: function (action) {
            if(action == 'start') {
            this.trigger();
            }
            elseif(action == 'reset') {
                this.reset();
            }
        }

It works fine. Am I missing something though? Is there a better way to achieve this ?

Thanks.

05 Jan
1 year ago

ArchStanton left a reply on Change Laravel Login Page To Vue Component

Redirect on the route to the component route?

02 Dec
1 year ago

ArchStanton left a reply on Doc Comments - Phpcs And Prs2

Good shout I am using VSCode and it was not picking it up.

01 Dec
1 year ago

ArchStanton started a new conversation Doc Comments - Phpcs And Prs2

I have phpcs installed in vscode and am trying to code to prs2.

It seems too strict as even Laravel files throw up warnings

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{

Missing file doc comment
Missing class doc comment

How strict do I need to be and can I get away with missing out these comments?

16 Nov
1 year ago

ArchStanton left a reply on Small Site - Lumen Or Something Else

@YazanStash I think you are right, there is no real benefit from starting at lumen and adding.

ArchStanton left a reply on Small Site - Lumen Or Something Else

Mainly html & javascript.

I suppose not but I wanted to tidy up the code without building or installing a router and having a neater way to add the partials rather than require or include.

ArchStanton started a new conversation Small Site - Lumen Or Something Else

Hi,

I have a little app that is one main long page and a couple of legal type pages. I would like some of the basic functionality - routing, partials/templating, a little form.

Is lumen the best route, should I build it myself or is there something else?

ArchStanton left a reply on Valet Serving Php Files

@tykus The driver was fine but that is a good time, thanks. In the end it was an intenal redirect thing.

The replies did help me get there though!

15 Nov
1 year ago

ArchStanton started a new conversation Valet Serving Php Files

Hi,

I have a simple php site I want to serve on Valet. If I create an index.html it works fine but all .php files return a 404.

Any idea how I fix this? I really don't want to go back to MAMP.

11 Sep
1 year ago

ArchStanton left a reply on Emitted Event Not Working In Firefox.

@vanderb

Sorry I have copied the compiled code.

In my source it is

filterPeople: function() {

ArchStanton started a new conversation Emitted Event Not Working In Firefox.

I have an event which is triggered via a click

methods: {

        filterPeople: function filterPeople(event) {
            Event.$emit('people');
When my instance is mounted it is listened for

 mounted: function mounted() {
    var self = this;
    Event.$on('people', function () {
      self.filterPeople();
    });
  }

In my component I have the method which is called from this listener

filterPeople: function filterPeople() {

This works fine but the event is not defined in firefox. Any ideas how I can get this to work in FF?

Thanks,

01 Sep
1 year ago

ArchStanton left a reply on Helper Method Not Being Found.

@theFinalArbiter - I want to slap myself.

Composer dump-autoload fixed it.

ArchStanton started a new conversation Helper Method Not Being Found.

I have a helper class which is is my app folder.

Locally this is fine

I try and use in a blade template

{{ Helper::groupNameFromID($key) }}

I have an alias

'Helper' => \App\Helpers::class,

I get an error

(2/2) ErrorException
Call to undefined method App\Helpers::groupNameFromID()

The class is being found but not the method. I thought it may be a case issue so changed to all lowercase.

Any idea why the method is not being found?

The full Helper

ArchStanton started a new conversation Url From Model Methods

public static function getAllCampaignsByClient($id)
{
  return \App\Campaign::where('client', $id);
}

I have a method on my model. I like to do this I think it is a really concise way to retrieve your data.

However I now need to return this from a GET request. Thinking about keeping this DRY, what is the best approach?

ArchStanton left a reply on Laravel Package To Get The Width And Height Of Uploaded Video

Hi @Dhaval_patel @saurabh , I am looking for a server-side solution, I tried php mp4. It failed at the first attempt.

getid3() looks better as it reads the Metadata.

31 Aug
1 year ago

ArchStanton started a new conversation Laravel Package To Get The Width And Height Of Uploaded Video

Hi,

Just need to get his info from the file, will only ever be mp4.

Thanks.

ArchStanton left a reply on Routing Conflicts

I did is this the only way to get this to work? It seems that the order should not really matter.

I was just wondering if there was a way to make it explicit.

Thanks.

ArchStanton started a new conversation Routing Conflicts

I have a route I use for editing which is actually generate by the resource controller

/campaign/{id}/edit

I also have a route that filters by type

Route::get('campaign/{id}/{type}', function ($id, $type) {

The problem I am having is these routes tend to overwrite each other depending on which one is first in the route definition.

Is there a way to get these routes to work at the same time?

24 Aug
1 year ago

ArchStanton left a reply on Practical Use Of VueJS With Laravel

The routing system you want depends on the type of app. There is no right answer here.

As @topvillas said if there I would always route in Laravel unless you were making an SPA or there was a good reason to.

You are making a mobile app so maybe look at this

https://laracasts.com/series/whatcha-working-on/episodes/4

In your instance it sounds like you should mostly be using vuejs and then just use Laravel for the restful endpoints.

23 Aug
1 year ago

ArchStanton started a new conversation Returning Errors Back From Ajax To Trigger Laravel Flash Messages.

Hi,

Is it possible to trigger a flash message from an ajax request.

$.ajax({
    url: '/product/destroy/',
    type: 'post',
    data: {id:id, _method: 'delete', _token: '{{ csrf_token() }}' },
     success:function(data) {
       //do something here
    } 
  });

Thanks,

ArchStanton left a reply on Laravel - Create A Alias

Nice one thanks.

ArchStanton started a new conversation Laravel - Create A Alias

I have a route

GET|HEAD  | campaign/{campaign}/edit     | campaign.edit        | App\Http\Controllers\[email protected]

I can access this by a url

    http://localhost:3002/campaign/123/edit

In my controller

    public function edit(\App\Campaign $campaign){}

This works fine however I would like to also access this route by a unique key in my table. (campaign_id). This is a varchar not an int but it is unique.

http://localhost:3002/campaign/ABC1234/edit

Is this possible?

22 Aug
2 years ago

ArchStanton started a new conversation Doubleforeach - A Betterway In Blade

I have an eloquent relationship which joins all the groups to my collection

$campaigns = \App\Campaign::with('product')->with('groups')->where('client', $client->id)->get();

I can output the groups with a nested foreach but it is pretty cumbersome, is there a better eloquent way to do this?

@foreach($campaigns as $campaign)
                <tr><td><div class="campaign">
                    <a href="/campaign/{{ $campaign->campaign_id }}">{{ $campaign->campaign_name }}</a>
                </div>
                </td>
                <td>{{ $campaign->product->count() }}</td>
                <td>@foreach($campaign->groups as $group)
                        {{ $group->group_name }}
                    @endforeach

                </td>
                <td>
                
                <a href="/campaign/{{ $campaign->campaign_id }}">Edit Campaign</a> 
                |<a href="/campaign/{{ $campaign->campaign_id }}/all">View Campaign</a></td>
            </tr>
            @endforeach 
14 Aug
2 years ago

ArchStanton started a new conversation Combining Where And Has

Hi,

I am trying to return a group with a certain campaign_is which has no products.

$emptygroups = \App\Group::where('campaign_id', $id)->has('products', '=', 0)->get();

Logically this seems to work but it returns 2 groups which are not empty.

What am I doing wrong?

The relationship in the groups is

public function products()
  {
      return $this->hasMany('\App\Product', 'campaign_id');
  }

ArchStanton started a new conversation Browsersync/Mix - Css Not Refreshing

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
    .browserSync({
    proxy: '192.168.10.15'
});

I have a vagrant box which I am using with laravel mix/browsersync. The css does not seem to update. Occasionally it flashed up and then reverts, it appears like there is some local cashing going on.

How can I prevent this behaviour?

11 Aug
2 years ago

ArchStanton started a new conversation GroupBy And ::with()

I was trying to do this

$products = \App\Product::where('campaign_id', $id)->with('groups')->groupBy('groups.group_ name')->get();

I got an error

Column not found: 1054 Unknown column 'group_name' in 'group statement' (SQL: select * from products where campaign_id = STM28906 group by group_name)

I solved it by doing the group collection, however I was wondering is it possible to combine eager loading with a groupby function and is there much of a gain in keeping the groupby in the eloquent query

$products = \App\Product::where('campaign_id', $id)->with('groups')->get();
$products = $products->groupBy('groups.group_name');

ArchStanton started a new conversation Route Model Binding - Calling Relationship

I have a route with an injected model

public function edit(\App\Campaign $campaign)
    {
        dd($campaign-toArray());
        return view('campaign.edit', compact('campaign'));
    }

A campaign can have many 'groups'. I have setup this relationship and try this

public function edit(\App\Campaign $campaign)
    {
        $campaign = $campaign::with('groups')->get();
        dd($campaign->toArray());
        return view('campaign.edit', compact('campaign'));
    }

but it returns all the campaigns and groups. How can I grab the relationship?

04 Aug
2 years ago

ArchStanton started a new conversation Does Anyone Still Use The Form Helper Class?

I have begun to move away from this I just find it harder to read and a bit cumbersome than plain old html.

https://laravelcollective.com/docs/5.4/html

 {{ Form::submit('Click Me!',  array('class' => 'btn btn-primary')) }}

I am happy to be convinced otherwise and am interested in other peoples opinions.

How do you build your forms?

03 Aug
2 years ago

ArchStanton left a reply on Route Model Binding

Gotcha, - nice one.

ArchStanton started a new conversation Route Model Binding

I have a route

http://192.168.10.15/user/33/edit

I am trying to return the user based on the url id.

  public function edit($id, \App\User $user)
    {
        dd($user->id);
         return view('user.update');

    }

The id is returning null, how do I return user 33 (in this example)?

02 Aug
2 years ago

ArchStanton started a new conversation Laravel Storage - File Exists

Hi,

How can I make my file overwrite a file with the same name

Storage::disk('public')->move('uploads/'.$filename, 'uploads/'.$filename_pieces[0].'/'.$filename);

I currently get the error

FileExistsException
File already exists at path

``


28 Jun
2 years ago

ArchStanton left a reply on Laravel Mix - Unexpected Token

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
 .sass('resources/assets/sass/main.scss', 'public/css').version();

ArchStanton started a new conversation Laravel Mix - Unexpected Token

I am trying to run this

Vue.component(
      'async-webpack-example',
      () => import('./my-async-component')l
    )

I get this error but thought mix could compile ES2015 syntax?

Syntax Error: Unexpected token (30:8)

  28 | Vue.component(
  29 |   'async-webpack-example',
> 30 |   () => import('./my-async-component')
     |         ^
  31 | )
17 May
2 years ago

ArchStanton started a new conversation Grouping In Blade

$campaign = Campaign::where('campaign_id', $id)->first();
$products = \App\Product::where('campaign_id', $id)->with('group')->get();


A campaign has many products and a product has many groups.

Using 'with' to make the join I have the data I want

  • product id
  • group_id
  • group_name

In blade I currently do a simple foreach

@foreach($products as $product) 
    <div><a href="/product/{{ $product->id }}">{{ $product->product_id }}</a></div>
@endforeach

I want to be able to output, grouping by the group name so.

GROUP1 product1 product45 product 60

GROUP2 product2 product8 product 40

How can I achieve this?

09 May
2 years ago

ArchStanton started a new conversation Join With Eloquent

Hi,

I have a people table, people can be in many departments.

public function departments()
    {
      return $this->belongsTo('App\Models\Departments', 'id');
    }

I have a departments table, a department has many people

    {
        return $this->hasMany('App\Models\People', 'id', 'department_id');
    }

The people table

  • id -name
  • title

The departments table

  • id
  • person_id
  • department_id

The person_id is the foreign key.

So if I am looking to return all the people from departments 2 (accounting) I can do this

$depts = $departments::where('department_id', 2)->get();
   foreach($depts as $dept) {
     // do something
   } 

But this only returns their id. It's a start but how do I do the join to return the name and title?

08 May
2 years ago

ArchStanton left a reply on Backpack : How Access To A Different Model ?

@bouffekai I am interested in this did you ever manage it?

05 May
2 years ago

ArchStanton left a reply on Larvel Backpack

It's an easy fix.

My primary key was called 'department_id', it should jut be id.

ArchStanton started a new conversation Larvel Backpack

Hi,

I am trying to setup a Laravel backpack multi select colulmn

$this->crud->setColumns(['name']);
$this->crud->addField([
                  'label' => "Department",
    'type' => 'select_multiple',
    'name' => 'departments',
    'entity' => '', // the method that defines the relationship in your Model
    'attribute' => 'department_name', // foreign key attribute that is shown to user
    'model' => "App\Models\DepartmentNames", // foreign key model
    'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
]);

It works on but the html does not render out any values

<select class="form-control" name="departments[]" multiple="">
    <option value="">-</option>
    <option value="">accounts </option>
    <option value="">services</option>
    <option value="">digital</option>
    <option value="">office</option>    
</select>

Does anyone have any ideas how to get this working?

27 Apr
2 years ago

ArchStanton left a reply on Class App\Http\Controllers\SocialFeeds Does Not Exist

I think the path was wrong but also think when I switched git branches there was a permissions problem.

I was just going round in circles.

ArchStanton left a reply on Class App\Http\Controllers\SocialFeeds Does Not Exist

ok point taken,

I have another class

namespace App\Classes;
class TwitterAPIExchange
{

// some stuff

When I try to pass this in

<?php

namespace App\Http\Controllers;


use Illuminate\Http\Request;
use Classes\TwitterAPIExchange;

class PagesController extends Controller
{
    //
 public function index(TwitterAPIExchange $twitter) {
    //dd($social);
  return "hello";
}
}

I get the same error.

ReflectionException in RouteSignatureParameters.php line 25:
Class Classes\TwitterAPIExchange does not exist

ArchStanton started a new conversation Class App\Http\Controllers\SocialFeeds Does Not Exist

I have my SocialFeeds Controller

When I try and inject it into my index method

use App\Http\Controllers\SocialFeedsController;

class PagesController extends Controller
{
    //
 public function index(SocialFeedsController $social) {
  return "hello";
}
}

I get the error

ReflectionException in RouteSignatureParameters.php line 25:
Class SocialFeedsController does not exist

How can I get this working?