sutherland

sutherland

Member Since 4 Years Ago

Montgomery, AL

Experience Points 130,110
Experience Level 27

4,890 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 808
Lessons
Completed
Best Reply Awards 115
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.

05 Mar
1 year ago

sutherland left a reply on .env File Changes

Yes, you'll notice there's also a config:cache command. Your setup must be doing this for you. Laravel does this for performance reasons. This combines all the configuration settings into a cached file to save a little time on every request. You can learn more here: https://laravel-news.com/config-caching

01 Mar
1 year ago

sutherland left a reply on I Run Composer Update On 5.5 After Adding Some Packages In Composer.json Got Problem With That...

Looks like you need to require a newer version of graham-campbell/markdown compatible with 5.5. Try "graham-campbell/markdown": "^10.0",

sutherland left a reply on Dispatch Another Job From Within Current Job

Great! Don't forget to mark your question solved.

sutherland left a reply on Do I Need To Include Doctrine/dbal In Composer For Laravel 5.5 And Above?

If you already have a migration that modifies existing columns, yes, add it. If not, I'd wait until I need it to add it again.

sutherland left a reply on Do I Need To Include Doctrine/dbal In Composer For Laravel 5.5 And Above?

A fresh installation of 5.5 doesn't require it. You may have previously used it because if you want to modify columns in a migration it is an additional requirement.

sutherland left a reply on Dispatch Another Job From Within Current Job

Try running php artisan queue:work --tries=3 and then if the job is failing it will get pushed to your failed jobs table where you can see the stack track for why it's failing.

sutherland left a reply on Dispatch Another Job From Within Current Job

I think you need to declare the ids property on your SendPush class:

...

class SendPush implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $ids;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($ids)
    {
        $this->ids = $ids;
    }

...

sutherland left a reply on Amazon S3 Region Problem

The disks section should have another entry for s3 like:

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],

    ],

sutherland left a reply on Amazon S3 Region Problem

@splendidkeen check your config/filesystems.php file to see which env values are being read.

sutherland left a reply on Destroy Route Link

What I do if I'm not going to use javascript is create a blade component that contains the form to clean up my table and so I can reuse the delete button in other parts of the application.

sutherland left a reply on My Laravel Is More Than 1GB In Size

Are you running a process that creates that zip file? What does it look like? You might be including the previous zip in your new zip, making the result grow every time it gets zipped.

sutherland left a reply on My Laravel Is More Than 1GB In Size

You might be storing something somewhere other than your storage directory. I would open your project root in your terminal and run du -sh * to get a summary of the size of each subdirectory, and from there drill down into which is using a lot of space.

sutherland left a reply on How To Run A Function Every Time A Certain Class Is Deleted?

No, you don't need to return anything.

You're making it a little more complicated than necessary, here's closer to what you should do:

Page::deleting(function ($page) {
    foreach ($page->drawings as $drawing) {
        $drawing->delete();
    }
});

Drawing::deleting(function ($drawing) {
    $path = app()->basePath() . '/public' . $drawing->path;

    if (file_exists($path)) {
        unlink($path);
    }
});

sutherland left a reply on Blade HasSection, What Is It Really?

You would use it in a master blade file so that a child template could optionally something like include a sidebar, hero image, or other element that might get reused in a few child templates but not in every single one.

If you placed the example given in your master blade file (something like app.blade.php), then in a layout that extends that view (like a home.blade.php) you could use

@extends('app')

@section('navigation')
    Some navigation content
@endsection

@section('content')
    The page content
@endsection

Next you could create another view that doesn't include the navigation section and blade will know not to render anything inside @hasSection.

sutherland left a reply on How To Run A Function Every Time A Certain Class Is Deleted?

@octoxan no, I'd still call $drawing->delete() and make another listener/observer for the Drawing that does the file deletion. That way you don't end up having to repeat the logic in multiple places if a user needs to delete a single drawing without deleting the entire page.

sutherland left a reply on How To Get A File From A Url And Push To S3 Bucket On Behalf Of A User Account?

You could just use the AWS SDK directly instead of the Laravel filesystem which I'm not sure can change s3 credentials on the fly. The linked repo has a demo for adding a file to S3.

sutherland left a reply on MassAssignmentException Error On Field After Form Submission

Three backticks on a separate line before and a line after your code

```

sutherland left a reply on Vue Transition - Content Of V-for Displaying Before Container Transition Completes.

Haven't used Vue transitions but it looks like you just need to add overflow: hidden; to the CSS of the parent element.

sutherland left a reply on How To Run A Function Every Time A Certain Class Is Deleted?

@mrbadr observers are just another way to tie into the same Eloquent events, but like I said you'll need to listen to the Page's model events first to call delete on each Drawing. Otherwise the Drawing's deleting event (regardless of how it's registered) never gets called if it's left solely to the database schema.

sutherland left a reply on How To Run A Function Every Time A Certain Class Is Deleted?

You are going to have to loop through the drawings somewhere and individually call delete on them if you want it to get rid of the files. I wouldn't do it in the controller, instead I'd listen to the deleting event on the Page model then individually delete each Drawing model. That way it will always delete the related records no matter where you call $page->delete() from.

https://laravel.com/docs/5.6/eloquent#events

28 Feb
1 year ago

sutherland left a reply on How To Find Nearest Cities From Latitude And Longitude

Change it to City::selectRaw('id, latitude, longitude, (...))

27 Feb
1 year ago

sutherland left a reply on How To Save Quill.js Values To Database Laravel 5.6

@Drfraker well he had already replied to the wrong information, in that scenario I personally think it's better to post your new suggestion in a new comment so there's a record of what solutions have been tried and eliminated.

sutherland left a reply on How To Save Quill.js Values To Database Laravel 5.6

@Snapey it looks like @Drfraker changed his answer to mine after I posted

sutherland left a reply on How To Save Quill.js Values To Database Laravel 5.6

Quill has a demo of submitting a form on their playground, looks like you'll need a bit of javascript: https://quilljs.com/playground/#form-submit

sutherland left a reply on Problem With Laravel Collectiev

Like I said before, that's exactly what two curly braces is supposed to do, you need the {!! !!} version if you want to contents to be HTML.

https://laravel.com/docs/5.1/blade#displaying-data

sutherland left a reply on Problem With Laravel Collectiev

Two curly braces will HTML encode anything inside, this is good for displaying user input in case it contains any tags. Using the exclamantion point version will directly echo anything inside, which in your case you need so you can output the form HTML.

sutherland left a reply on Select Value Data Not Being Stored

Here's my idea:

<script type="text/javascript">
  $(document).ready(function() {
    $('#programSelect').change(function() {
      $('.scopes').hide();
      $('.scopes select').removeAttr('name');
      $('#' + $(this).val()).show();
      $('#' + $(this).val() + ' select').attr("name", "scope_id");
    });
  });
</script>

Haven't used jQuery in awhile so I know it's not the most efficient way but it should get the job done.

sutherland left a reply on Select Value Data Not Being Stored

It's because you have multiple <select> elements with the same name, and the last one (or it might be the first?) overrides all the other ones. Modify your jQuery to remove the name attribute from the hidden select fields and add the name field to the active one.

sutherland left a reply on How To Find Nearest Cities From Latitude And Longitude

@murilo strange, I almost suggested that but in my config I had it set to true so I thought it wouldn't matter. I guess maybe I have that configured somewhere else...

sutherland left a reply on Using Trait On Observer

If all the observers are going to have the same methods, why not just create a generic observer like ActivityObserver that uses the generic model class?

So instead of your ThreadObserver having something like this:

public function created(Thread $thread)
{
    //
}

You'd do something like this:

use Illuminate\Database\Eloquent\Model;

...

public function created(Model $model)
{
    //
}

Then the observer will be able to be registered for any model.

sutherland left a reply on MethodNotAllowedHttpException Error

It's still submitting the form the old fashioned way, you need to prevent the default action like so:

<script>
        $('#loginForm').submit(function (e) {
            e.preventDefault();
            initLogin($('#email').val(),$('#password').val());
        });
</script>

sutherland left a reply on How To Preview Image Before Uploading.

Check out this lesson: https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/65

It might be named AJAX image uploads but it also shows how you can use JavaScript to display a selected file before uploading.

Here's some more info with a jQuery example as well: https://stackoverflow.com/questions/24837646/onchange-file-input-change-img-src-and-change-image-color

sutherland left a reply on Auto Data Entry Into Desktop Application

I think it's safe to assume it's not his desktop application, hence the reason he's looking for another way to import the data.

sutherland left a reply on How To Find Nearest Cities From Latitude And Longitude

Yes, MySQL 5.7 and no issues here.

sutherland left a reply on Boolean Field Returns Empty When Set To False In Blade

That's the way echoing a boolean as a string works. You should do the following:

var xxx = "{{ Auth::user()->alertConfigs->progress_bar ? '1' : '0' }}"

sutherland left a reply on Observer Is Not Firing.

Are you sure you've imported ThreadObserver at the top of your AppServiceProvider and given it the correct namespace in ThreadObserver.php?

sutherland left a reply on How To Find Nearest Cities From Latitude And Longitude

You don't need a distance column, the raw select statement is calculating it for you.

I just tested this on Laravel 5.6 with no issues:

$latitude = 25.000;
$longitude = 25.000;

$cities = City::selectRaw('*, ( 6367 * acos( cos( radians(' . $latitude . ') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(' . $longitude . ') ) + sin( radians(' . $latitude . ') ) * sin( radians( latitude ) ) ) ) AS distance')
    ->having('distance', '<', 30)
    ->orderBy('distance')
    ->get();

What database driver are you using?

sutherland left a reply on Why It Appears This Error: "Route [rtypes.update] Not Defined"?

Can you show your update and store controller methods? I still think you need to update your 'rtypes.store' route like this:

Route::post('conference/update/{id}/rtypes', [ 'uses' => '[email protected]', 'as'=>'rtypes.update']);

Route::post('conference/store/{id}/rtypes', [ 'uses' => '[email protected]', 'as'=>'rtypes.store']);

You said when a user "stores a registration type it goes to a blank page" so it sounds like you just need to perform a redirect at the end of your store() method?

sutherland left a reply on Queue Worker Query With Locks

I'd assume it's to avoid having multiple workers do something to the same job at the same time? Is it causing a problem?

sutherland left a reply on Why It Appears This Error: "Route [rtypes.update] Not Defined"?

I don't understand what the code and data is exactly trying to accomplish, but if the view is the same and the controller is the same, why do you need two different actions for your form? Can you break down what exactly what the site is doing?

sutherland left a reply on Why It Appears This Error: "Route [rtypes.update] Not Defined"?

You don't have to create another view, just a controller method that uses the same view.

sutherland left a reply on Why It Appears This Error: "Route [rtypes.update] Not Defined"?

Ah, I see now. Both your routes (rtypes.store and rtypes.update) are using a POST request with the same URL, so it must only be registering one of them. Try changing the store URL to something like 'conference/store/{id}/rtypes'

sutherland left a reply on Why It Appears This Error: "Route [rtypes.update] Not Defined"?

If you run php artisan route:list in your terminal do you see the rtypes.update route listed?

sutherland left a reply on How To Find Nearest Cities From Latitude And Longitude

The raw query in the select is using AS to calculate the distance. I just copied it from an old Laravel 4 project so I'm not sure what's changed.

Maybe try changing ->having('distance', '<', 25) to ->where('distance', '<', 25)?

sutherland left a reply on How To Find Nearest Cities From Latitude And Longitude

If you already have the latitude and longitudes in your database you might as well query them yourself. This is from a project where I'm doing something similar:

$cities = City::select(DB::raw('*, ( 6367 * acos( cos( radians('.$latitude.') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians('.$longitude.') ) + sin( radians('.$latitude.') ) * sin( radians( latitude ) ) ) ) AS distance'))
    ->having('distance', '<', 25)
    ->orderBy('distance')
    ->get();

sutherland left a reply on Add IP To Contact Form

That's because your IP column in your table doesn't allow null values. Contact::create() tries to insert the data without an IP defined yet and MySQL shows an error as it should. Here's what you can do:

    public function store(ContactRequest $request)
    {
        $contact = new Contact($request->all());

        $contact->ip = $request->ip();

        $contact->save();
    }

Now it's only executing the query once after everything has been filled.

sutherland left a reply on Checkbox Not Displaying A Tick

Then define an accessor like this on your model:

    public function getDciAttribute($value)
    {
    if (is_null($value)) {
                return [];
        }

        return $value;
    }