talelmishali

Member Since 11 Months Ago

Experience Points
59,180
Total
Experience

820 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
535
Lessons
Completed
Best Reply Awards
3
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 12
59,180 XP
Apr
04
1 week ago
Activity icon

Awarded Best Reply on Vue Application + Laravel . Cors Error

Would be easier to help if we would see the middleware.

By the way, great video by Jeffrey Cross-Origin Resource Sharing (CORS)

Apr
03
1 week ago
Activity icon

Replied to Vue Application + Laravel . Cors Error

Would be easier to help if we would see the middleware.

By the way, great video by Jeffrey Cross-Origin Resource Sharing (CORS)

Apr
02
1 week ago
Activity icon

Replied to Laravel Socialite, Google API Not Redirect To Authorized Redirect URIs!?

Can you share the code? Can not really get much from what you posted, doesn't tell much. And are you in a testing environment with google auth or production?

Mar
16
4 weeks ago
Activity icon

Replied to Forms & API Requests (Laravel&Vue&Inertia.js)

Thanks for the heads-up! Checked it with Expose with multiple mobile devices!

Mar
15
4 weeks ago
Activity icon

Replied to Forms & API Requests (Laravel&Vue&Inertia.js)

Thanks for pointing this out!

Activity icon

Started a new Conversation Forms & API Requests (Laravel&Vue&Inertia.js)

Hello! Wondering how others in the community utilizing $inertia.form for an API request, I'll describe my use case and how I work with it at the moment.

I have a checkout page where a user submits a form (new order), the controller generates a payment link, and returns it as part of data object. Upon success, opening a modal with an iframe where the src attribute is the generated payment link. At the moment I am using axios.

Checkout.vue

axios
        .post('endpoint', this.form)
        .then(({ data }) => {
            if (data.success) {
                this.showLoadingBar = false

                this.order_id = data.data.order_id

                this.paymentUrl = data.data.url

                this.showPaymentModal = true

                window.addEventListener(
                    'message',
                    function (event) {
                        if (event.data.success == true) {
                            this.successPayment()
                        }
                    }.bind(this)
                )
            }
        })
        .catch((error) => {
            this.showLoadingBar = false

            this.$page.props.errors = error.response.data.errors
        })

ApiOrderController.php


    /**
     * Store a newly created resource in storage.
     *
     * @param  \App\Http\Requests\OrderRequest $request
     * @return \App\Models\Store\Order
     */
    public function store(OrderRequest $request)
    {
        try {
            $order = $this->orderService->create($request);

            $peymentLink = $this->paymentService->generatePayment($order, new PaymentService());

            $response = [
                'success' => true,
                'code' => 201,
                'data' => [
                    'url' => $peymentLink,
                    'order_id' => $order->id
                ],
               'error' => []
            ];
        } catch (\Throwable $th) {
            $response = [
                'success' => false,
                'code' => 406,
                'data' => [],
                'error' => [
                    'message' => $th->getMessage(),
                ],
            ];
        }

        return new JsonResponse($response, $response['code']);
}

How would you go about it using Inertia without axios both on the server-side and the client-side?

Thanks!

Mar
12
1 month ago
Activity icon

Awarded Best Reply on Map Label To Data From API Response

Not the most elegant solution, but that's where I ended up:

    public function mapDocument($document, $attributes, $map)
    {
        return collect($document)->only($attributes)->map(function ($item, $key) use ($map) {
            return $this->mapper($item, $key, $map);
        });
    }

    protected function mapper($item, $key, $map = [])
    {
        if (! is_array($item) && Arr::has($map, $item)) {
            return $map[$item];
        }

        if (! is_array($item) && Arr::has($map, $key)) {
            if (is_array($map[$key])) {
                return $map[$key][$item];
            }
        }

        if (! is_array($item) && Arr::has($map, $key)) {
            return $map[$key];
        }

        if (is_array($item) && Arr::has($map, $key)) {
            $item = Arr::collapse($item);
            foreach ($item as $itemKey => $itemValue) {
                if (Arr::has($map[$key], $itemKey) && is_array($map[$key][$itemKey])) {
                    $item[$itemKey] = $map[$key][$itemKey][$itemValue];
                }
                if (Arr::has($map[$key], $itemKey) && ! is_array($map[$key][$itemKey])) {
                    $item[$itemKey] = $map[$key][$itemKey];
                }
            }

            return $item;
        } else {
            return $item;
        }

        if (is_array($item)) {
            foreach ($item as $itemKey => $itemValue) {
                return $this->mapper($itemValue, $itemKey, $map);
            }
        }

        return $item;
    }
Activity icon

Replied to Map Label To Data From API Response

Not the most elegant solution, but that's where I ended up:

    public function mapDocument($document, $attributes, $map)
    {
        return collect($document)->only($attributes)->map(function ($item, $key) use ($map) {
            return $this->mapper($item, $key, $map);
        });
    }

    protected function mapper($item, $key, $map = [])
    {
        if (! is_array($item) && Arr::has($map, $item)) {
            return $map[$item];
        }

        if (! is_array($item) && Arr::has($map, $key)) {
            if (is_array($map[$key])) {
                return $map[$key][$item];
            }
        }

        if (! is_array($item) && Arr::has($map, $key)) {
            return $map[$key];
        }

        if (is_array($item) && Arr::has($map, $key)) {
            $item = Arr::collapse($item);
            foreach ($item as $itemKey => $itemValue) {
                if (Arr::has($map[$key], $itemKey) && is_array($map[$key][$itemKey])) {
                    $item[$itemKey] = $map[$key][$itemKey][$itemValue];
                }
                if (Arr::has($map[$key], $itemKey) && ! is_array($map[$key][$itemKey])) {
                    $item[$itemKey] = $map[$key][$itemKey];
                }
            }

            return $item;
        } else {
            return $item;
        }

        if (is_array($item)) {
            foreach ($item as $itemKey => $itemValue) {
                return $this->mapper($itemValue, $itemKey, $map);
            }
        }

        return $item;
    }
Mar
11
1 month ago
Activity icon

Replied to Map Label To Data From API Response

Thanks, it is a way to go over it but it is required prior knowledge of how deep is the nested array. I would prefer to call again a method that would extract each array over and over.

Activity icon

Replied to Map Label To Data From API Response

Thanks for the comment.

To wrap the response back to the client I will use an API Resource.

I am still at the stage prior to it where I receive data from a request and need to convert some data in it to be readable from constants for instance:

	{
	"type" => 320
	}

Really mean for the client

	{	
	"type" => "Credit Card"
	}
Activity icon

Started a new Conversation Map Label To Data From API Response

Hello, I have API results that look something like that:

Illuminate\Support\Collection {#1282
  #items: array:35 [
    "id" => "05c327f4-5sdb-498c-b641-337ecf66ed57"
    "type" => 320
    "number" => 60013
    "documentDate" => "2021-03-11"
    "creationDate" => 1615482203
    "amountDueVat" => 170
    "amountExemptVat" => 0
    "vat" => 28.9
    "amount" => 198.9
    "amountOpened" => 0
    "client" => array:12 [
      "id" => "55d63e90-cf7e-4bb8-9b1f-7400as6094f"
      "name" => "Jow D"
      "department" => ""
      "address" => "Address"
      "city" => "City"
      "zip" => "1234567"
      "country" => "IL"
      "phone" => "7237918237"
      "fax" => ""
      "mobile" => ""
      "emails" => array:1 [
        0 => "[email protected]"
      ]
      "self" => false
    ],
   "payment" => array:1 [
      0 => array:18 [
        "id" => "af5f80d8-e882-4668-bc11-df75958a9323e"
        "date" => "2021-03-11"
        "type" => 3
        "status" => 1
        "price" => 198.9
        "currency" => "ILS"
        "currencyRate" => 1
        "paymentStatus" => 0
        "ref" => []
        "cancellable" => false
        "cardType" => 2
        "cardNum" => "0000"
        "dealType" => 1
        "numPayments" => 1
        "payment" => 1
        "name" => "כרטיס אשראי"
        "description" => "ויזה 0000 / רגיל"
        "amount" => 198.9
      ]
}

And I would like to map over this collection and convert let's say

  "type" => 320

to

  "type" => 'Some String'

Based on an array of conversation:

	return [
		'320' => 'Some String'
	];

And with one level from the results, I can accomplish that, but then if an item from the map function is an array, it can get a bit tricky. Any suggestion on how to go about it?

$results->map(function($item, $key) use ($array){
  
  foreach($array as $typeKey => $typeValue){
  	return $typeKey === $item ? $typeValue : $item;
  }
  
})->toArray();

I was thinking of deligating to a separate function to check for each item from the map function , and then check is that item is an array, in that case, call the same function again and collapse the array to one dimension.

Mar
03
1 month ago
Activity icon

Replied to Laravel Socialite/Google - Local Testing

Thanks! I guess I’ll need to test it with serve command.

Activity icon

Started a new Conversation Laravel Socialite/Google - Local Testing

Hello! When trying to configure OAuth Authorized redirect URIs for the local testing environment (using valet) getting an error from google:

Invalid Redirect: must end with a public top-level domain (such as .com or .org).
Invalid Redirect: must use a domain that is a valid top private domain.

The redirect URI is

http://mysite.test/auth/google/callback

Now I understand it has an issue with the .test domain, but, when I tried to change it using valet domain dev chrome is alerting

Your connection is not private

How do you test in on local environment? Thanks!

Feb
25
1 month ago
Activity icon

Started a new Conversation FormRequest With Inertia.js

Solved.

Feb
05
2 months ago
Activity icon

Commented on Cleaner Webhook Management

Really simple and useful! Thanks.

Feb
04
2 months ago
Activity icon

Commented on Customize Routes

Why is the default middleware for the Dashboard view is auth:sanctum ? The jetstream config default to

'middleware' => ['web'],

the auth config default to

    'defaults' => [
        'guard' => 'web',

and the fortify config default to

'guard' => 'web'

And yet the middleware on the Web.php file indicate auth:sanctum on installation.

Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
    return Inertia::render('Dashboard');
})->name('dashboard');
Jan
28
2 months ago
Activity icon

Replied to Working With SoftDeletes

The routes already grouped by middleware

    Route::middleware(['auth:sanctum', 'verified'])->group(function () {
        Route::delete('products/{product}', [ProductController::class, 'delete'])->name('products.delete');
        Route::delete('products/destroy/{destroyProduct}', [ProductController::class, 'destroy'])->name('products.destroy');
    });

as well with a policy

    public function __construct(ProductService $productService)
    {
        $this->authorizeResource(Product::class, 'product');

        ....
    }
Activity icon

Replied to Working With SoftDeletes

I meant that authorization is not mentioned in the question but there is a logic in place. That is the flow of what I am asking :

  • Product Created
  • User delete the product -> Product deleted first time softDelete
  • User want to delete it from the archive -> Product delete for the second and final time forceDelete
  • The question is not about authorize requests from users. When I am referring to users I am referring to whoever is using the app, not necessarily a user with respect to roles.
Jan
27
2 months ago
Activity icon

Replied to Working With SoftDeletes

Hey @chaudigv, thank you for your comment. I meant more on the route level on how to distinguish between delete() action from the user to forceDelete()

When a user submits a request to delete a model how do you recognize and identify if it's soft delete or hard delete. *When referring to a user I am considering user the person using that logic, not referring to roles or abilities, In my question I am assuming that the user is authorized to perform this action in my question.

Activity icon

Started a new Conversation Working With SoftDeletes

Hey, Was wondering how others working with SofeDeletes, how do you go about distinguishing between when the user wants to forceDelete vs delete?

  • First way - It is not possible to pass data with DELETE request, so I am passing ['destroy' => 1] with a PUT request instead, which works perfectly fine.
  • Second way - Customizing The Resolution Logic and having two separated delete routes for two different methods.

Just looking for some other's opinions and best practices.

  • The question is not about authorization, there is a logic in place for that already, please assume the request as authorized.

First way

Web.php

Route::put('products/{product}', [ProductController::class, 'destroy'])->name('products.destroy');

ProductController.php

    /**
     * Remove the specified resource from storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Product  $product
     * @return \Illuminate\Http\Response
     */
    public function destroy(Request $request, Product $product)
    {
        $request->destroy ? $this->productService->destroy($product) : $this->productService->delete($product);

        back();
    }

ProductService.php

    /**
     * Soft delete the product from the storage.
     *
     * @param \App\Models\Product  $product
     * @return \Illuminate\Http\Response
     */
    public function delete(Product $product)
    {
        return $product->delete();
    }

    /**
     * Permanently destroy the product from the storage.
     *
     * @param \App\Models\Product  $product
     * @return \Illuminate\Http\Response
     */
    public function destroy(Product $product)
    {
        return $product->forceDelete();
    }

Second way

Web.php

        Route::delete('products/{product}', [ProductController::class, 'delete'])->name('products.delete');
        Route::delete('products/destroy/{destroyProduct}', [ProductController::class, 'destroy'])->name('products.destroy');

RouteServiceProvider.php

    public function boot()
    {
        ....

        Route::bind('destroyProduct', function ($value) {
            return Product::withTrashed()->find($value);
        });
    }

ProductController.php

    /**
     * Delete the specified resource from storage.
     *
     * @param \App\Models\Store\Product $product
     * @return \Illuminate\Http\Response
     */
    public function delete(Product $product)
    {
        $this->productService->delete($product);

        back();
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Product  $destroyProduct
     * @return \Illuminate\Http\Response
     */
    public function destroy($destroyProduct)
    {
        $this->productService->destroy($destroyProduct);

        back();
    }

ProductService.php

    /**
     * Soft delete the product from the storage.
     *
     * @param \App\Models\Product  $product
     * @return \Illuminate\Http\Response
     */
    public function delete($product)
    {
        return $product->delete();
    }

    /**
     * Permanently destroy the product from the storage.
     *
     * @param \App\Models\Product  $product
     * @return \Illuminate\Http\Response
     */
    public function destroy($product)
    {
        return $product->forceDelete();
    }

Thanks!

Jan
24
2 months ago
Activity icon

Replied to FormRequest & Policy

Cool, Thanks!

Activity icon

Replied to FormRequest & Policy

Hey @martinbean , I know that is why I asked if is it redundant to have two authorization methods on the same controller (RequestForm, Policy) Or, I can combine it and first check if the user can be engaged with this Request and then check if he is authorized for the method on the controller?

Thank!

Activity icon

Started a new Conversation FormRequest & Policy

Hey! So, everything is working, just looking if that is the proper way and I'm not missing something.

I have Category model with CategoryController on the controller I got:

    public function __construct()
    {
        $this->authorizeResource(Category::class, 'category');
    }

AuthServiceProvider

    protected $policies = [
        Category::class => CategoryPolicy::class,
        Product::class => ProductPolicy::class,
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        Gate::before(function ($user) {
            return $user->hasRole('Super Admin') ? true : null;
        });
    }

And CategoryRequest

    public function authorize()
    {
        return $this->user()->hasAnyRole(['Super Admin']);
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'description' => ['sometimes', 'string', 'max:255'],
        ];
    }

So..the request first hitting the authorize() method on the CategoryRequest which validate that the user has any sort of abilities to engage with that class, then the __construct on that controller will delegate to the policy to verify each an every action on the controller and the Gate::before just do his thing and authorize Super Admin from been checked on each Policy method.

The test is passing and that is just a refactoring.

Or should I go with #authorizing-resource-controllers and just keep the authorization part on the policy, is it working twice and not efficient, or is it another layer of security?

If you plan to handle authorization logic for the request in another part of your application, you may simply return true from the authorize method:

Am I understanding it correctly?

Jan
19
2 months ago
Activity icon

Awarded Best Reply on Js - Laravel Default Style Format

Thanks!

End up using Prettier with the following key and configuration settings in the Package.json file :

    "prettier": {
        "tabWidth": 4,
        "vueIndentScriptAndStyle": true,
        "printWidth": 120,
        "singleQuote": true,
        "jsxSingleQuote": false,
        "trailingComma": "es5",
        "semi": true,
        "arrowParens": "always",
        "bracketSpacing": true
    }

The only thing is I use "printWidth": 120 where in some Vue files included with Laravel/Jetstream the printWidth is much longer and not explicitly clear.

Activity icon

Replied to Js - Laravel Default Style Format

Thanks!

End up using Prettier with the following key and configuration settings in the Package.json file :

    "prettier": {
        "tabWidth": 4,
        "vueIndentScriptAndStyle": true,
        "printWidth": 120,
        "singleQuote": true,
        "jsxSingleQuote": false,
        "trailingComma": "es5",
        "semi": true,
        "arrowParens": "always",
        "bracketSpacing": true
    }

The only thing is I use "printWidth": 120 where in some Vue files included with Laravel/Jetstream the printWidth is much longer and not explicitly clear.

Activity icon

Replied to Js - Laravel Default Style Format

The config for formating the document on save, something like that https://docs.styleci.io/presets#laravel just for js and not PHP

Activity icon

Started a new Conversation Js - Laravel Default Style Format

Hey! Any idea where to find the format style for js on Laravel projects? Something like styleci preset for PHP on Laravel?

Thanks!

Jan
12
3 months ago
Activity icon

Started a new Conversation Transition-group With Tailwindcss Brake The Panel

Hey! Trying to get transitions to work with the example ui component by tailwindcss https://tailwindui.com/components/application-ui/overlays/slide-overs

Per the documentation (Vue) whenever using

<transition-group>

It’s going to render an actual span , which then brake the slide-over panel, any ideas how to go about it?

Jan
11
3 months ago
Activity icon

Replied to Laravel 8 Register A User And Return User Info To Axios

Looks like you returning an instance of

App\Models\User

Where the return must be an instance of RegisterResponse which is an interface who extends to the Responsable contract support. You should implement it and respect the interface.

Jan
10
3 months ago
Activity icon

Replied to Laravel 8 Logout Returning The GET Method Is Not Supported For This Route. Supported Methods: POST.

Not quite sure to be honest. Haven’t code dive to find it, sure you can track it on the framework repository for Laravel 6.0. Let us know what you find.

Activity icon

Replied to Laravel 8 Logout Returning The GET Method Is Not Supported For This Route. Supported Methods: POST.

The logout route is expecting a post request, which you send with Inertia but not with the anchor tag. You can check it with

php artisan route:list -name=logout 

to see the associated request methods and controller to that end point.

Jan
07
3 months ago
Activity icon

Awarded Best Reply on Jetstream Team Cached Between Requests?

Can we see the full test? When using the fresh() method the existing model instance will not be affected, you can try to refresh() to re-hydrate the same model instance, unless saving the fresh() instance to a new variable.

Activity icon

Replied to Something Like 'hasManyThrough' For HasMany / BelongsToMany ( Many-To-Many ) Grandchild Relation ?

Can you clarify what is your end goal?

Do you want to be able to get a count of how many videos exist under a certain category with a specific alphabet?

Can check on the docs if that's what you looking for https://laravel.com/docs/8.x/eloquent-relationships#constraining-eager-loads

Activity icon

Replied to Jetstream Team Cached Between Requests?

Can we see the full test? When using the fresh() method the existing model instance will not be affected, you can try to refresh() to re-hydrate the same model instance, unless saving the fresh() instance to a new variable.

Activity icon

Replied to Pagination With Search Filter

I think what are you looking for is a way to add a query based on the search tag and then paginate?

$users = User::where('tag', $tag)->paginate(15);

What @a4ashraf suggested is a great way to create an endpoint that will have the query string value already appended, useful when needed to be able to share a link for those results.

Activity icon

Replied to Integrity Constraint Violation Error In Tweety App

No problem! Happy to help.

Activity icon

Awarded Best Reply on Integrity Constraint Violation Error In Tweety App

You should pass the unique keys as an array $table->unique(['user_id', 'tweet_id']); as you want the unique index to be on those two foreign id's, otherwise the second parameter you pass is just specifying the index name yourself.

Activity icon

Replied to Integrity Constraint Violation Error In Tweety App

You should pass the unique keys as an array $table->unique(['user_id', 'tweet_id']); as you want the unique index to be on those two foreign id's, otherwise the second parameter you pass is just specifying the index name yourself.

Activity icon

Replied to Integrity Constraint Violation Error In Tweety App

Have you tried to tinker with it and check if a user with an id of 2 can like it? Any tests?

Jan
03
3 months ago
Activity icon

Replied to Created() To Mounted()

Any luck?

export default {
  data() {
    return {
      user: {},
    };
  },
  mounted() {
    this.getUserName();
  },
  methods: {
    getUserName() {
      axios
        .get("/user/api")
        .then((res) => {
          this.user = res.data.user;
        })
        .catch((err) => console.log(err));
    },
  },
};
Dec
31
3 months ago
Activity icon

Replied to Best Way To Store Raw Password Along With Bcrypt Password For Guest Users Who Wants To Create Account

I think it’s worth considering expiring the token security wise, you don’t want some link to access an account been out there for too long. Maybe after expiring the token you can ask the user if he would like to generate new link by clicking a button.

Dec
27
3 months ago
Activity icon

Replied to API Visible To Users?

I want to be able to fetch all the products from the API route regardless of authentication of the user, I want to prevent accessing the URI, to begin with.

Activity icon

Replied to API Visible To Users?

auth:api will only assure me that the user can't access the URI, at the same time the XHR request fails with 401 (Unauthorized)

Activity icon

Started a new Conversation API Visible To Users?

Hello, I have an API route that simply returns a JSON with the product's information from the database, I use the route to for an Axios get request to push into a vue data.

When visiting the API address I can see the JSON response, how should I go about protecting it? I'm not sure I want it visible to users.

How do you usually protect your own API routes to use only from the server requests?

Dec
15
3 months ago
Activity icon

Replied to Simple Hash Watcher For Active Menu Class By Id

Not using routes, It is a single page that has a navigation bar with <a href /> to separate section in the page, I just want to adjust the class of the menu items based on the hash. After that, I will look for an option to adjust those active class by the position of the window.

Activity icon

Started a new Conversation Simple Hash Watcher For Active Menu Class By Id

Hello, Trying to figure a light way to watch for hash change and add active class to navbar item based on it.

data() {
        return {
            pageLocation: window.location.hash
        };
    },
    watch: {
        pageLocation: function() {
            console.log(window.location.hash)
        }
    }

Thank you.