vernancheta25

Member Since 2 Years Ago

Experience Points
28,700
Total
Experience

1,300 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
274
Lessons
Completed
Best Reply Awards
0
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.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 6
28,700 XP
Nov
17
1 month ago
Activity icon

Started a new Conversation How To Enable Error Reporting On Mix Webpack

I just noticed that in create-react-app, it warns you about unused keywords and imports in your React code.

But with Laravel mix it doesn't do this. I'm using the react scaffold that comes with Laravel. Any ideas how can I accomplish this with Laravel mix?

Nov
16
2 months ago
Activity icon

Started a new Conversation How To Run Node Script Using Task Scheduler

Hello! I'm trying to use the task scheduler to run a node script that creates the sitemap of the site:

$schedule->exec('/usr/bin/node /home/site/site/current/create-sitemap.js')->daily('06:35');

The only problem is that it doesn't seem to be getting called. Though I can execute it manually when I login via ssh.

Is this a problem with the www-data user not having permission to execute node? how can I solve it? I also checked php.ini and I haven't excluded the exec function. Node was installed via Ubuntu PPA.

I know that the task scheduler works because I tried with a test command which logs something into the logger and it worked:

$schedule->command('test:command')->dailyAt('07:02');

I also tried other variants:

$schedule->exec('node create-sitemap.js')->daily('07:02');
$schedule->exec('/usr/bin/node create-sitemap.js')->daily('07:02');

but none of them seems to work. Any ideas what I could be missing? Thanks in advance.

Nov
03
2 months ago
Activity icon

Started a new Conversation How To Extract General Functionality To A Package

My boss wants me to copy almost the exact same functionality from one project to another to save time. I'm really against this because I will have to copy and paste code, and then maintain both codebases later on. What's your recommendation that I could do to make this task more fun. I don't really want to do the default option which is to copy and paste code.

For context, it's a simple ecommerce website. Users can create products, design their own store, accept orders, etc. I'm thinking of extracting all these functionality to a library or package of sorts which I could then just call with ease from both projects. Something like an ecommerce core library. Obviously, this is going to need some frontend as well. So if I could just extract all those common functionality (with their corresponding frontend views and scripts), put it in a package and then use it from both projects that would be ideal.

Am I going in the right direction? If so, please give me guidance on how should I go about this.

Oct
16
3 months ago
Activity icon

Started a new Conversation JavaScript File Is Triggering Route Middleware

I don't know what's going on but for some reason a JavaScript file is triggering my route middleware.

Here's my code:


Route::middleware(['record_linklistview'])->group(function() {

 
  Route::get('/{linklist_url}/{page_id?}/{page_id2?}/{page_id3?}/{page_id4?}/{page_id5?}', '[email protected]');

});

And here's my middleware:

namespace App\Http\Middleware;

use Closure;

class RecordLinklistView
{
  
    public function handle($request, Closure $next)
    {

         $linklist_url = $request->route('linklist_url');
         info('url: ' . $linklist_url); // this is logging js for some reason
     }
}

So when I access the page, the JavaScript file in that page is also triggering the middleware which results in an error. It's just an ordinary JavaScript file compiled with mix:

<script src="{{ mix('js/LinkListRoot.js') }}"></script>

Interestingly, it doesn't get triggered when I access the file manually on the browser.

In my controller, I have it like so. Which made me think something must be going on in the controller which makes the JavaScript file get triggered:

public function index(FormatLinklistRequest $request, $linklist_url, $page_id = null, $page_id2 = null)
  {
    $linklist = $request->linklist;

    return $this->getLinkListPage([
      'linklist' => $linklist,
      'link_url' => $request->path(),
      'request' => $request
    ]);
  }

But even if I simplify it like this, the JavaScript file is still triggering the middleware:

public function index(Request $request)
{
    $linklist = $request->linklist;
    return view('tester');
}

Here's the simplified view. The JavaScript file is triggered for both simplified code and the current code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>hello</h1>
    <script src="{{ mix('js/LinkListRoot.js') }}" defer></script>
</body>
</html>

My http kernel file looks like:

protected $routeMiddleware = [
   'record_linklistview' => \App\Http\Middleware\RecordLinklistView::class,
]

I'm out of ideas. Please help.

Sep
10
4 months ago
Activity icon

Started a new Conversation Scout Won't Sync If I Use Beanstalkd For Processing Queues

Hello! I need help with Scout. I have an Algolia index which I want to sync with one of my models. This works if I just use sync for the queue driver. But it breaks as soon as I use beanstalkd. I know that beanstalkd works with ordinary jobs created with php artisan make:job. The only problem is with Scout. I already tried the solutions here: https://github.com/laravel/scout/issues/175 but none of them work. The only solution that worked is disabling queue for Scout via the .env file like so:

SCOUT_DRIVER="algolia"
SCOUT_QUEUE=false

But I still want to use beanstalkd with Scout. Is there something additional that needs to be done in order to get these two to work? Based on the documentation, it will just use the default queue driver you set with QUEUE_CONNECTION in your .env.

Thanks!

Aug
27
4 months ago
Activity icon

Started a new Conversation Vue Instantsearch SEO Friendly URL

Hi guys! I’m using Vue instantsearch and I want to make the URL a bit pleasing to the eyes so I followed this guide: https://www.algolia.com/doc/guides/building-search-ui/going-further/routing-urls/vue/#seo-friendly-urls

But the problem is I couldn’t get the category filter to work properly. The route is generated and appended to the address bar when I use the category filter but when I access the same URL again, either by pressing enter on the address bar or refreshing the page, the category filter is stripped off and only the query string remains.

Here’s what I have so far:

routing: {
    router: historyRouter({
        createURL({ qsModule, routeState, location }) {
           
            const urlParts = location.href.match(/^(.*?)\/search/);
            const baseUrl = `${urlParts ? urlParts[1] : ""}/`;

            const queryParameters = {};
            if (routeState.query) {
                queryParameters.query = encodeURIComponent(routeState.query);
            }
            if (routeState.categories) {
                queryParameters.categories = routeState.categories.map(encodeURIComponent);
            }
            if (routeState.page !== 1) {
                queryParameters.page = routeState.page;
            }

            const queryString = qsModule.stringify(queryParameters, {
                addQueryPrefix: true,
                arrayFormat: "repeat",
            });
            return `${baseUrl}search/${queryString}`;
        },
    }),
    parseURL({ qsModule, location }) {
      
        const pathnameMatches = location.pathname.match(/search\/(.*?)\/?$/);

        const { query = "", page, categories = [] } = qsModule.parse(location.search.slice(1));

        const all_categories = Array.isArray(categories) ? categories : [categories];

        return {
            query: decodeURIComponent(query),
            page,
            category: all_categories.map(decodeURIComponent),
        };
    },
  
    stateMapping: {
        stateToRoute(uiState) {
           
            const indexUiState = uiState["my_index"] || {};
           
            return {
                query: indexUiState.query,
                categories: indexUiState.refinementList && indexUiState.refinementList.category,
                page: indexUiState.page,
            };
        },
        routeToState(routeState) {
          
            const category_list = routeState.category ? routeState.category.split(" ") : [];
          
            return {
                my_index: {
                    query: routeState.query,
                    page: routeState.page,
                    refinementList: {
                        category: category_list,
                    },
                },
            };
        },
    },
},

The category is being picked up nicely by the routeToState function. But as soon as it gets to the stateToRoute, the category is no longer there. The name of my index is my_index.

Any ideas what’s wrong with my code?

update

I got it to work on code sandbox. This means that the problem has something to do with Laravel's routing. I'm serving this via the /search route, and the URL I'm constructing in the frontend also has /search. That's what I'm checking for in this code:

const urlParts = location.href.match(/^(.*?)\/search/);
const baseUrl = `${urlParts ? urlParts[1] : ""}/`;

It seems like Laravel is resetting the URL somehow. because even if I use the built-in Algolia route, I still get the same issue:

routing: {
    router: historyRouter(),
    stateMapping: singleIndexMapping("my_index"),
},

Though that doesn't seem to be the case as this only get called once:

public function index()
{
    info('hey I got called');
   	return view('search');
}

UPDATE

I figured out what's causing the URL to reset. I'm using <ais-configure> to sort the results based on the user's current location:

<ais-configure
    :distinct="true"
    :around-lat-lng.camel="coordinates"
    :around-radius.camel="around_radius"
    :hits-per-page.camel="10"
/>

The coordinates is empty by default:

data() {
  return {
    coordinates: ""
  }
}

But when the component is created, I determine the user's location and update the coordinates. This will then trigger it to re-render. Thus losing the initial state supplied through the URL:

created() {
    this.$getLocation().then((coordinates) => {
        this.coordinates = `${coordinates.lat},${coordinates.lng}`;
    });
},

How do I make it so that it doesn't do that?

Aug
20
4 months ago
Activity icon

Started a new Conversation How To Use Route Model Binding On Multiple Models

Hello! I have two models, Town and Business. Then I have a route like this which I want to bind to either the Town or Business model whichever one is accessed:

Route::get('/{url}', function () {

});

I tried doing it like this:

Route::get('/{town}', function (App\Town $town) {
    return $town;
});

Route::get('/{business}', function (App\Business $business) {
    return $business;
});

And then on the Town and Business model, I override the resolveRouteBinding model:

// App\Town
public function resolveRouteBinding($value, $field = null)
{
    return $this->where('slug', $value)->firstOrFail();
}

// App\Business
public function resolveRouteBinding($value, $field = null)
{
    return $this->where('url', $value)->firstOrFail();
}

But this doesn't work, as its always the route that's declared first that gets called. Any ideas?