ignisrzeus

ignisrzeus

Member Since 2 Years Ago

Experience Points
2,710
Total
Experience

2,290 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
0
Lessons
Completed
Best Reply Awards
2
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 1
2,710 XP
Jul
09
2 months ago
Activity icon

Awarded Best Reply on How To Make Recursive Calling Of Subitems In Vuejs2?

Hi! Here's an excellent example of handling Recursive Components in VueJS

https://alligator.io/vuejs/recursive-components/

This covers everything you need. Cheers!

Jul
08
2 months ago
Activity icon

Replied to How To Make Recursive Calling Of Subitems In Vuejs2?

Hi! Here's an excellent example of handling Recursive Components in VueJS

https://alligator.io/vuejs/recursive-components/

This covers everything you need. Cheers!

Activity icon

Replied to Laravel Passport How To Logout User?

Have you checked if the user has multiple tokens? Because it is possible.

        $request->user()->tokens->each(function ($token, $key) {
            $token->delete();
        });

Will delete every user's token. Hope this helps.

Activity icon

Replied to Get Websocket Data In Laravel Controller

I'm not sure myself if you can directly do this. However, you can simply call an ajax request when your receive the data from the websocket link, then pass the received data thru ajax so that you can use the data in the controller.

Jul
03
2 months ago
Activity icon

Replied to Access Denied For User 'forge'@'localhost' (using Password: YES)

I see. I'm seeing some related issues regarding Laravel Forge not retrieving the correct .env file. Could this be related to my issue?

Can't seem to move forward because of this dilemma. Any additional help would be amazing. Thanks!

Jul
02
2 months ago
Activity icon

Replied to Access Denied For User 'forge'@'localhost' (using Password: YES)

Hi! I'm completely lost here. I'm very sorry for being clueless about Laravel Forge. Few questions here

  1. When Enter Password prompts in:
[email protected]:~$ mysql -uforge -p
Enter password:

What password should I input? From my understanding, I am supposed to input the DB_PASSWORD under the .env file -- which is the same password that is emailed to be by Laravel Forge.

  1. In relation to 1, when prompted for the password of root, I do not know what I am supposed to input. I checked my email, and I did not receive a password for root unfortunately.

Here's a sample of the email I got from Laravel Forge

Name:	SomeWebsiteName
IP Address:	SomeIPAddress
Username:	forge
Sudo Password:	SomeSudoPassword
Database Username:	forge
Database Password:	SomeDBPassword

This is the only email I received that has a password inloved in it.

Hope this helps clarify things. Thanks!

Activity icon

Replied to Access Denied For User 'forge'@'localhost' (using Password: YES)

Hi! Thank you for the response!

I checked my database users and confirmed that Laravel Forge created user "forge" right away after creating the "forge" server.

And also, i can confirm that user "forge" exists because I was able to access the database via SSH. My terminal now starts at:

[email protected]

My problem occurs when entering the DB_PASSWORD, it seems as if it the .env is not reflecting the correct DB_PASSWORD unfortunately.

[email protected]:~$ mysql -uforge -p
Enter password:
ERROR 1045 (28000): Access denied for user 'forge'@'localhost' (using password: YES)

If i am assuming the wrong things, I apologize in advance as I am new to deploying Laravel Applications. Hopefully I made sense. Thank you!

Activity icon

Replied to How To Input Into Array As Numbers

Hi! There's so much optimizing here in your code. This is not the "Vue" way to do this, as you can simply have a v-model for each totalScore and bind it to each via index (totalScores[score_index]) or something along those lines. I can help you design the form for that, but here are some quick fixes for you:

  1. A reason why your values are behaving like strings is because you used value=1, value=2 and so on and so forth. What you should have instead used is
   <td class="text-center" style="vertical-align: middle;">
                            <input type="radio" @change="onChange($event, index)" :name="question.name" :value='3'>
                        </td>

Take note of the change from

value=3 ----------> :value='3'
  1. If the problem persists, then simply your strings to numbers using parseInt!
    onChange(event,index) {
              let data = parseInt(event.target.value);              
              Vue.set(this.totalScores, index, data);             
          }

This is a quick fix, but you should look into properly binding your forms into v-models! You can ask questions here if you want to do this the "Vue" way.

Hope this helps!

Activity icon

Replied to Laravel 7 Add Checks Before FormRequest Validation

Hi! I'm not sure exactly what you're asking, but if you simply want to validate your form whether to push or not, you may use Laravel's validate function

public function store(Request $request)
{
    $validatedData = $request->validate([
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
    ]);
}

In your case, if I understood your question correctly, something like this should do the trick

public function store(Request $request)
{
    $validatedData = $request->validate([
        'products' => 'required',
    ]);

// If products is not null, do rest of the code below...
}

Here's a link for everything about validation in Laravel! https://laravel.com/docs/7.x/validation

Hope this helps!

Activity icon

Started a new Conversation Access Denied For User 'forge'@'localhost' (using Password: YES)

Good Day Laracasts!

Today is my first time deploying a website via Laravel Forge. I've been following BitFumes' guide on how to deploy a laravel app via Forge, and everything has been working fine up until the database connection.

I have successfully logged in via SSH in my database, but whenever i run

mysql -uforge -p

I always get the result:

Access denied for user 'forge'@'localhost' (using password: YES)

The password that I input is the one that is located in the .env file in the Laravel Forge Environment section.

Currently stuck as i cannot successfully access my database because of this dilemma.

As of the moment, I'm not sure what I need to show you guys, but i simply named my database "forge" and didn't change anything as of the moment as i tried to strictly follow BItFumes' guide.

However, these are crucial files that I think are related to my dilemma:

database.php

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

config\app.php

 'key' => env('APP_KEY'),

.env

APP_NAME=Laravel
APP_ENV=production
APP_KEY=base64:Jihb8EG1he78Cv5ZhG8CRxAfyic3bWm+FetJbXWTqPg=
APP_DEBUG=false
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD="somerandomgeneratedpassword"

As I have stated above, I copy and simply paste "somerandomgeneratedpassword" (Obv. a placeholder) in the password section when being asked after running "mysql -uforge -p".

Any help will be greatly appreciated. Thank you very much!

May
22
4 months ago
Activity icon

Awarded Best Reply on Mood Off ! What You Do When It Happen?

Best advice I can give you is that If you're not feeling like doing it right now, then just simply don't do it -- only if you are confident you can accomplish it the next day. Coding is such a momentum based activity. If you don't have the momentum, you'll just be distracted all the time and end up doing little to no work.

However, if you do need to accomplish it right away, then just think about the satisfaction of finishing a module and your reward from it (may it be financial, grades, or whatever). Just remind yourself all the intrinsic and extrinsic rewards that you will get from accomplishing the module and you'll be grinding again in no time :)

May
18
4 months ago
Activity icon

Replied to Laravel Websockets Beyondcode

Hi try looking into this: https://github.com/beyondcode/laravel-websockets/issues/285

TLDR: "I solved this in my ENV by providing both of my Valet certificates exact paths. Previously, I had them aliased to user path using ~/. If this is your case, you'll need to provide with exact paths."

Might be helpful if you're using Laravel Valet.

Activity icon

Replied to Laravel Websockets Beyondcode

Got it. I clearly remember this situation, i dont know if you're up to it but it's up to you to attempt this. It worked on my end, hopefully it works for you too!

Instead of running php artisan serve, try setting it up on a virtual host. I remember back then, when using php artisan serve, I couldn't make my laravel websockets work. Then I tried using a virtual host so that I wont have a need for php artisan serve, then it suddenly worked like a charm.

For now there are 2 key differences in our application

  1. I'm using an API to authorize my usage of echo, while you are using csrf token.
  2. You're running yours on php artisan serve, while I run mine on a virutal host.

I can't seem to find any other key differences that are hindering yours from working as of now...

Activity icon

Replied to Laravel Websockets Beyondcode

Oh and I also forgot to ask. Is this running in your localhost server or is it deployed? If it's deployed then you should look into your certificates.

Activity icon

Replied to Laravel Websockets Beyondcode

Have you tried removing the middleware? Just so we can isolate if it is a middleware-related problem (most authentication problems in laravel-websockets are middleware related).

Please try and remove the middleware first, and remove the authorization header in your window.Echo. If the problem still persists, let me know so we can look into other possible problems that are affecting your application

Activity icon

Replied to How To Get Token Key Without User Name And Password ?

Excellent! Goodluck on your project!

Activity icon

Replied to Laravel Websockets Beyondcode

Unfortunately I have yet to test this in a non api-related scope.

When firing an event, what error do you receive now? Do you still receive the same error?

Activity icon

Replied to Change Box Width And Color

index.html

<div id="app">
    <div class="demo" :class="color" :style="{'width': width +'px'}"></div>
<hr>
<input type="text" v-model="color">
<input type="text" v-model="width">
</div>

app.js

new Vue({
el: '#app',
data: {
	color: 'gray',
	width: 100
},

style.css

<style>
.demo {
height: 100px;
background-color: gray;
display: inline-block;
margin: 10px;
}

.red {
background-color: red;
}

.green {
background-color: green;
}

.blue {
background-color: blue;
}

.gray {
background-color: gray;
}
</style>

Your app isn't working probably because it's still referencing the data from your app.js. Please try this instead.

Activity icon

Replied to Laravel Websockets Beyondcode

If this is the case, there is clearly something wrong in your configuration. Please take a loot at my general config example.

Also, you may need to clear your cache before testing this!

php artisan config:clear

And again, if you aren't protecting your routes, then just delete the authorization headers first in the bootstrap.js file for the meantime. I have a feeling that your routes are protected by a group middleware tho -- i might be wrong, so please do check if your routes are protected or not.

Activity icon

Replied to Laravel Websockets Beyondcode

Here's a general setup that should work for any machine:

.env file:

  • values of key secret do not matter for now. you can input whatever you want there
PUSHER_APP_ID=123
PUSHER_APP_KEY=abc
PUSHER_APP_SECRET=def
PUSHER_APP_CLUSTER=mt1 

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

broadcasting.php file:

    'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'host' => '127.0.0.1',
                'port' => 6001,
                'scheme' => 'http'
            ],
        ],

bootstrap.js file:

const token = window.localStorage.getItem('access_token');

import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');
window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    wsHost: window.location.hostname,
    wsPort: 6001,
    disableStats: true,
    auth:{
        headers:{
            Authorization: `Bearer ${token}`
        }
    }
});

For the case of the bootstrap.js file, please do make sure that you have already stored your access token in your localStorage. Have you done that as well?

And most importantly, I assume that you have done everything you need to do from the installation page: https://docs.beyondco.de/laravel-websockets/1.0/getting-started/installation.html

Do attempt to copy paste this in the designated files. Best of luck!

Activity icon

Replied to Notification System

@michaloravec has pretty much summed up what you need to know when handling notifications in Laravel, but just to add, you may want to look at https://docs.beyondco.de/laravel-websockets/ if part of your requirements is making your notifications realtime to the user. Otherwise, all you need is what @michaloravec has commented above.

Goodluck!

Activity icon

Replied to Mood Off ! What You Do When It Happen?

Best advice I can give you is that If you're not feeling like doing it right now, then just simply don't do it -- only if you are confident you can accomplish it the next day. Coding is such a momentum based activity. If you don't have the momentum, you'll just be distracted all the time and end up doing little to no work.

However, if you do need to accomplish it right away, then just think about the satisfaction of finishing a module and your reward from it (may it be financial, grades, or whatever). Just remind yourself all the intrinsic and extrinsic rewards that you will get from accomplishing the module and you'll be grinding again in no time :)

Activity icon

Replied to Laravel Websockets Beyondcode

If your routes are secured, then you do need authorization header.

One way to implement is something like this:

const token = window.localStorage.getItem('access_token');
import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');
window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    wsHost: window.location.hostname,
    wsPort: 6001,
    disableStats: true,
    auth:{
        headers:{
            Authorization: `Bearer ${token}`
        }
    }
});


Also, do try if "yoururl.com/laravel-webosckets" is working.

Hope this helps.

Activity icon

Replied to Change Box Width And Color

Copy paste this entire thing:

<template>
<div>
    <div class="demo" :class="color" :style="{'width': width +'px'}"></div>
<hr>
<input type="text" v-model="color">
<input type="text" v-model="width">
</div>
</template>

<script>
export default{
	data(){
		return{
			color: "gray",
			width: 100
		}
	}
}
</script>

<style>
.demo {
height: 100px;
background-color: gray;
display: inline-block;
margin: 10px;
}

.purple{
    background-color: purple;
}
.red {
background-color: red;
}

.green {
background-color: green;
}

.blue {
background-color: blue;
}

.gray {
background-color: gray;
}
</style>

I just tested it. You probably just didn't set up your templates right or something. But anyway just copy paste that code. I even tried adding a new color "purple" to see if it works and it did.

Hope this helps

Activity icon

Replied to Laravel Websockets Beyondcode

Hi! If your routes are protected by a middleware, say for example an api middleware, you would need to pass an authorization bearer header before you can use it.

Can i see the route where you using Echo? Also, you are running php artisan websockets:serve right?

Activity icon

Replied to Change Box Width And Color

Hi i was giving a general example on how you want to implement this, but this is how I would do it:

<div class="demo" :class="color" :style="{'width': width +'px'}"></div>
<hr>
<input type="text" v-model="color">
<input type="text" v-model="width">

<script>
export default{
	data(){
		return{
			color: "gray",
			width: 100
		}
	}
}
</script>

<style>
.demo {
height: 100px;
background-color: gray;
display: inline-block;
margin: 10px;
}

.red {
background-color: red;
}

.green {
background-color: green;
}

.blue {
background-color: blue;
}

.gray {
background-color: gray;
}
</style>

Activity icon

Replied to 404 Not Found

Hi! Please post your web routes so we can have a look if you are using named routes or not. You should have a route there something like

Route::get('your_url_to_dashboard', [
    'as' => 'dashboard', 'uses' => '[email protected]'
]);

Then, your redirect should look something like this:

return redirect()->route('dashboard');

Hope this helps you.

Activity icon

Replied to How To Get Token Key Without User Name And Password ?

You could store the token key in your local application storage, then have a module for it in your vuex so that you can easily get and destroy the token using actions/mutations.

A case can be made that the you should use cookies to store your token, but it's all up to you based on your requirements.

[EDIT: Woops I just realized you are not using VueJs for this one lol.]

If you are not using VueJs for this one, you can still store it in your local application storage, then just get it via javascript using localStorage.getItem("access_token"). Then, whenever you make a call, just pass the token as an Authorization Bearer.

May
17
4 months ago
Activity icon

Replied to Avoid Page Refresh In Vuejs Navigation

HI!! I'm not sure if you've figured out how to do this, but I believe you do not have a nested router view in your VueJs Application. You have your first router view to handle all components in the page that you do not want to be refreshed every movement (This could be your sidebar, adminbar, footer, etc.) Then inside that router view, you have another router view. This "child" router view will be the only affected by the changes during navigation.

Let me know if you still haven't figured this one out. Thanks

Activity icon

Replied to Change Box Width And Color

You are giving the colors based on class name.

You should instead have something like this

<div class ="demo" :class="color">

As for the styling, your first parameter should be the style name, and then its value

<div class ="demo"    :style="{ 'background-color': color}">

Let me know if it works. Thanks!

Activity icon

Replied to Vuex Module Reuse Best Practices

Hi!! Thank you for the response, but I have found that the solution to this was to export it as a constant, and have the state a functioning return object:

export const accountModule = {
    namespaced: true,
    state(){
        return{
            item: null,
            
            loading: true,
            show_return_modal: false,
            show_reject_modal: false,
            show_remarks_modal: true,
        }
    },
}

This now returns a fresh instance of the module every time i create the module instead of referencing it. Just putting this as a note, but I'll put your answer as the best answer as thanks to your help!!

Activity icon

Replied to Application Of VueX Module Reuse

Hi!! I opened a new discussion here regarding reusing vuex modules:

https://laracasts.com/discuss/channels/vue/vuex-module-reuse-best-practices

Any help will be appreciated. Thanks very much!

Activity icon

Started a new Conversation Vuex Module Reuse Best Practices

Good Day Laracasts!

I posted a few days ago regarding the application of Vuex module reuse. While I am able to create unique namespaces for each module, it is to my surprise that they actually share properties -- which defeats the purpose of reusing Vuex modules (at least for my context).

Below is a code from my "Account Component"

    beforeDestroy() {
        this.$store.unregisterModule(this.namespace);
    },
    beforeCreate() {
        var id = this.$route.params.id;
        var namespace = "account-" + id;
        return new Promise((resolve, reject) => {
            resolve(this.$store.registerModule(namespace, accountModule));
        }).then((response) => {
            this.$store.dispatch(namespace + "/storeItem", id);
        });
    },

As you can see above, I am creating a new AccountModule everytime I create this component based on the router parameters, and proceed to unregister the module when the component is destroyed.

For every instance of the accountModule, I expect to be given a fresh copy of the accountModule:

  state: {
        item: null,
        
        loading: true,
        show_return_modal: false,
        show_reject_modal: false,
        show_remarks_modal: true,

Situation: - When I load "somelink.com/accounts/1", and i change the value of "show_remarks_modal" to false through a mutation, it works as intended. However, when I load "somelink.com/accounts/2", and I check the value of "show_remarks_modal", it is now changed to false even if I did not mutate it within the page. This led me to believe that I'm only creating a new module, but i am actually referencing to the same store.

After much research, I came across a discussino on github that has the exact same problem as I do:

https://github.com/vuejs/vuex/issues/615

However, I still do not understand how to implement this approach because I am not exactly sure what createModule() does given the answer above.

Sorry it took so long, but to conclude, I have these questions in mind - How can I create reuse modules with the same "template" without each affecting each other? - Am I creating unique namespaces correctly? - Am I destroying modules correctly?

I'm very interested in mastering Vuex, so Im hoping you guys can help me around here.

Thank you Laracasts!

May
15
4 months ago
Activity icon

Replied to Application Of VueX Module Reuse

Hi!! Thank you for your response. Sorry it took awhile. Will be accepting this as the best answer as it directly helped me in understanding resuasble vuex modules.

Thank you very much!

Activity icon

Replied to Application Of VueX Module Reuse

Hi!! this is exactly my problem, it starts becoming extremely messy because i have a lot of child components in this page.

I'm gonna be honest here, I don't exactly understand how to implement this, and I cant seem to find any useful guide on the internet on how to do this myself, and the documentation is just downright unclear.

Activity icon

Started a new Conversation Application Of VueX Module Reuse

Good day Laracasts!

I am fairly new to VueX, so I'm not entirely sure if this should be used in this specific situation.

Say in a given scenario, I have a Project that I fetch using axios in "someurl.com/projects/1" where I want to show Project 1.

Traditionally, I could store it in a local state:

export default{
data(){
return{
	project: null
}}
}

// methods
axios.get("/api/project/1/").then(response => {
	this.project = response.data.data;
 })

Great! This works perfectly. However, given a scenario that this component has A LOT of child components, I would need to pass project MULTIPLE times as a prop. Now this is a fairly simple example, but I hope I get my point across. Instinctively, I am inclined to use VueX to store the said project, but this would result in "someurl.com/projects/1" and "someurl.com/projects/2" share the same state of the project (Please do take note that the project is not the only property in the state. I need to manage the states of other things as well that are unique to EACH page).

Vuex has posted "Module Reuse" as part of their documentation, but it provides little explanation as to how to apply this in an actual project.

That said, I have 2 questions:

  1. Should I use VueX for this situation?
  2. Should I just bear with it and pass EVERYTHING as a prop instead of using VueX?

Thank you Laracasts!

May
04
4 months ago
Activity icon

Replied to Storage::download Does Not Download An Existing File

Excellent! Thanks for your help. Just a question tho, this seems a bit like a brute force of sorts. I'm just wondering if this is an optimal solution for this problem.

No complaints here tho, it worked like a charm. Thanks!

Activity icon

Replied to Storage::download Does Not Download An Existing File

Woops. I accidentally clicked the best answer. LOL

Activity icon

Replied to Storage::download Does Not Download An Existing File

Below is my route:

    Route::post('/download_cost_estimate/{id}', 'API\[email protected]');

Below is my download function:

    public function download($id)
    {
        $headers = [
        'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        ];

        $cost_estimate = CostEstimate::findOrFail($id);
        return Storage::download("cost-estimates/".$cost_estimate->name, "trial.xlsx", $headers);

    }

Below is my vuejs function that is called when the download button is clicked:

         axios.post('/api/download_cost_estimate/' + this.cost_estimate.id).then(response=> {

  });

Hope this helps. Thank you!

May
03
4 months ago
Activity icon

Replied to Storage::download Does Not Download An Existing File

the excel file does open correctly from the storage -> cost estimate. Als tested this using Microsoft edge, and it still does not work... currently really lost on what to do right now

Activity icon

Replied to Storage::download Does Not Download An Existing File

It does not download correctly. Even if I go to my registered route for the download file, it will unfortunately not return a download file.

Activity icon

Replied to Storage::download Does Not Download An Existing File

the file is located in:

storage->app->cost-estimates

i am able to save my files correctly in said directory, but when I download it, it returns me that weird chunk of code. Hope this answers your question. Thanks!

Activity icon

Replied to Storage::download Does Not Download An Existing File

With or without the headers, it returns this weird chunk of characters. Any advice on what should I do?

May
02
4 months ago
Activity icon

Started a new Conversation Storage::download Does Not Download An Existing File

Good day laracasts.

Below is my code for my download path:

    $headers = [
        'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        ];

        $cost_estimate = CostEstimate::findOrFail($id);
        return Storage::download("cost-estimates/".$cost_estimate->name, "trial.xlsx", $headers);

Case in point, I know for a fact that Storage recognizes that my file exist because it is not throwing an error that the file does not exist. The problem is, when I attempt to download a file using this function in the controller, I get a weird response of weird characters instead:

PK!¤SÅÏN[Content_Types].xml ¢( ¬“ËNÃ0E÷HüCä-ŠÝ²@5í‚Ǻ(`âIbÕ/yÜÒþ=÷±@¡j7±bÏÜs=3žÌ6Ökˆ¨½«Ø˜X®öJ»¶bŸ‹·ò‘˜¤SÒxÛ²Ùôöf²ØÀ‚²V¬K)<	uV"÷4>Z™è7¶"Èz)[÷£Ñƒ¨½KàR™z
6¼@#W&¯ÚÞ9‰`Ï»ÀžU1‚ѵLäT¬úE)÷N™9;ðŽl01HèOþìó>¨4Q+(æ2¦wiɆØñíãòËû%?-2àÒ7®Aùze©C©°HÖð¼r+µ;ø>ÁÏÁ(ò2¾²‘þ~YøŒDý‘¿—[È2g€˜¶ðÚeÏ¢§ÈÔ¯yôir#üŸ~Í>»$1i8çP“Dšú‹¯ý»R Ø"¿ãéÿÿPK!µU0#ôL_rels/.rels ¢( ¬’MOÃ0†ïHü‡È÷ÕݐBKwAH»!T~€Iܵ£$Ý¿'TƒG½~üÊÛÝ<êÈ!öâ4¬‹;#¶w­†—úqu*&r–Fq¬áÄvÕõÕö™GJy(v½*«¸¨¡KÉß#FÓñD±Ï.W	¥†=™ZÆMYÞbø®ÕBSí­†°·7 ê“Ï›ז¦é
?ˆ9LìҙÈsbgÙ®|Èl!õùUSh9i°bžr:"y_dlÀóD›¿ý|-NœÈR"4ø2ÏGÇ% õZ´4ñ˝yÄ7	ëÈðɂ‹¨ÞÿÿPK!%³ŽW+xl/workbook.xml¬U[o£8}_iÿâbsA¥£„‹¶ÒtTµÎK¥•¦x˜µM“ªšÿ¾Ÿ!¤ít´Êv6"¾s|Î÷›ÓO»¶1©Œw±‰OiЮà%ëbóëMn…¦!éJÒðŽÆæ•æ§³ß;Ýr±¹ç|[email protected]'c³Vªl[5m‰<á=í`¦â¢%
ºâÁ–½ ¤”5¥ªml¡Àn	ëÌ	!Ç`ðªbMy1´´Sˆ 
[email protected]_Ö¬—3Z[×±z«àm÷¬aêi5¶ˆÎ:.È}²wØ7vžþAáÌ;ÁÔ»­ZV.y¥NڞH¿Ó‘ñ›ìÞÇà8$Ïô‘éX‰àƒ¬‚Vð†Ñ/£a°Öè•‚÷A4ÿÀÍ1ÏN+ÖÐÛɺéû/¤Õ™jL£!Re%S´ŒÍtù–¾C¿X³Ž8žiŸì|)Œ’VdhÔ
y†‡“KÇ×+Á«FQÑEÞ)ðá^ׯznÄNj7®èßø´BIŠˆÜËK¢jcMl&ÑÝW	òïþâuWÜ¥Tnïï^ù’¼?ÿÁ™¤ÐrmÐ;qšÚ?jj"šÝw©„íóô3dàš<B> ëåþ¸žCÀÃ?Ÿlå¦i’Y‹Ës3ßZ;^h­Pè.Qæ/“Üù*DœªÞçXcƦçÿdê‚ì挢•/û?£ýÏÒõÅ<÷]+Õ·Ù-£[ùâÝ5vßXWòmlZØ5Oo»Ûqò+U
vB–LcPöPcŒq ½/Í,6Ÿ}”çYêbk„©å¥A-oe-² ôƒÔM쎌ìW”Æ{¨µÑ^¿Öw)†Z×:ºÐ‘ÞCœ—xÌÞüZAš¼­«qá#g©WНú,ÕXƒ­ÐÃZ-ÐÒ³Pæú–.+ô\ÇJ¼ÔÉüE–fk_çGßûÑÿqûîŽæŠfY¡n)6ðº¢ÕšHpÒ$ø¾&»öÃ5r¢—ãÜòðYëuàY~š»þƒÍüü…¬–_}ðî	íñmJÔçRɱé2ߏ«i`Ÿ§7‡.ºJuÜ÷oÿÛÂkPßÐ#ç·G.L¾\Ü\ŒÞø©{°.G[ØsZÎþÿÿPK!‡Úpà-xl/_rels/workbook.xml.rels ¢( ¬‘ËjÃ0E÷…þƒ˜}=v
¥”ÈٔB¶Åý!Ė„f’Ö_á‚Ý@H6Ù®Ýs$mw?ã N¹÷NC‘å ÈY_÷®ÕðU}<½‚b1®6ƒw¤a"†]ùø°ý¤ÁH:Ä]X¥Ç:‘ð†È¶£Ñpæ¹4i|¤[ÆLK¸ÉóŒÿ; <ëTûZCÜ×Ï ª)$òínß4½¥wo#9¹€@–iHP•‰-‰†¿œ%GÀËøÍ=ñ’ž…Vúq^‹kÅ=¾}<pG$«Ç²Å8O<ûäòÿÿPK!—9oƒØÖxl/worksheets/sheet1.xmlœ“ÉnÛ0†ïúï%yIlXR/hŠnwšI„¹¨$½¡è»g$CJ_Œ’0C‘ß?Cþ\<µ"Gp^Z“Ó4N(#l!M•Óß¿¶Ñ#%>pSpe
äôž>-?Zœ¬Ûû $ŸÓ:„fΘ5hîcۀÁ?¥ušL]Å|ã€Ý"­X–$S¦¹4ôJ˜»{¶,¥€µ
&\!X¿¯eã{š÷à4wûC	«D줒áÒA)ÑbþRëøNaßçtÌ9;|2|G½L7~£¤¥pÖÛ2ÄHfךo۟±ãb Ýö&3GÙà*ûXIéd`eo°ÑaÓÖn—›d‘Ó›éjšà'Ú<N¶Ñ8Ù~‰ž“Í:šŒÆãu6K§£íê?].
‰'ÜvE”9}N)[.:óü‘pòïbøî'(P ¥¤õæÎÚ};ñ‡ÄùnB‹ã"È#¬@)¤b›þïU kØ ð>îÕ¶›¿;[email protected]É*ü°§¯ «: ì{lM2/.kð݉Âq6Ê^óÀQ¡á|㮒Æe7ëwÅÆÁ6íÚDîlV÷Y÷Ð'IŒ;ZZú¤­|¸‘ËWÿÿPK!Á¾NÆ xl/theme/theme1.xmlìY͋7¿ú?swü5ã%ÞàÏl“Ý$d”µ¶ìQV32’¼%9õR(¤¥—Bo=”Ò@
½ô	$´éÑ'ÍØ#­å$›lJZv
‹Gþ½§§÷ž~zótñÒ½˜zG˜’–_¾Pò=œŒØ˜$Ӗk8(4|OH”Œe	nù,üK۟~rmÉÇØùDl¡–I9Û*ņ‘¸Àf8ß&ŒÇHÂ#ŸÇƒÞ˜+¥R­#’ø^‚bP{}2!#ì
•J{©¼Oá1‘B
Œ(ßWª±%¡±ãòBˆ…èRî!Úòaž1;â{Ò÷(~hù%ýç·/ÑV&DåYCn ÿ2¹L`|XÑsòéÁjÒ ƒZ{¥_¨\ÇõëýZ¿¶Ò§h4‚•¦¶Ø:ë•na
PúÕ¡»WïUËÞÐ_]³¹ª…× T°†ºàE¯A)>\ǝf§gë× _[Ã×Kí^P·ôkPDIr¸†.…µjw¹ÚdÂèŽÞƒA½’)ÏQ
«ìRSLX"7åZŒî2>€R$IâÉÅOв¸‹(9àÄÛ%Óo†&`¸T)
JUø¯>þ¦#Š¶02¤•]`‰XRöxbÄÉL¶ü+ Õ7 /ž={þðéó‡¿=ôèùÃ_²¹µ*Kn%SSîՏ_ÿýýÞ_¿þðêñ7éÔ'ñÂÄ¿üù˗¿ÿñ:õ°âÜ/¾}òòé“ß}õçOÚÛ˜ð!‰±ð®ácï&‹aûñ?Ä0BĒ@èv¨îËÈ^[ êÂu°íÂÛXƼ<¿kÙºñ¹$Ž™¯F±ÜcŒvw:ચËððpžLݓ󹉻‰Ð‘kî.J¬÷ç3 WâRٍ°eæ
Š‰¦8ÁÒS¿±CŒ«»Cˆå×=2âL°‰ôˆÓ%Cr`%R.´CbˆËÂe „ÚòÍÞm¯Ã¨kÕ=|d#a[ ê0~ˆ©åÆËh.QìR9D15¾‹dä2rÁG&®/$DzŠ)óúc,„Kæ:‡õA¿
ãû]Ä6’KrèÒ¹‹3‘=v؍P<sÚL’ÈÄ~&!E‘wƒI|Ù;D=CP²1Ü·	¶Âýf"¸äjš”'ˆúeα¼Œ™½t‚°‹eÚ<¶ØµÍ‰3;:ó©•Ú»StŒÆ{·>sXÐa3Ëç¹ÑW"`•ìJ¬+ÈÎUõœ`e’ªkÖ)r—+e÷ñ”m°goq‚x(‰ߤùDÝJ]8åœTzŽMà5åä‹Ó)×è0’»¿IëYg—zî|]p+~o³Ç`_Þ=í¾|j ö·öÍQk‚<a†
݂ˆþ\D«Zl؛6FV½“äÅω²'üwÊws[ñû”:›(eçD³	÷,kzhžÜÀp’¬sÖyUs^ÕøÿûªfÓ^>¯eÎk™óZÆõöõAj™¼|Ê&ïòèžO¼±å3!”îËÅ»Bw}¼ÑŒ0¨ÛQº'¹jÎ"øš5˜,ܔ#-ãq&?'2ڏÐZCeÝÀœŠLõTx3& c¤‡u+ŸÐ­ûNóxÓNg¹¬ºš©’ùx)\C—J¦èZ=ïÞ­Ôë~èTwY—(ÙÓaLfQuQ_B^g„^ٙXÑtXÑPꗡZFqå
0mxåöàE½å‡AÚA†f”çc§´™¼Œ®
ΙFz“3©™Pb/3 tSÙºqyjuiª½E¤-#Œt³0Ò0‚á,;͖ûYƺ™‡Ô2O¹b¹r3êkE"'¸&&SÐÄ;nùµj·*#4kùèÃ×x¹#Ô[¢S¸vIžnøwa–²‡D”:\“NÊ1‘˜{”Ä-_-•
4Ñ¢m+W€>Zãš@+›qt;Èx2Á#i†ÝQžNáS®pþªÅ߬$Ù½½:ç7¤XX/+Ž‰€‹ƒrêÍ1›°‘åùwâ`Êh×¼ŠÒ9”Ž#:‹Pv¢˜džÂ5‰®ÌÑO+OٚÁ¡ë.<˜ªö½OÝ7ÕÊsiæg¦Å*êÔt“é‡;ä
«òCÔ²*¥nýN-r®k.¹ÕyJ¼áÔ}‹Á0-ŸÌ2MY¼Nʳ³QÛ´3,OÔ6ømuF8=ñ®'?ȝÌ[email protected],ëJøúÊܼÕfw<zp8§RèPBo—#(úÒȔ6`‹Ü“Yß¼9'-ÿ~)lÝJØ-”a¿TƒR¡¶«…vVËý°\êu*à`‘Q\Óëú\aÐEvi¯Ç×.îãå-ͅ‹‹L_̵áúâ¾\Ù|qï ûµÊ Ymvj…fµ=(½N£ÐìÖ:…^­[ï
zÝ°Ñ<ð½#
ÚÕnPë7
µr·[j%e~£Y¨•J;¨·ý ý +c`å)}d¾÷j»¶ÿÿÿPK!y¡€l¤R
xl/styles.xml¤UmkÛ0þ>ØúîÊvã,	¶ËÒÔPèÆ ì«bˉ¨^Œ$gÎÆþûNv^:¶Ñ~‰NçÓsÏÝsRқN
´cÆr­2]…1UꊫM†¿>Á#먪¨ÐŠexÏ,¾Éß¿K­Ûö¸eÌ!€P6Ã[çš!¶Ü2Ií•n˜‚/µ6’:ؚ
±a´²þ$Ã)‘”+< ,dù? ’šç¶	J-êøšîö=F²\Üo”6t-€jMh‰ºhjbԙc’Þû"ä¥ÑV×î
p‰®k^²—tçdNhyFä×!E		ã‹Ú;óJ¤	1lǽ|8Ok­œE¥n•1¨oÁâYéïªðŸ¼sˆÊSûí¨O„Iž–ZhƒHë=ŠJ6DÜRÁ׆û°šJ.öƒ;öŽ^íCœäÐ{ï$žÇa±pˆqb{àÈSÏ1£
Ø ƒý´o ½‚I`ú¸DoÝGq2:@ú„yºÖ¦‚É>÷ãèÊSÁjD
ßlýêt¿kí¨Ÿ§§­¨ð¥ 'Ê)™~ú¿ÕØ]T+éî«Ã=òM8šPÈÁð†Ç£
Øo†E]}‰ˆ#Ú¤Oé‘×;ßýu09´n¹p\ý0`Vݹ¡WÀù«×7ç”:Q±š¶Â=>følboe|ŠúÂwÚõ>Û^©hês°Î=X/XQkx†Þ-?ÌWwEÌÂå,˜\³$˜'ËULn—«U1ãðö×èxÃõïß«<…‹µ°	s(öPâãٗáÑf ßÏ(ÐsŸÇÓðc…AqFÁdJgÁlzEÅ«édy—Ɉ{òÊg"$Q4<8ž|²pÁÕQ«£Bc/ˆÛ¿AŽJóŸAþÿÿPK!T¸N7>[docProps/core.xml ¢( Œ’ÍNÃ0„ïH¼Cä{b'¥XI*ê‰JH¸Yö6
Ä?²
iß'iCP9pôÎì·³+ç˽l¢/°®Öª@iBPŠkQ«ª@ϛU¼@‘óL	Öh:€CËòò"ç†rmáÑjÖ×à¢@RŽrS ÷†bìø$sIp¨ nµ•Ì‡§­°aüƒU€3BæX‚g‚y†;`lF":"‘æÓ[email protected]
HPÞá4Iñ×ƒ•îφ^™8eí&ìtŒ;e>ˆ£{ïêÑضmÒÎú!Š_×Oýªq­º[[email protected]å˜×¶|×;Ås<©t×k˜óëpèm
âöp2Ôp ¢…ÁOÊËìî~³BeF2“«˜d›”P2§³Å[7÷Wm(Èãôÿ¯iz3!žeŽÏ¾Cù
ÿÿPK!aI	‰docProps/app.xml ¢( œ’AoÛ0…ïúÝ9ÝP¬bHWô°a’¶gM¦c¡²$ˆ¬‘ì׏¶ÑÔÙzêä{xúDIÝ:_ôÑÅP‰å¢kö•xØÝ]~’	µñ[email protected]%Ž€âF_|R›dr€G¬DK”VR¢m¡3¸`9°ÒÄÜâ6ïelgá6ڗÉ«²¼–p 5ԗé(¦ÄUO
­£øðqwL¬Õ·”¼³†ø–ú§³9bl¨ø~°à•œ‹Šé¶`_²££.•œ·jk‡5ëÆx%ßêÌ°´qµêiՃ¥˜txmW¢ømœJô&;ˆ±ÛԌµOHY?ÅüŒ-¡’l˜†c9÷Îk÷E/GçÆ!`aáqçÈþj6&Ó;ÄË9ñÈ0ñN8ہo:sÎ7^™Oú'{»d‘…SõÅg|H»xk^×y>TÛÖd¨ùNë>
Ô=o2û!dݚ°‡úÕó¿0<þãôÃõòzQ~.ù]g3%ßþ²þÿÿPK-!¤SÅÏN[Content_Types].xmlPK-!µU0#ôL‡_rels/.relsPK-!%³ŽW+¬xl/workbook.xmlPK-!‡Úpà-0
xl/_rels/workbook.xml.relsPK-!—9oƒØÖPxl/worksheets/sheet1.xmlPK-!Á¾NÆ ^xl/theme/theme1.xmlPK-!y¡€l¤R
Ýxl/styles.xmlPK-!T¸N7>[¬docProps/core.xmlPK-!aI	‰!docProps/app.xmlPK		>à

Hence, my problem is not that my Storage is not locating my file, but rather, It's simply just not downloading my file at all. any suggestions on what to do? Thanks!

Apr
23
5 months ago
Activity icon

Replied to Using WhereJsonContains With An Array

Just a side note, there is no need to for the query function to exist. It can be as simple as

$users = User::query();
$positions = $request->get('positions');
	foreach($positions as $position){
                $users->orWhereJsonContains('positions', ['name' => $position]);
            }

Thank you once again for your help.

Activity icon

Replied to Using WhereJsonContains With An Array

Thank you for linking the post to me! It's actually insane lol.

My Previous Code:

  $positions = $request->get('positions');
            foreach($positions as $position){
                $users->whereJsonContains('positions', ['name' => $position]);
            }

It doesn't work because i should have been using orWhereJsonContains instead!

This yields the correct answer.

  $positions = $request->get('positions');
            foreach($positions as $position){
                $users->orWhereJsonContains('positions', ['name' => $position]);
            }

CONCLUSION: Always use orWhereJsonContains when Looping through an array of values. Will now close this post. Thank you for your help!

Activity icon

Started a new Conversation [SIDENOTE INQUIRY ONLY] - Using A WiFi Dongle Somehow Causes Some Services To Not Work

Good day Laracasts!

I am using a TP Link Wireless Adapater to conenct to my router's 5g connection. I have known this for a long time, but I have never bothered knowing why this is the case. Anyway, whenever I use my wifi dongle I have noticed that installing ANY package via NPM does not work and will cause multiple issues. In addition, when using mailtrap, the mail will not send and will return an error in the console instead.

My temporary solution is to not use my 5g WiFi Dongle when coding. I'm just curious though if there is a legitimate workaround to this problem.

Thank you Laracasts!

Activity icon

Replied to Using WhereJsonContains With An Array

Unfortunately this still does not work. It returns an empty collection of Users.

In addition, I think the difference between the example provided from the documentation is that "options" is posted as a JSON Object I believe.

options:{
.... => ....
.... => ....
.... => ....
language => ['en', 'jp']
}

I am able to perform the above example IF I have a JSON object stored in the database, not a JSON Array of Objects. Hopefully I make sense.

I appreciate your help. Please do let me know if there are other tips you can give me.

Also, one more thing. I tried to somehow bruteforce my way to the solution by using this

$users = User::query();
        if($request->get('positions')){
            $positions = $request->get('positions');

            foreach($positions as $position){
                $users->whereJsonContains('positions', ['name' => $position]);
            }
   
        }
        return UserResource::collection($users->get());

This returns an empty collection of users unfortunately if my positions are ["Project Execution Head", "Some Other Position"]; However, if i delete one of these elements, it will return me a a collection of users where their positions column contains one or the other.

This doesnt make sense to me, because it works if the array only has 1 element in it, but if i put 2 or more elements, it will return me an empty collection of users.

Was hoping if you would know the answer to this question as well. I apologize for the inconvenience and thank you very much!

Activity icon

Replied to Using WhereJsonContains With An Array

Which part of it should I change to $data?

Also, how will this code work?

    $query->whereJsonContains('positions->name', $data);

In my understanding, this will not work because positions is an array, not an object. Hence, positions does not have a property of name per se. On the other hand,

    $query->whereJsonContains('positions', ['name' => $position])->get();

works as intended, only IF i compare it to 1 string. However, comparing it to multiple strings like in an array will yield me nothing. Please do let me know if my understanding of whereJsonContains is incorrect. Thank you

Activity icon

Replied to Using WhereJsonContains With An Array

And just to be clear this isn't working unfortunately.

Any advice would be an immense help. Thank you!