17 Best Reply Awards

  • Member Since 4 Years Ago
  • 882 Lessons Completed
  • 4 Favorites

10th March, 2018

Drfraker left a reply on Single Request, Multiple Models Of The Same Type • 1 week ago

Create your form with name prefixes for each field. Like student_email, partner_email, etc. When you do validation you can validate them correctly.

Drfraker left a reply on Make Default Auth Uses People Credentials • 1 week ago

I think you will simply need to override this function from the trait in your User.php file:

     * Get the e-mail address where password reset links are sent.
     * @return string
    public function getEmailForPasswordReset()
        return $this->people->email; // whatever this is on the user's profile

Drfraker left a reply on Conditional Vue Component In Blade • 1 week ago

If you are loading it based on the route anyway, why not add a new route and show an entirely different *.blade.php view for each route?

8th March, 2018

Drfraker left a reply on Bootstrap Sass • 1 week ago

Can't figure out how to delete a question...

Drfraker started a new conversation Bootstrap Sass • 1 week ago

Im testing something on here.

28th February, 2018

Drfraker left a reply on Add Queue Listen As Post Deployment Hook • 2 weeks ago

In envoyer you can create a deployment hook from the ui.

Set it up to run after the "Activate New Release" event.

cd {{release}}

php artisan queue:restart

Drfraker left a reply on Passing Boolean From Laravel Blade To Vue Component Prop • 2 weeks ago

Try casting it to a boolean from the model:

// User.php

protected $casts = ['two_factor_enabled' => 'boolean'];

27th February, 2018

Drfraker left a reply on How To Save Quill.js Values To Database Laravel 5.6 • 3 weeks ago

@sutherland I'm not copying your homework! I found the link on the Quill.js site and changed my answer so I didn't give the guy the wrong information. I didn't even know you had posted anything.

Drfraker left a reply on How To Save Quill.js Values To Database Laravel 5.6 • 3 weeks ago

I've never used Quill.js but if you want a regular post request when you submit a form on your page. Try attaching quill.js to a text area in your form.

<form action="/some/route" method="post">
    <textarea id="editor" name="body"></textarea>
    <button type="submit">Save</button>

Drfraker left a reply on Redirect From The Auth/LoginController • 3 weeks ago

What is the uri that is being returned from Session::get('uri')? How is that being set in the session when they log in?

Try this:

// LoginController.php

protected function redirectTo() {

     return dd(Session::get('uri'));

What is the result of that? You can also specify a default value in the case that the 'uri' variable isn't set like this:

Session::get('uri', '/dashboard');

Drfraker left a reply on Change Id Field To People_id • 3 weeks ago

Your primary key is set on the model as 'id'. If you want it to be something different you have to specify that by setting the property in your model to the new 'people_id'. I wouldn't recommend doing this because eloquent works out of the box by following conventions. You will fight this to some degree each time you want to set up a relationship with People.php.

To change it here is what you need to do:

// People.php
protected $primaryKey = 'people_id';


23rd February, 2018

Drfraker left a reply on Time Not Saving Correctly • 3 weeks ago

Show the code. We can't help if we don't see what you are actually doing.

Drfraker left a reply on Where Do I Start With Testing This Small Class? • 3 weeks ago

If you aren't worried about github api changing, or it isn't that important to the core functionality of your app, then maybe consider mocking Zttp. This will have the benefit of being faster and not requiring internet connection for the test to run with the downside of not actually testing that you can get information from github.

If it is critical to make sure that the API call is working, you can make it more of an integration test and hit the github API for a repository of yours with a known value of stars and make sure that it is returning the correct data. Or build the world in the test and use the github API to create a repository and star it, then use this class to confirm that you can access the repo and see that it has one star. Finally delete the repository once the test has run.

I have some tests like this and I do both options, but I place all of the Integration tests in a separate test suite and only run them before I push to production. In my day to day testing I don't run them because they are slow.

Drfraker left a reply on Moving From Shared Server To Forge - Subfolder Redirect To Subdomain • 3 weeks ago

Create a new site on the forge server called sub.domain.com and install your laravel app there. (you won't need to put it in domain.com/subfolder/public) In your dns settings point the address sub.domain.com to the IP address of your server.

12th February, 2018

Drfraker left a reply on Weird Issue With Queued Jobs Not Processing • 1 month ago

That is strange. I would move to laravel horizon. With horizon you get a dashboard that you can see jobs running and see when they fail. It might give you some insight into when they are failing and offer more debugging options.

Drfraker left a reply on Ubuntu And PHP 7.1 • 1 month ago

Not sure. Sorry.

Drfraker left a reply on Ubuntu And PHP 7.1 • 1 month ago

I'm running PHP 7.2 on an ubuntu 16.04 server. So I'd say you might be missing something.

Drfraker left a reply on What Is A Good Approach To Getting Model Properties? • 1 month ago

If you want to decouple it from the column name, you could do this:

class User extends Model 
    public function email(){
        return $this->email; // this can change if you change the column name.

Drfraker left a reply on Why Is My Vue In Laravel Not Showing? • 1 month ago

Take a moment to help the people that are helping you and include your route and controller logic. It is impossible to diagnose the issue with the code you provided.

Drfraker left a reply on Multiple Parameters To Crud • 1 month ago

@dsml you can type

php artisan route:list 

in the console and see all of the routes in your app. This might help you understand what the resource routes are creating for you.

Drfraker left a reply on Subpages Laravel • 1 month ago

Hey @littlebox

I think it might be easier to break this out into multiple controllers so that you can follow a rest pattern all the way down from a podcast to the finer details about an episode. It also makes the routing easier. I'm not sure what "serials" are so I'm going to use a concept that is easy for me to understand, Podcasts. This is very quick and dirty and you may want to change the structure a bit, but I think you'll get the gist of it.

web.php might have the following.

// Show all podcasts in the database
Route::get('podcasts', '[email protected]')->name('podcasts.index');

// Show information about a specific podcast including all seasons
Route::get('podcasts/{podcast}', '[email protected])->name('podcasts.show');

// Show information about a specific podcast season. which shows all episodes for the given season
Route::get('seasons/{season}/episodes', '[email protected]')->name('episodes.show');

// Show all information about a specific episode
Route::get('episodes/{episode}', '[email protected]')->name('episodes.show');

This assumes that you have a data structure like this: podcasts id, name, meta...

seasons id, podcast_id, name, meta...

episodes id, season_id, name, meta...

You can use has hasManyThrough relationship to connect episodes to a podcast through the seasons relationship.

29th January, 2018

Drfraker left a reply on Clean Up Large Controller Method • 1 month ago

To me it depends on how complex your discounting logic is. If it is simple, leave in on the order model and have an applyDiscount method where you for example pass in a coupon code that gets checked for a discount amount. If it is complex and will grow more complex in the future you could separate it out into its own class called Discount and handle the logic there. Hard to say without seeing more. I would not create helper methods in a separate file, I'd make a dedicated class if it wasn't going to be in the order model.

25th January, 2018

Drfraker left a reply on Clean Up Large Controller Method • 1 month ago

Sounds like you could be dispatching a few jobs on the queue to take care of this the heavy lifting. Then the jobs are reusable throughout your project.

For example make a job called GeneratePdf. Your controller can dispatch that and move on to getting back to the user. You move all of that logic out of your controller and now you can dispatch that job from other parts of your code. :)

Drfraker left a reply on Schedule Database Changes • 1 month ago

Create a job to update the row and delay it for the proper amount of time.


namespace App\Http\Controllers;

use App\Product;
use Illuminate\Http\Request;
use App\Jobs\SendReminderEmail;
use App\Http\Controllers\Controller;

class ProductUpdateController extends Controller
     * Update the value of a product and push a new job onto the queue.
     * @param  Request  $request
     * @param  int  $id
     * @return Response
    public function sendReminderEmail(Request $request, $id)
        $product = Product::findOrFail($id);

    $delayTime = '??'; // Calculate your delay time
        $job = (new UpdateProduct($product))->delay($delayTime);


24th January, 2018

Drfraker left a reply on How Too Properly Debug Jobs In Laravel 5 • 1 month ago

You can debug jobs easily by setting the queue driver to sync. Instead of being queued they will run synchronously. Then you can use xDebug.

Drfraker left a reply on Join Causes Duplicate Results • 1 month ago

What exactly is duplicated?

Drfraker left a reply on Simple Delete Request Logic • 1 month ago

I would reconsider your naming conventions, they are confusing as is.

// routes/web.php

Route::delete('stacks/{stack}', '[email protected])->name('stacks.delete');
// delete dashboard route should point to a [email protected] method, since this is stacks, I changed the name of the route. Modify to fit your needs

// form in blade file I'm making some assumptions about what you are trying to do here.
@foreach($stacks as $stack)
<form action="{{route('stacks.delete', ['stack' => $stack])}}" method="POST">
{{ method_field('DELETE')}}
{{ csrf_field()}}
<button type = submit>Delete Stack</button>

// StacksController.php
public function delete(App\Stack $stack)
    // perform some user validation to make sure the authenticated user is authorized delete the stack


    return redirect('dashboard/index');

Drfraker left a reply on Cant Find A Way To Update Variable From Form Request • 1 month ago

The validate method on the request helper is returning an array that you are storing in the variable $office. When you are trying to call the update() method on the $office array you get the error you see. You code doesn't make sense. If you are updating an office model why are you passing it an address? There might be a cleaner way to do what you are trying to do.

$data = request()->validate ...


23rd January, 2018

Drfraker left a reply on What Am I Missing. • 1 month ago

Is your index controller method that is loading that view passing the user in?

11th January, 2018

Drfraker left a reply on Redis Cashing Issue With ::remember • 2 months ago

Are you sure you are passing in the correct key when you call the cache later? That is where I would start debugging. Otherwise, everything looks good.

Drfraker left a reply on PHP CODE IN LARAVEL • 2 months ago

  // echo ‘hello world’;

6th January, 2018

Drfraker left a reply on Laravel Horizon Handle Long Running Jobs • 2 months ago

Have you thought about using an artisan console command instead? I think they are better suited for long running processes like this. You can also queue them up in case you have more than one to call.


Drfraker left a reply on Need Help With Eloquent Relationship Problem • 2 months ago

If the parent_id column is null, it is a top level category. If the parent_id column has a value the parent of the subcategory is the category that matches the parent_id. Look at the examples I gave of a category and a sub category and I think you will see it.

Drfraker left a reply on Extracting Values From Url And Updating Table In Db • 2 months ago

Form in page where they are creating a booking

<form method='POST' action="/schedule/{{$schedule->id}}">
    // input fields


Route::post('schedule/{id}', '[email protected]'); 
class BookingController extends Controller {
public function store($scheduleId){

    $this->validate( request(), [
            'lastName'      => 'required',
        'firstName'     => 'required',
        'email'         => 'required',
        'mobilenumber'  => 'required',
        'additionalId'  => 'required',
        'idNumber'      => 'required'



        'schedule_id'           => $scheduleId,
        'lastname'      => request('lastName'),
        'firstname'     => request('firstName'),
        'email'         => request('email'),
        'mobilenumber'  => request('mobilenumber'),
        'id_type'           => request('additionalId'),
        'id_number'     => request('idNumber')


Drfraker left a reply on Need Help With Eloquent Relationship Problem • 2 months ago

I don't think you need 2 tables for the category and subcategory. Try this schema instead.

categories table id parent_id title slug timestamps

A Category example id:1, parent_id:null, title:Some parent category, slug: some-parent-category

A subcategory of example above id:2, parent_id:1, title:Some Subcategory, slug: somesubcategory

posts table id user_id category_id title body slug

Drfraker left a reply on Looping Through Values In_array And Checking Multiple Checkboxes • 2 months ago

@foreach($list_of_grades as $output_grade)
  <div class="inline field">
    <div class="ui checkbox">
      <input type="checkbox" name="grades[]"
        {{in_array($output_grade->name, $grade_array)) ? 'checked' : ''}}
        tabindex="0" class="hidden">
      <label>{{ $output_grade->name }}</label>

22nd December, 2017

Drfraker left a reply on Best Option - Many To Many • 2 months ago

Go with the many to many option and utilize caching to reduce database queries later if you need to.

5th December, 2017

Drfraker started a new conversation Queue Worker Constantly Restarting • 3 months ago

I have a server that I manage with forge. I'm seeing a few things that don't make sense to me.

Server Info: I have an application server, a redis server for queues, sessions, and caching and a database server for MySql. These are all set up in a network on Forge so they can communicate with eachother. My cache, session and queues are all using the default settings that laravel provides out of the box. My application server is using opcache.

First: The queue worker is restarting constantly. When I view the progress it is always at a runtime of 14 seconds or less, or restarting. This can't be right.

Seconde. The queue is still processing event listeners that don't exist in my application anymore. Like it's picking up jobs from old code still.

Some things that I did that might be a problem:

  1. I ran php artisan queue:work and php artisan queue:listen on my application server while also having a daemon on forge that is running the same queue.
  2. I ran php artisan queue:flush on my application server to try to get rid of old jobs that were running the code that doesn't exist anymore.


29th November, 2017

Drfraker left a reply on Guards Don't Work. • 3 months ago

Does the Kod Class have a password column in the table? It appears that it does not based on the error you are receiving.

21st November, 2017

Drfraker left a reply on Avoiding Dynamic Calls • 3 months ago

This is exactly what form validation is for.

    'email' => 'unique:users,email_address'

You should also enforce this at the database layer:

// in migration

Drfraker left a reply on How To Compare A Date In A Retrieved Model? • 3 months ago

If you are using expire_at you will need to set that in $dates array on your model in order to cast it to a carbon instance when you retrieve it.

protected $dates = [

Otherwise do this:

$expired = Carbon::parse($model->expires_at) <= Carbon::now();

Drfraker left a reply on Eager Loading With Field Filters • 3 months ago

From the docs: https://laravel.com/docs/5.5/eloquent-relationships#eager-loading

Eager Loading Specific Columns

You may not always need every column from the relationships you are retrieving. For this reason, Eloquent allows you to specify which columns of the relationship you would like to retrieve:

$users = App\Book::with('author:id,name')->get();

When using this feature, you should always include the id column in the list of columns you wish to retrieve.

Drfraker left a reply on How To Compare A Date In A Retrieved Model? • 3 months ago

Timestamps in Laravel are cast to instances of Carbon. http://carbon.nesbot.com/

You can check the carbon website for documentation on comparing dates. Make sure you watch the vscode series on Laracasts as it covers packages that might help you identify types etc.

Drfraker left a reply on Need Help With Pulling Data. • 3 months ago

If there isn't a config setting within the original package that allows the package to do this, you will probably have to copy the package files into your own app or create a version of the package from the existing one and require that instead of the original. Then find in the package where it is getting those config settings and write the functionality to get it from the database instead.

Should be pretty straightforward.

Drfraker left a reply on Constructor In Model Class • 4 months ago

I think it should be

public function __construct()
    // your constructor stuff

Or am I missing something?

Drfraker left a reply on Cookie::get Returns Encrypted Value • 4 months ago

Is it possible that you are encrypting your cookies somewhere in your code when you set them? In that case you would be setting an encrypted value that in turn, gets encrypted, and retrieving an enctypted-encrypted value. Therefore, you get an encrypted value after it's decrypted the by the framework the first time. This seems inception-like, right!

Drfraker left a reply on Need Help With Pulling Data. • 4 months ago

Rather than bending the package to your needs, you might scrap the package and write the logic specific to your own needs. I've found that going down the package modification rabbit hole is usually a lot more time consuming than writing something custom in the first place.

Drfraker left a reply on How Do You Store The Wysiwyg In The Database? • 4 months ago

Create a migration for the table:


use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateSomeContentTable extends Migration {

     * Run the migrations.
     * @return void
    public function up()
        Schema::create('some_content', function(Blueprint $table) {

     * Reverse the migrations.
     * @return void
    public function down()


Store the content from the wysiwyg editor in the wysiwys_text column.

Drfraker left a reply on Refactoring Messy Store Method - Need Help Understanding Use Cases From Tutorial Lesson 2 • 4 months ago

If the class BookClubEvent has dependencies, you can put a constructor in that class. Then when you call

new BookClubEvent(Dependency $dependency) 

you can pass the dependencies to it. Better yet if you use the container to create a new instance of BookClubEvent it can build the class with it's dependencies for you.


If the dependencies are resolvable by the container this will be done automatically.

Edit Your Profile

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