num3thod

num3thod

Lead Software Architect at Homicity Inc.

Member Since 4 Years Ago

ottawa on

Experience Points
18,410
Total
Experience

1,590 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
235
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.

Level 4
18,410 XP
Jul
18
3 years ago
Activity icon

Replied to Struggling To Retrieve Users By Role

Thanks @thefuzzy0ne, exactly what I needed.

Activity icon

Started a new conversation Struggling To Retrieve Users By Role

Hi, I have a relatively simple need to retrieve Users of a certain role, which is defined on a pivot table called assigned_roles.

on my User model

public function roles()
    {
        return $this->belongsToMany(config('access.role'), config('access.assigned_roles_table'), 'user_id', 'role_id');
    }

on my Role model

public function users()
    {
        return $this->belongsToMany(config('auth.providers.users.model'), config('access.assigned_roles_table'), 'role_id', 'user_id');
    }

in my controller

//$users = User::roles()->contains(3)->get();
 //$users = User::find(1)->roles()->wherePivot('role_id', 3)->get();
$users = User::with('roles')->where('role_id', 3)->get();
dd($users);

Ideally I could define a method on my User model that would help me retrieve users of a specific role simply. Any help would be greatly appreciated.

Feb
10
3 years ago
Activity icon

Started a new conversation Problems With The Default Removal Of WWW

This has been haunting me for the past three days. Basically, on my latest L5.1 project, whenever I type WWW.domain.com it removes it perfectly. But if I type WWW.domain.com/path, it rewrites to domain.com/index.php/path, thus breaking the page.

In my .htaccess, I've tried other variants such as:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.com$ [NC]
RewriteCond %{HTTPS}:s (on:(s)|off:s)
RewriteRule ^(.*)$ http%2://domain/$1 [R=301,L]

The default is:

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

Has anybody experienced this? Any advice would be extremely appreciated. Thanks.

SOLVED: screw it! Got rid of that rule, just like laracasts : )

Feb
06
3 years ago
Activity icon

Replied to Yet Another Mailgun Question. Please Help.

Yeah, it seems to be a DNS issue. VPS hosts website -> GoDaddy manages email accounts (I know)

I will simply post to another L5 project that has no issues with smtp. Thanks.

Activity icon

Started a new conversation Yet Another Mailgun Question. Please Help.

So I've used mailgun/mandrill in the past without issues. But on this Laravel 5.1 project, I am constantly getting timeouts on live. The error message says "Connection could not be established with host smtp.mailgun.org [Connection timed out #110]".

Yet, I am specifically using the Mailgun driver. Laravel should not be attempting to connect through SMTP (which is blocked by my hosting provider). What is going on here? How do I force Laravel to use the mailgun driver and NOT try smtp?

MAIL_DRIVER=mailgun
'mailgun' => [
        'domain' => env('mydomain.com'),
        'secret' => env('key-a2d3f9XXXXXXXXXXXXXXX'),
    ],
Feb
01
3 years ago
Activity icon

Replied to Is There A Way To Append A URL Param From A Controller?

SOLVED. Was an error within my manual paginator.

Jan
31
3 years ago
Activity icon

Started a new conversation Is There A Way To Append A URL Param From A Controller?

I just need to append &page=1 when returning the view.

The reason is that my manual paginator is sorting my filtered results incorrectly on the first page (which does not contain the page param).

Thanks in advance.

Jan
28
3 years ago
Activity icon

Replied to I Simply Need To Retrieve An Item From A Collection.

SOLVED. Changed to whereLoose. So $result = $collection->whereLoose('id', $search_input)->all();

Activity icon

Replied to Mandrill Not Able To Send Mails.

Try to simply change to the 'smtp' driver. I always have to fuss around to set it up on my VPS.

Activity icon

Started a new conversation I Simply Need To Retrieve An Item From A Collection.

Greetings,

So I have this table/model that has, obviously, an id column. I want to retrieve a specific row based on its id value. I also want to do this NOT as an eloquent query, but rather a sexy Laravel Collection method (because I want to further manipulate said collection).

For some reason, I keep getting an empty array as a result.

Here is a sample snippet:

$search_input = Input::get('search_input');
$collection = MyModel::all();
$result = $collection->where('id', $search_input);
dd($result); //Always comes back empty
//RESULT
Collection {#475 ▼
  #items: []
}

Also tried:

$search_input = Input::get('search_input');
$collection = MyModel::all();
$result = $collection->where('id', $search_input)->all(); //added the ->all();
dd($result); //Always comes back empty
//RESULT
[]

Also tried first(), and bunch of other methods. But no matter what I try, I can't seem to retrieve that darn row. Thanks in advance.

Jan
17
3 years ago
Activity icon

Started a new conversation Bizarre ErrorException When Chaining Two Where Clauses To Retrieve A Specific Row

SOLVED: One of $value2 retrieved higher up in my code was empty. Thus was breaking at that retrieval. Phew.

Hi, I'm wondering if I am going crazy here, or if I am not doing this the right way.

Basically, I am trying (and succeeding) to get a specific row in the following manner:

$myRow = Table::where('COLUMN1', $value1)->where('COLUMN2', $value2)->first();
echo $myRow->COLUMN3;

Issue is that Laravel is returning "Trying to get property of non-object", yet also returning the correct row as if everything was a-ok. Die and dump tells me the correct row was returned.

What am I doing wrong here?

Many thanks in advance.

MR

Sep
20
4 years ago
Activity icon

Replied to Intervention Image Upload - Ajax Post Problem

Solved by ditching $.post and replace with a proper $.ajax call. So umm, $.post sucks.

Hehe, you can Askers's Choice yourself. Whoda thunk it?

Activity icon

Started a new conversation Intervention Image Upload - Ajax Post Problem

Hi, I've been banging my head for hours now trying to figure out why Laravel doesn't seem to get the ajax post data for a file upload.

Specifically, Laravel seems to be unable to "read" the posted object data. Or, at least, I'm going about it the wrong way.

My approach: 1- retrieve the file object 2- post to laravel 3- save file and return success message (pretty simple stuff)

My code:

//JS
uploadElement.on("drop", function (e) {
   e.preventDefault();
   var file = e.originalEvent.dataTransfer.files[0];
   handleFileUpload(file);
});

function handleFileUpload(file) {
   var form = new FormData();
   form.append('file', file);
   $.post('upload', {
      data: form
   }, onSuccess);
}

function onSuccess(data, status, xhr) {
   console.log(data, status, xhr);
}
//PHP
Route::post('upload', function(){
   if (Request::ajax()) {
      $data = Input::get('file');
      if (Input::hasFile('file'))
      {
         $file = Input::file('file');
         $file->move('public/uploads', 
         $file->getClientOriginalName());
         $image = Image::make(sprintf('public/uploads/%s', $file->getClientOriginalName()))->resize(200, 200)->save();
         return "YES F**K YES!";
         }
      return $data;
      //returns "[]" for some reason
   }
});

I am getting a http 200 from the laravel post handler. Just not getting into the if (Input::hasFile('file')) condition.

Any help or insight or even vaguest of hints would be greatly appreciated.

Thanks,

MR

Jul
02
4 years ago
Activity icon

Replied to Is There A Way To Pass A Call To A Partial Though {!! MyVariable !!}?

Many thanks @constb! This is what I will try. Will report back when completed.

Activity icon

Started a new conversation How To Use BladeCompiler Method?

I ran into this http://laravel.com/api/5.1/Illuminate/View/Compilers/BladeCompiler.html#method_compileString today and am trying to use it to compile a string I have.

I am trying return view::compileString($myString);

but am getting Call to undefined method Illuminate\View\Factory::compileString()

Any ideas? Thanks.

Jul
01
4 years ago
Activity icon

Replied to Is There A Way To Pass A Call To A Partial Though {!! MyVariable !!}?

@constb Thanks for the suggestion. Can you give me an example of how I would create the shortcodes?

Activity icon

Replied to Is There A Way To Pass A Call To A Partial Though {!! MyVariable !!}?

@polarcubs Actually no. I do know how to call partials straight up in my view, as you indicated. What I am trying to do is call a partial from my blog posts content, like you would a Wordpress shortcode. I searched and searched, but am not seeing an effective way to do this.

Jun
30
4 years ago
Activity icon

Started a new conversation Is There A Way To Pass A Call To A Partial Though {!! MyVariable !!}?

Ok, I know this is going to sound bizarre, but hear me out. I created a simple blog, and I'd like to be able to call Blade partials from the blog post body (content) area when composing a post. Similar to how shortcodes work in Wordpress.

Obviously, when I try inserting @include('includes.partials.test') it ignores it and shows it as a string.

Any ideas? I am aware that there are composer packages for shortcodes, but I'd prefer sticking to pure Laravel if possible.

Thanks in advance.

MR

Jun
16
4 years ago
Activity icon

Replied to Postgres Db Seeding

@ldruneau You are right, and yes, with a few extra adjustments, the seeding is now working.

1- comment out DB::statement('SET FOREIGN_KEY_CHECKS=0;'); and DB::statement('SET FOREIGN_KEY_CHECKS=1;');

2- follow this guide for the truncate statements http://espadav8.co.uk/2015/03/04/laravel-database-seeding-with-postgresql/

Thanks.

Activity icon

Started a new conversation Postgres Db Seeding

I am getting the following error when attempting to seed my Postgres db

SQLSTATE[42704]: Undefined object: 7 ERROR: unrecognized configuration parameter "foreign_key_checks" (SQL: SET FOREIGN_KEY_CHECKS=0;)

The only other mention I could find is this post

https://laracasts.com/discuss/channels/eloquent/foreign-key-constraints-on-seeding

Yet, nothing on how to configure DatabaseSeeder.php for Postgres seeding.

What should I do? Thanks in advance.

Activity icon

Replied to Foreign Key Constraints On Seeding

@rdelorier What should be done Postgres?

Jun
09
4 years ago
Activity icon

Replied to Database Query Builder Question

@bestmomo Never mind. Got it. Woo!

Activity icon

Replied to Database Query Builder Question

@bestmomo Hey, I was wondering if you could explain this line $id = $this->blog ? ',' . $this->blog : '';

I have everything setup, but am struggling to adapt this bit to my scenario. Thanks.

Activity icon

Replied to Database Query Builder Question

@bestmomo Oh man. That's the right (clean) way to do this. Was my first hunch, but got lazy ; )

Anyways, thank you all for the tips.

Cheers.

Activity icon

Replied to Database Query Builder Question

@mstnorris Thanks. I'll try that now.

Activity icon

Started a new conversation Database Query Builder Question

I created a simple blog (for learning). Let's say I want to update a page's slug, but want to query my database to see if the new slug is already used by another page.

My code looks like this

$page->slug = Input::get('slug');
if (Page::where('slug', '=', $page['slug'])->first()) {
            throw new GeneralException('That slug has already been used.');
    } else {
            $page->save();
            return redirect()->route('admin.access.pages.index')->withFlashSuccess('The page was successfully updated.');
    }

My problem is that I am catching the very page I am updating, thus it will always throw the exception. How would I exclude "this" page from my query?

Hoping this makes sense. I looked and looked, but alas, nothing. Thanks in advance.