sutherland

sutherland

Member Since 4 Years Ago

Montgomery, AL

Experience Points
130,760
Total
Experience

4,240 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
810
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.

Level 27
130,760 XP
Mar
05
1 year ago
Activity icon

Replied to .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, because combining all the configuration settings into a single cached file saves a little time on every request. You can learn more here: https://laravel-news.com/config-caching

Mar
01
1 year ago
Activity icon

Replied to 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",

Activity icon

Replied to Dispatch Another Job From Within Current Job

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

Activity icon

Replied to 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.

Activity icon

Replied to 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 added it to your composer file because if you want to modify columns in a migration it is an additional requirement.

Activity icon

Replied to 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 trace for why it's failing.

Activity icon

Replied to 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;
    }

...
Activity icon

Replied to 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'),
        ],

    ],
Activity icon

Replied to Amazon S3 Region Problem

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

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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);
    }
});
Activity icon

Replied to 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.

@extends('app')

@section('content')
    This is a page that doesn't need any navigation.
@endsection
Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to MassAssignmentException Error On Field After Form Submission

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

```
Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to 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

Edit: To further explain, right now your database schema must be using on delete cascade to remove the related records, which is a nice convenience, but that happens on the database layer so Laravel isn't aware it needs to call your delete logic on those records.

Feb
28
1 year ago
Activity icon

Replied to How To Find Nearest Cities From Latitude And Longitude

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

Feb
27
1 year ago
Activity icon

Replied to 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.

Activity icon

Replied to How To Save Quill.js Values To Database Laravel 5.6

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

Activity icon

Replied to 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

Activity icon

Replied to Problem With Laravel Collectiev

Like I said before, that's exactly what two curly braces is supposed to do to protect if you are displaying something a user has saved (like their name), but you need the {!! !!} version if you want to allow the contents to contain HTML.

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

Activity icon

Replied to Problem With Laravel Collectiev

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

Activity icon

Replied to 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.

Activity icon

Replied to 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?) is likely null and 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.

Activity icon

Replied to 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...

Activity icon

Replied to Using Trait On Observer

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

So instead of your ThreadObserver and PostObserver 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.

Activity icon

Replied to 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>
Activity icon

Replied to 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

Activity icon

Replied to 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.

Activity icon

Replied to How To Find Nearest Cities From Latitude And Longitude

Yes, MySQL 5.7 and no issues here.

Activity icon

Replied to 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 if you want a 1 or 0:

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

Replied to 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?

Activity icon

Replied to 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( ? ) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians( ? ) ) + sin( radians( ? ) ) * sin( radians( latitude ) ) ) ) AS distance', [$latitude, $longitude, $latitude])
    ->having('distance', '<', 30)
    ->orderBy('distance')
    ->get();

What database driver are you using?

Activity icon

Replied to 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]tore', '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?

Activity icon

Replied to 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?

Activity icon

Replied to 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?

Activity icon

Replied to 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.

Activity icon

Replied to 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'

Activity icon

Replied to 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?

Activity icon

Replied to 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', '<', 30) to ->where('distance', '<', 30)?

Activity icon

Replied to 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 an older project (so may not work or be the best method) 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();
Activity icon

Replied to 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.

Activity icon

Replied to 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;
    }