Flor

Flor

Member Since 7 Months Ago

Copenhagen

Experience Points
12,760
Total
Experience

2,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
103
Lessons
Completed
Best Reply Awards
4
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 3
12,760 XP
Aug
08
1 month ago
Activity icon

Replied to Vue Script Not Working

You could make a JSON object in the <head> of your site, like:

<script>
  window.App = {!! json_encode([
    'rolesSelected' => $user->roles->pluck('id')
  ]) !!}
</script>

Then in your app.js file, you could do:

const app = new Vue({
    el: '#app',
    data: {
      rolesSelected: window.App.rolesSelected,
    }
});
Activity icon

Replied to Stop Schedule Task Laravel Homestead

The documentation for Homestead says, that you configure it in Homestead.yaml:

sites:
    - map: homestead.test
      to: /home/vagrant/project1/public
      schedule: true

https://laravel.com/docs/7.x/homestead#configuring-cron-schedules

So if you've got that configuration, just remove it from Homestead.yaml

Jun
07
3 months ago
Activity icon

Awarded Best Reply on Using Response()->json From Helpers

A method in a controller MUST return something, otherwise no response is being generated.

The response() method is not setting a global response object, but rather making a ResponseFactory.

Activity icon

Replied to Using Response()->json From Helpers

A method in a controller MUST return something, otherwise no response is being generated.

The response() method is not setting a global response object, but rather making a ResponseFactory.

Activity icon

Replied to Should I Register My SPA User With A Token ?

Is the backend only serving your Nuxt SPA? Because if that's the case, I would strongly recommend you to look at Sanctum - It's an offical package that allows an SPA to authenticate with a Laravel API backend with cookies, removing the need for sending tokens back and forth.

Activity icon

Replied to Using Response()->json From Helpers

It's hard to help, without any code snippets.

Are you returning the returned value from your helper class in your controller?

class ResponseController extends Controller
{
    public function index()
    {
        return MyHelperClass::getFormattedResponse();
    }
}

Besides that, it sounds like you could benefit from using transformers. There's an excellent package from The PHP League here: https://fractal.thephpleague.com/transformers/

Activity icon

Replied to Video On Demand

If you have videos in proper format, you could just embed them with the HTML5 video tag:

<video width="1280" height="720" controls>
  <source src="https://s3.amazonaws.com/path/to/video.mp4" type="video/mp4">
  <source src="https://s3.amazonaws.com/path/to/video.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

Other than that, Amazon has its own "Video on Demand" solution and guide:

https://aws.amazon.com/solutions/implementations/video-on-demand-on-aws/

Jun
06
3 months ago
Activity icon

Replied to Vue Reactivity Issue

Ok, yeah - In my book, that should work too. You can always add a watcher to watch for state changes. So if the state changes properly, you should be able to listen to it.

Here's a nice blogpost about watching state changes: https://dev.to/viniciuskneves/watch-for-vuex-state-changes-2mgj

Activity icon

Replied to Vue Reactivity Issue

How are you fetching the state object in the component? Are you getting it from a computed getter?

Data properties are not reactive, but computed getters are.

Activity icon

Replied to Vue Reactivity Issue

When mutating the state, you should change the entire state object, and not just part of it. So you should do something like this:

const teams = state.teams;
teams[team].members.splice(gymnast, 1);
state.teams = teams;

You can read more here: https://vuex.vuejs.org/guide/mutations.html#mutations-follow-vue-s-reactivity-rules

Jun
01
3 months ago
Activity icon

Replied to Using Watch To Remove The Text-danger While Typing The Input

Instead of using watch, you should probably use an input event on the fields.

For instance:

<input type="text" name="jobName" @input="clearError('jobName')" />

and then add a method:

methods: {
  clearError: function(field) {
    this.$set(this.error, field, null);
  }
}
Activity icon

Replied to The Command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm Root -g` Node

Could be an issue with missing modules.

Error: Cannot find module 'puppeteer'

Have you run npm install on the server?

Activity icon

Awarded Best Reply on Nuxt Pages

The underscore prefix on nuxt pages, will make the router interpret the route as a route variable.

If you want a plain page called "register", you should create a file called pages/register.vue, not pages/_register.vue as I am assuming you are doing now.

You can read more about dynamic routes here: https://nuxtjs.org/guide/routing#dynamic-routes

Activity icon

Replied to Nuxt Pages

The underscore prefix on nuxt pages, will make the router interpret the route as a route variable.

If you want a plain page called "register", you should create a file called pages/register.vue, not pages/_register.vue as I am assuming you are doing now.

You can read more about dynamic routes here: https://nuxtjs.org/guide/routing#dynamic-routes

Activity icon

Awarded Best Reply on Delete User's Avatar Folder After His Deletion.

As it seems, you are deleting the user twice.

$user->delete();

if ($user->delete()) {
...

I think you should look into events for the user model.

You could do something like:

class User extends Authenticatable
{
    protected static function boot()
    {
        parent::boot();

        self::deleted(function (User $user) {
            if (Storage::exists($storagePath)) {
                Storage::deleteDirectory($storagePath, 'public');
            }

            $user->notify(new SendEmailToUserReferingToDeletingProfile($user));
        });
    }
}

Then the user model will take care of whatever needs to happen when it's being deleted.

Activity icon

Replied to Delete User's Avatar Folder After His Deletion.

As it seems, you are deleting the user twice.

$user->delete();

if ($user->delete()) {
...

I think you should look into events for the user model.

You could do something like:

class User extends Authenticatable
{
    protected static function boot()
    {
        parent::boot();

        self::deleted(function (User $user) {
            if (Storage::exists($storagePath)) {
                Storage::deleteDirectory($storagePath, 'public');
            }

            $user->notify(new SendEmailToUserReferingToDeletingProfile($user));
        });
    }
}

Then the user model will take care of whatever needs to happen when it's being deleted.

Activity icon

Replied to Composer Install Fails: SSL: Connection Reset By Peer

Have you thought about using something like Homestead or Valet

Homestead would take away a bunch of your headaches, whereas Valet might not. You can read about the differences here: https://laravel.com/docs/7.x/valet#valet-or-homestead

May
28
3 months ago
Activity icon

Replied to Laravel Database Connection

Yeah, but database connections still works like this in Laravel. Have you tried the solution?

Activity icon

Replied to Composer Install Fails: SSL: Connection Reset By Peer

It sounds like php does not have a valid path to ssl certificates. You can download curl ssl certificates here:

https://curl.haxx.se/docs/caextract.html

And you can read about configuring PHP with the certificates here:

https://stackoverflow.com/questions/35197412/ssl-error-at-composer-install

If you want to avoid installing composer manually, you could do one of the following:

Windows:

Try using the Windows installer, that will handle everything for you.

MacOS

You can install composer with brew: https://gist.github.com/shashankmehta/6ff13acd60f449eea6311cba4aae900a

Linux

You should be able to install via the distros package manager, for instance: apt-get install composer

Activity icon

Replied to Composer Installed But Getting This....,composer Is Not Recognized

Ok.

Have you tried inspecting your PATH environment variable? Just run PATH in your cmd. It should contain: C:\ProgramData\ComposerSetup\bin and also C:\Users\Q c\AppData\Roaming\Composer\vendor\bin

Just some debugging steps to try:

  • Closing all command windows and reopening them - this will "refresh" the PATH.
  • Restarting your computer
  • Uninstall and reinstall composer
Activity icon

Replied to Composer Installed But Getting This....,composer Is Not Recognized

Did you install it via the windows installer? https://getcomposer.org/download/

Or did you install it some other way? It might not be added to your PATH environment variable on your system:

https://getcomposer.org/doc/00-intro.md#installation-windows

Activity icon

Awarded Best Reply on "Favorites" Relationship - I Am Stuck

Oh, I just saw, that you've assigned the class Product::class in the posts method on your User class. Is this intentional? You can, by the way, just reference the classes like so, since Laravel will assume the table columns in the pivot table to be user_id and post_id:

User class:

public function posts() 
{
    return $this->belongsToMany(Post::class);
}

Post class:

public function users()
{
    return $this->belongsToMany(User::class);
}
Activity icon

Replied to "Favorites" Relationship - I Am Stuck

Oh, I just saw, that you've assigned the class Product::class in the posts method on your User class. Is this intentional? You can, by the way, just reference the classes like so, since Laravel will assume the table columns in the pivot table to be user_id and post_id:

User class:

public function posts() 
{
    return $this->belongsToMany(Post::class);
}

Post class:

public function users()
{
    return $this->belongsToMany(User::class);
}
Activity icon

Replied to "Favorites" Relationship - I Am Stuck

You've defined the relationship between users and posts properly, but you are missing a pivot table. Laravel will look for a table called post_user, so you'll need to create a new table via a migration:

php artisan make:migration create_post_user_table

In this migration, you'll need to define the two id's. You could do it like this:

Schema::create('post_user', function (Blueprint $table) {
    $table->unsignedBigInteger('post_id');
    $table->unsignedBigInteger('user_id');
    $table->timestamps();
    $table->primary(['post_id','user_id']);
})

This will create the pivot table, and Laravel will now be able to persist the relationships. You can read more about Many to Many relationships here: https://laravel.com/docs/7.x/eloquent-relationships#many-to-many

And if you need to assign more data to the relationship, take a look at pivot models here: https://laravel.com/docs/7.x/eloquent-relationships#defining-custom-intermediate-table-models