foxted

Member Since 5 Years Ago

Vancouver, BC

Web Application Developer at WiderFunnel Marketing Optimization Inc.

Experience Points 37,225
Experience Level 8

2,775 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 565
Lessons
Completed
Best Reply Awards 14
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.

20 Jun
1 month ago

foxted left a reply on Define Broadcaster Per Events

I've been giving it a shot to submit a PR, but can't seem to figure out the best way to do it. I'll try another approach.

In my case, Pusher is great for broadcasting to the frontend, but to broadcast to other server-side application, I'd like to send some events using Google Pub/Sub, as it has a guaranteed delivery and Pusher doesn't.

19 Jun
2 months ago

foxted started a new conversation Define Broadcaster Per Events

With Laravel, there is a way to define the queue connection used on a per-event basis:

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;

class TestEvent implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    protected $connection = 'redis';

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('hello-there');
    }
}

I was wondering if there was a way to do the same with the broadcaster, something like:

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;

class TestEvent implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    protected $broadcaster = 'pusher';

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('hello-there');
    }
}

Anybody worked on something like this before?

03 Sep
2 years ago
05 Aug
3 years ago

foxted started a new conversation Add PHP As A Category For Community Links

Wanted to add a generic package to the community links today, but noticed the "PHP" category was missing!

@jeffreyway would you be interested in adding this category?

Thanks!

26 Jun
3 years ago

foxted left a reply on Laravel 5.3 Wish List

  • Built-in Oauth
  • Built in transient tokens (like Spark)
05 May
3 years ago

foxted left a reply on Vueify, Templates, And Laravel Blade

I think the template would have to be inline to be able to use Blade variables when rendering and delegate to Vue then.

Vueify is to compile *.vue files, which can contain your template, your javascript and also your style if you want to (I personally avoid the latter).

If you start having a lot of Vue components, I would recommend a single page application pattern or fetch your data from each component using AJAX requests.

foxted left a reply on Bind Event Dynamically

You could probably use: http://vuejs.org/api/#vm-on.

foxted left a reply on Add Route() Parameter With VueJs

Because of this code:

<a href="{{ route('edit_page_path', [@{{ page.id }}]) }}">
      @{{ page.title }}
</a>

I am guessing you have a page object available within your VueJS code as JSON. Maybe you can attach this route to the model directly so it would be available in the JSON.

For example:

class Page extends Model {

    protected $appends = ['url'];

    public function getUrlAttribute() {
        return route('edit_page_path',  $this->id);
    }
}

This way in your page url is included in the page object JSON, now within your VueJS code in your Blade template you could do:

<a href="@{{ page.url }}]">
      @{{ page.title }}
</a>
03 May
3 years ago

foxted left a reply on Real World SPA Using Laravel As Backend?

Built this kind of thing recently (I am using basic authentication though, no JWT yet): https://liftmap.com

08 Dec
3 years ago

foxted left a reply on Change Resource Route Parameter Placeholder

Thanks for your answers guys!

I was just trying to avoid registering a Model Binding on a simple letter, but I will just write some documentation for my co-workers and it should be fine!

foxted left a reply on Change Resource Route Parameter Placeholder

Thanks for your answer @JoeDawson , but I am trying to change the wildcard name and not the route name.

It is not a major issue, but I just find it weird to have a binding named p instead of projects !

foxted started a new conversation Change Resource Route Parameter Placeholder

Hello!

I am trying to setup a resource to create URLs that look like this:

/p/{projects}

But if I use

Route::resource('p', 'ProjectsController');

as expected, the parameter name is p like so /p/{p}.

Is there a way to override the parameter name for a resource?

Thank you!

01 Sep
3 years ago

foxted left a reply on My Aliases Simply Do Not Resolve

In Laravel 5, controllers are now namespaced, so to use a Facade, you have to add a use statement at the top:

use Flash;
29 Apr
4 years ago

foxted left a reply on Laracasts Forums Crave For Moderation

@JeffreyWay Just started implementing Algolia - Search As A Service for a website of mine, pretty cool and no complicated server admin stuff!

foxted left a reply on Envoyer, Maintain User Uploads Between Releases

@opheliadesign

  1. Create your VBX folder in /home/forge/{domain_name} or /home/forge/{domain_name}/storage
  2. Create the deployment hook:
cd {{release}}/public
ln -s /home/forge/{domain_name}/vbx vbx

Done ;)

10 Apr
4 years ago

foxted left a reply on Moving Code From Route.php To A Controller For Handling AJAX Form

You could name your route like so:

Route::post('posts/create', ['as' => 'posts.create', 'uses' => 'FeedController@createPost']);

And then call

<form action="{{ route('posts.create') }}" method="POST">

in your Blade template.

foxted left a reply on Is There A Way To Add Phpspec To My Path?

Or, you can add vendor/bin to your path, this way you'll have access to any bin downloaded though composer in your project.

foxted left a reply on Responsive Twitter Bootstrap Grid, Array_chunk()

@mstnorris To fix the problem on your screenshot, where the column are "shifted" to the right because one column has more content than the others, take a look at this jQuery plugin

09 Apr
4 years ago

foxted left a reply on Authentication Redirect Problem

You should leverage FormRequest to do your validation, you could reduce the code in your login method drastically!

public function postLogin(LoginRequest $request)
{
        $request->validate();

        $credentials = $request->only('email', 'password');

        if ($this->auth->attempt($credentials, $request->has('remember')))
        {
              return redirect()->intended($this->redirectPath());
        }

        return redirect($this->loginPath())
              ->withInput($request->only('email', 'remember'))
              ->withErrors([
                    'email' => $this->getFailedLoginMessage(),
         ]);
}

foxted left a reply on How I Redirect The Form To Edit After Create

When you create a new "entry", it should return the entry's id, you can then do:

return redirect()->route('entry.edit', $id);

foxted left a reply on Dynamic Routing From Database

  1. You generate the routes file every time you have a new redirection in database, not on every request
  2. https://mattstauffer.co/blog/laravel-5.0-route-caching

foxted left a reply on One Table, Multiple Relations

Why exactly do you have to keep users and customers separated?

foxted left a reply on Dynamic Routing From Database

I mean generating a dedicated routes file (on every change or not, depends on you).

Even if you generate a new routes file on every redirection update, it will still be faster than querying your database and looping though all results on every request.

foxted left a reply on Format MySQL Result For Chart

Try this approach:

  1. Create an array with the dates
  2. Fetch all attempts (successful and failed) between the first date and the last
  3. For each date, filter your collection items for each date using filter() to assign the successful and failed attempts

foxted left a reply on Dynamic Routing From Database

So you are building a tool to help your clients generate 301 redirections.

You could generate .htaccess rules or even a routes file.

foxted left a reply on Show Different Menu Based On Role

We could chat about it sometime if you'd like.

Follow me on Twitter and I'll send you my email via PM.

foxted left a reply on Forge - 502 Bad Gateway

Any errors in the php5-fpm logs?

foxted left a reply on Dynamic Routing From Database

I am confused by your issue... Why not using Nginx/Apache to do 301 redirections?

foxted left a reply on Everything Relates To The User

You could delegate the return view() function to a "ViewFactory" of your own to make it cleaner.

foxted left a reply on How To Access Url Without Public/

Then you should really take a look at Laravel Homestead which basically run a "virtual server" on your machine.

A few key features:

  • Use real domain names (ex.: project.dev)
  • Ubuntu 14.04
  • PHP 5.6
  • HHVM
  • Nginx
  • MySQL
  • Postgres
  • Node (With Bower, Grunt, and Gulp)
  • Redis
  • Memcached
  • Beanstalkd
  • Laravel Envoy
  • Fabric + HipChat Extension
  • Blackfire Profiler
  • ...

Out of the box!

foxted left a reply on Forge - 502 Bad Gateway

What about boosting the keepalive setting?

Source: http://stackoverflow.com/a/23865671

foxted left a reply on How To Access Url Without Public/

What is your local web server configuration?

Three solutions:

  1. If you have Apache or Nginx installed, configure your vhost to point to /public/ directly
  2. Use Laravel Homestead
  3. Navigate to your project-folder/ within your terminal and run php artisan serve, you can now browse to http://localhost:8000 directly in your browser

foxted left a reply on Generate CSV File For Download And Show Waiter Until Ready

You should be able to set the memory limit on your worker.

artisan queue:listen has a memory limit setting for example:

Usage:
 queue:listen [--queue[="..."]] [--delay[="..."]] [--memory[="..."]] [--timeout[="..."]] [--sleep[="..."]] [--tries[="..."]] [connection]

Arguments:
 connection            The name of connection

Options:
 --queue               The queue to listen on
 --delay               Amount of time to delay failed jobs (default: 0)
 --memory              The memory limit in megabytes (default: 128)
 --timeout             Seconds a job may run before timing out (default: 60)
 --sleep               Seconds to wait before checking queue for jobs (default: 3)
 --tries               Number of times to attempt a job before logging it failed (default: 0)
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question
 --env                 The environment the command should run under.

EDIT: You could also use a Push Queue service like Iron.io if you want to move your workers out of your server.

foxted left a reply on Show Different Menu Based On Role

@mstnorris It was just an example for the 'log in as' feature.

Can the "scope" system work for you? Does it sounds like what you are trying to achieve?

foxted left a reply on Generate CSV File For Download And Show Waiter Until Ready

I had the same problem on an app of mine (CSV with 80,000+ rows to generate). Sounds like you should try to leverage Queue Jobs on that one.

Basically:

  • You send an ajax request to the server to create a queue job that will generate the CSV
  • When the job is ready, use a service like Pusher to notify the user and show him the link to download the CSV

This way, the user can continue doing something else until the document is ready.

foxted left a reply on Everything Relates To The User

You have multiple solutions:

  1. Use different routes to change scope (ex.: domain.com/student, domain.com/admin, etc.)
  2. Use different domains (ex.: student.domain.com, admin.domain.com, etc.)
  3. Use a middleware only to "load" the current scope.

You could share views, models, etc. between scopes.

But to be sure to answer your question, I would need more information about what changes between scopes:

  • is it just a different design/layout? in this case, just load different views according the user's scope
  • is it different content? then maybe you can detect scope in your controller or in a middleware to direct user to the right route (to avoid bloating your controllers)

foxted left a reply on Show Different Menu Based On Role

So it's definitely a "scope" system that you need.

You could manage scopes on a User the same way you manage the permissions and route the user to the right part of your app using middlewares to detect the current scope.

EDIT: If you feel like outsourcing all of this, take a look at Auth0

foxted left a reply on Everything Relates To The User

I use to maintain a small Permissions package, that could manage simple permissions (can_edit, can_do_this, can_do_that) and Roles were a pre-defined set of permissions to apply to a User.

Everything is pretty much based on the permissions. If the user experience like you said is different between roles, maybe creating different "spaces" would be a good approach:

Controllers
   ->Student
   ->Admin

And leverage routes and middleware to guide the user through the app.

foxted left a reply on Show Different Menu Based On Role

Usually I try to group menu items together according to role, this way it limits the number of if statements.

Also, if you have roles that share the same menus, maybe it would be better to add a more in-depth permission system (ex.: @if(Auth::user()->can('do_whatever') )

foxted left a reply on Show Different Menu Based On Role

I personally use the second approach, works fine for me and no ordering problems so far.

foxted left a reply on Comma And Double Value

It would be

public function setKmPriceAttribute($value)
{
    $this->attributes['km_price'] = number_format($value, 2, ',');
}

But the DOUBLE and FLOAT formats don't support comma as a decimal separator

foxted left a reply on Eloquent Foreign Key Issue

Did you try this ??:

Schema::create('login',function(Blueprint $table)
 {
      $table->increments('id');
      $table->integer('user_id')->unsigned()->unique();   
      $table->timestamps();
      $table->foreign('user_id')->references('user_id')->on('user_infos')->onDelete('cascade');
});
Schema::create('user_infos', function(Blueprint $table)
{
      $table->integer('user_id')->unsigned();
      $table->string('first_name',45);
      $table->string('last_name',45);
      $table->timestamps();
      $table->primary('user_id');
});

foxted left a reply on Best Way To "rewrite" Paginate Response?

Don't know this package at all, but it seems like it is using Fractal to transform the paginator, there must be a way for you to override the transformer.

foxted left a reply on Update The Value If Same Key Of Array Or Insert As New Value

Take a look at the addRow function in this case, it should give you a hint.

foxted left a reply on Update The Value If Same Key Of Array Or Insert As New Value

You could use a package like Crinsane/LaravelShoppingcart that could handle that for you automatically.

08 Apr
4 years ago

foxted left a reply on Mail Won't Send. Stuck In Pretend

I have no other idea :/

Take a look at this repo and compare with your code to see if there are some differences.

It seems like you environment is misconfigured or not loaded properly.