diegoaurino

diegoaurino

Member Since 1 Year Ago

web programmer at ~

Experience Points 158,990
Experience Level 32

1,010 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 1457
Lessons
Completed
Best Reply Awards 21
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

21 Jul
1 day ago

diegoaurino left a reply on PHPUnit Not Running From Vendor/bin Folder (Composer Install)

Hello, @pedroroccon !

What happens if you run composer install?

Are you running PHPUnit from the command line or from an IDE?

Check if your IDE is configured to use the proper phpunit.xml from the project's root folder and the autoload.php included in the /vendor folder. Also, check if you are calling PHPUnit from /vendor/bin/phpunit included in your app installation and not from other installation or even from a global installation on your OS in case you are using the command line.

And what do you mean by you are using vendor/bin/phpunit vendor/pedroroccon/my-package? Are you using PHPUnit to run a folder you placed inside the /vendor directory? If so, I am afraid your default PHPUnit configuration will not understand this. 

Hope this helps. Let me know.

15 Jul
1 week ago

diegoaurino left a reply on Asset() Work With Localhost , Not With Domain.local

Hello, @moukbel !

Follow the suggestions above, but also update your httpd-vhosts.conf to:

<VirtualHost *:80>
    ServerName myproject.local
    ServerAlias www.myproject.local

    ServerAdmin [email protected]
    DocumentRoot "C:/wamp64/www/laravel/myproject/public"

    <Directory "C:/wamp64/www/laravel/myproject">
        AllowOverride All
    </Directory>
</VirtualHost>

Then, restart all the servers. Also make sure you are not receiving ports collisions from other Windows apps like Skype etc.

Hope this helps. Let me know.

diegoaurino left a reply on Vue Select: How Do I Mark An Option As Selected Dependant On Id?

Hello, @finchy70 !

You are using prelim in this.prelimdata in the v-for. You don't need to use this to access the prelimdata array inside the template.

Also make sure the server response is returning the correct data.

Hope this helps. Let me know.

13 Jul
1 week ago

diegoaurino left a reply on Can't Get Vagrant Up

Hello, @paulgureghian !

Check this issue on Github: https://github.com/hashicorp/vagrant/issues/1671

The "failed to open /dev/vboxnetctl" problem is well known. There are some workarounds to mitigate the problem.

If you are accessing the VM remotely, also make sure the required ports are available.

Hope this helps. Let me know.

07 Jul
2 weeks ago

diegoaurino left a reply on Same Array But Not

Are you mutating the original array?

diegoaurino left a reply on Same Array But Not

Hello, @kidi !

Is the screenshot a console.log output for this.cart? How does it look like in your code?

diegoaurino left a reply on Laravel And Vue (in Forms)

Hope you are doing great.

I am not sure whether I understood your question or not. However, you can wrap only the multiselect component in other component. Then, you can easily emit only the filtered array you need. Also, you can massage your date in your controller to fit you need.

06 Jul
2 weeks ago

diegoaurino left a reply on Laravel And Vue (in Forms)

Hello, @zfdeveloper !

You don't need to create a new component to use vue-multiselect and you can use it directly inside your form in Blade. You will need to create a few methods in your Vue instance in the app.js file though. Those methods will be responsible for consuming the API and setting the options for the selection.

A general example would look like this:

inside you Vue instance ---

       data() {
            return {
                options: [],
            }
        },
        created() {
            this.getTags();
        },
        methods: {
            getTags() {
                axios.get('/api/admin/tags').then(response => {
                    this.options = response.data;
                })
            }
        },

And in your form ---

        <multiselect
            class=""
            v-model="tags"
            placeholder="Search a tag"
            label="name"
            track-by="name"
            :options="options"
            [...]>
        </multiselect>

That is just an example to give you an idea. Don't forget to properly import the libraries. There are plenty of examples on the internet, especially in Codepen, where people configure vue-multiselect directly in the Vue instance. But it is important to know that you Vue instance will get messy very, very quickly though.

Hope this helps. Let me know and good luck!

diegoaurino left a reply on Laravel Scout - The Relationship Is Not Added At Creation

I was facing a similar problem these days (with Algolia). The problem is that, for some reason, Scout appears to ignore relationship synchronizations on the store method. It looks like the `sync( method does not change (touches) the timestamp of the model object that has been created on the store method in question. 

$touches looks to be a solution for people that are not syncing or attaching but creating or updating the synced objects.

A small workaround, I did, was to touch() the object, what will update its timestamp. Then Scout will pick the relationship too. But you cannot do that on the store method; it will happen so quickly that the timestamp will not change.

A workaround is to add an event and a listener for the store method. Then, you only need to use the last one to trigger a job that will touch your model object. The job should be delayed at least 1 (one) minute. That appears to be enough for Scout to pick the new timestamp and index the object with the relationship. That approach does not interfere with the user experience because the job will be handled behind the scene.

In other words, it does not look like a Scout bug, but only a thing to be aware of.

Hope this helps someone!

05 Jul
2 weeks ago

diegoaurino left a reply on Can't Connect To Algolia .

Hello, @saberhosneydev !

Have you properly set the ALGOLIA_APP_ID variable in your .env file? Share more details of your set up!

02 Jul
2 weeks ago

diegoaurino left a reply on How Do I Keep Getting Hacked On PHPUnit?

Hello, @mchiasson !

It is hard to say based on the information you are providing.

What do you mean by ".htaccess restrictions to block .ENV"? You should expose only the public folder and properly set the permissions for this folder. That is the most basic thing you can do.

Also, from a sysadmin point of view, relying only on a custom .htaccess configuration is a bad idea. You need to properly set up your web server (Apache or Nginx) to secure the Laravel root directory and only expose the public folder.

If the attacker has access to your vendor folder, he can use PHPUnit to trigger any PHP code via POST request.

I don't believe the problem is with PHPUnit however.

It is also important to upgrade your entire framework from time to time.

Hope this helps. Let me know.

diegoaurino left a reply on Laravel Dusk Ignoring Testing Database And Uses Main One Instead

@R123 - So, check the docs for Dusk: https://laravel.com/docs/5.8/dusk#environment-handling

It has its own way to handle env variables.

" if you will be initiating the dusk command from your local environment, you should create a .env.dusk.local file."

Also, make sure you removed the previous configuration.

Let me know if this helps.

01 Jul
3 weeks ago

diegoaurino left a reply on Laravel Ignoring Testing Database And Uses Main One Instead

@R123 - Take a look at the docs: https://laravel.com/docs/5.8/testing#environment

It says that:


you may create a .env.testing file in the root of your project. This file will override the .env file when running PHPUnit tests or executing Artisan commands with the --env=testing option.

That is the documented way of doing this. After you should add your database variables there and so on.

Then,

You are free to define other testing environment configuration values as necessary. The testing environment variables may be configured in the phpunit.xml file, but make sure to clear your configuration cache using the config:clear Artisan command before running your tests!

Also, check https://laravel.com/docs/5.8/configuration#environment-configuration

You may also create a .env.testing file. This file will override the .env file when running PHPUnit tests or executing Artisan commands with the --env=testing option.

So, you do not need to mess up your config files. Don't forget that you need to correct any miss configuration on your phpunit.xml file too. If needed, you can run php artisan config:cache --env=testing to clean up the cache.

Another option is to run tests in memory.

Hope this helps. Let me know.

diegoaurino left a reply on How To Find Storage Directory Cpanel/filezilla

It is not clear to me. But...

What do you mean by /public_html/\imagineprofi? There is a backslash before the i in imagineprofi. The shell will interpret the next character as a special character. Is that what do you want?

Is the /imagineprofil/ the root directory or the public folder?

30 Jun
3 weeks ago

diegoaurino left a reply on Getting All Json Instances From An Axios Response Dynamically

@LITTLEBOBY - Glad you solved it out! =D

Check: https://laravel.com/docs/5.8/eloquent-resources and https://laravel.com/api/5.8/Illuminate/Http/Resources/Json/JsonResource.html

It will give you a better understanding about what JsonResource is doing with your data. ;)

Please, mark it as solved!

diegoaurino left a reply on Getting All Json Instances From An Axios Response Dynamically

@LITTLEBOBY - Also, note that you defined your attributes like this in PHP:

            'attributes' => [
                'name' => $this->name,
                'description' => $this->description,
            ],

And your the API response:

attributes:
description: "Esse doloremque iste aperiam atque minus ab illum dolores dignissimos amet illum voluptatem voluptas."
name: "Aliquam autem voluptas ipsa non."

Here you can see that it is an empty JSON key. So, if you chain it like attributes.name, you will get undefined.

Expand everything you see in your groups data in the Vue DevTools and paste it here. So, you can have a better idea of what v-for will give to you. Besides that, just put {{ group }} inside your v-for to see what you are getting there.

Good luck!

diegoaurino left a reply on Getting All Json Instances From An Axios Response Dynamically

@MSTRAUSS - No problem, @mstrauss . It was fun. :D

Besides what @mstrauss suggested, I would like to give some tips to you, @littleboby

It is hard to know, at least for me, where you want to go here. Your API response is not that clean. I would suggest you go to the controller and massage your API data before consuming it in the Front-End. You are using data.data to access the response; this chain is not a good sign.

You are using

v-for="group in groups"

to iterate over the groups object, it will create group with the associated value. But you are also defining group in your Vue data in one of your previous code. Why? Have you removed it?

Try to console.log the data you are applying to this.groups inside your response chain, see what you get. Also, go to your Vue.js devtools, click on the component in question and check what kind of data is stored on your groups data. You need to check if its content is iterable, otherwise the v-for will be blank.

Hope this helps!

diegoaurino left a reply on When To Use Components?

I would say it is okay if it fits your application architecture. Try to keep good programming principles in mind too. Also, note that components communication can get complicated if you are dealing with multiple components. In this last case, you will probably need to use Vuex to keep track of everything. Another important point is that every component has its own templates and styles; sometimes it can become hard to maintain if badly planned.

diegoaurino left a reply on Update Value Outside Component

@MARKOKAUP - Hello, @markokaup !

You don't need to use Vuex for simple things like that.

The proper way to communicate from parent to child in Vue is by using props, and from child to parent, you can emit an event or use an Event Bus.

The Vue documentation is really good to cover that. Do basic research about those terms, you will find multiple examples.

Also, here on Laracasts, you can find free lessons that cover virtually all aspects of this.

Check: https://laracasts.com/series/learn-vue-2-step-by-step

Hope this helps. Let me know. Good luck!

diegoaurino left a reply on Vue Is Not Rendering Youtube Video Correctly

Hello, @nhayder !

As I don't know what package are you using, I have some questions to try to guide you.

What package are you using? Have you properly import it?

Have you installed the Vue.js devtools extension? If so, check if it is pointing out some problems.   What your `console.log(From component =>+response.datashowing to you?

Note that in the following code you will not be able to access your `medi data:

        .then(function (response) {

            console.log('From component =>'+response.data);

            this.media = response.data;

        })

You need to use the arrow function instead.

        .then(response => {

            console.log('From component =>'+response.data);

            this.media = response.data;

        })

Also, try to wrap your div with other div to avoid future problems.

I also see that you have multiple props for this component, but not all are in use.

Hope this helps you. Let me know.

diegoaurino left a reply on Getting All Json Instances From An Axios Response Dynamically

@MSTRAUSS - Just to clarify things and helped here. The arrow function is called arrow function and not arrow scope function. The arrow function does not have it own this. For that reason, it will look for the enclosing lexical scope. In other words, it automatically gets the lexical e l. Check: https://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions 

@littleboby In your preview code, this is not pointing to your Vue object, but to the global object. 

If you are not okay with using the arrow function, you can use the `.bin utility, like `.bind(this after your function.

diegoaurino left a reply on Blade Layout Problem

@LEANSTI - Glad you solved the problem! Good luck! :)

diegoaurino left a reply on Blade Layout Problem

Hello, @leansti !

Are you just appending your HTML code on the default welcome.blade.php file? If so, note that it includes a div with the following classes: lex-center position-ref full-height. This div is wrapping other divs. Also, look at the style tag inside the head. You need to customize it.

Hope this helps. Let me know.

diegoaurino left a reply on Getting All Json Instances From An Axios Response Dynamically

Hello, @littleboby !

You need to use an arrow function to access the correct scope. For example:

            .then(response => {
                console.log(response.data.data[0].attributes.name); 
                this.groups = response.data.data[0].attributes; 
            })

Hope this helps. Let me know.

diegoaurino left a reply on PHPUNIT Fails, But Separate Testsuits Not

@BAHJAAT - Glad to see that! I didn't pay attention to the fact you were using 'DatabaseMigrations' instead of 'RefreshDatabase'. Did you properly set your testing database? Also, check the possibility of using the test in memory. It tends to be faster especially in Windows. If your project allows that, just add the following in you phpunit.xml:

        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>

But note that it will use sqlite in memory. Let the .env file to set only your main databases. Check if your antivirus or firewall is not slowing down the entire process. In general, tests running under a plain Apache and PHP installation on Windows, for example, tend to be really fast, but under WSL1 it is very, very slow.

Bests,

29 Jun
3 weeks ago

diegoaurino left a reply on PHPUNIT Fails, But Separate Testsuits Not

Hello, @bahjaat !

Are you running those tests from PHPStorm or from the command line?

Check if PHPStorm is configured to use the proper phpunit.xml and the autoload.php included in the /vendor folder. Also, check if you are calling PHPUnit from /vendor/bin/phpunit included in your app installation and not from other installation or even from a global installation on Windows in case you are using the command line.

In case the problem persists, paste here your .env and phpunit.xml files.

Hope this helps!

28 Jun
3 weeks ago

diegoaurino left a reply on Vue.js Activated In Tab: Npm Run Watch Build Successful, No Visual Feedback

@LITTLEBOBY - Glad to hear that! Please, mark it as solved! Good luck, @littleboby ! :)

diegoaurino left a reply on PHP Artisan Not Stopping

Hello, @joshuadabejero !

This is happening because when you press CTRL + C on Bash, it sends a SIGINT to the job running in the foreground. In other words, it interrupts the job on Bash but not the CMD.exe command that is running outside the WSL environment with the /C flags that says to the command run and then terminates itself when finished. The command will not terminate because it can't receive the SIGINT from bash.

Besides what @nash suggested, I would recommend you install the full LAMP inside WSL. So, you would have the best of XAMPP, but running natively inside WSL.

If your intention is to continue with your current environment, you can create a .bat script that is called by a specific alias that kills any php.exe instance that is running on Windows. Or more complexly, create a .ps1 scripts that run and watch the command it has called, thus it can kill those command when finished. But I believe the things start to be unnecessarily complex here.

Good luck!

diegoaurino left a reply on Vue.js Activated In Tab: Npm Run Watch Build Successful, No Visual Feedback

@LITTLEBOBY - Sure. You need to specify the id and note the class on Discover.html:


    <div id="app">
        <discover></discover>
    </div>

diegoaurino left a reply on Vue.js Activated In Tab: Npm Run Watch Build Successful, No Visual Feedback

Hello, @littleboby !

Try this on your Discover.vue component:

<template>
<div class="chat-app">
    <HeaderComponent></HeaderComponent>
</div>
</template>


<script>

import HeaderComponent from './HeaderComponent';

export default {
   components: {
      HeaderComponent
    },
    mounted() {
        console.log('Component mounted.')
    }
}


</script>

You are putting the components outside the export. Let me know if it helps you.

20 Jun
1 month ago

diegoaurino left a reply on Extended Latin Characters Missing On Save() - Laravel 5.8

@RICHARDEV - Are you using any of the str* (string) PHP functions before saving? Take a look at the entire path before saving. Paste here this path.

Some PHP string functions use the current locale. That is one reason why some mb_str* variants exist. https://www.php.net/manual/en/ref.mbstring.php

19 Jun
1 month ago

diegoaurino left a reply on Extended Latin Characters Missing On Save() - Laravel 5.8

@RICHARDEV - I am not a specialist in Baltic charsets for MySQL. But I know that MySQL had some problems with those related collations in older versions. Looking at the docs, MySQL 8.* made some improvements: 

Language specific Unicode 9.0 collations for Czech, Danish (also valid for Norwegian), German (phonebook order), Esperanto, Spanish, Spanish (traditional), Estonian, Croatian (also valid for Serbian with latin characters, and Bosnian), Hungarian, Icelandic, Lithuanian, Latvian, Polish, Romanian, Slovak, Slovenian, Swedish, Turkish, Vietnamese, Japanese (including kana sensitive collation), Chinese, and Russian (also valid for Bulgarian).

What version are you using on your local machine? Try to update to 8.* if you are running an older one. Also, try to use a specific charset and collation offered by the 8.* version to see whether it works or not. https://dev.mysql.com/doc/refman/8.0/en/charset-baltic-sets.html 

It is also easy and fast to set up SQLite or PostgreSQL with Laravel. So, it is an option to isolate the problem.

diegoaurino left a reply on Extended Latin Characters Missing On Save() - Laravel 5.8

@RICHARDEV - Did you check the config/database.php file? Check the charset and collation keys in the connections array.

        'mysql' => [
            'driver' => 'mysql',
            '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,
        ],
18 Jun
1 month ago

diegoaurino left a reply on Extended Latin Characters Missing On Save() - Laravel 5.8

Hello, @richardev !

Did you check if the specific table and column are using another charset? Perhaps this table (or column) is using utf8 instead. You can use `information_schema to accomplish it. Look: https://dev.mysql.com/doc/refman/8.0/en/information-schema.html 

Columns, tables, and schemas of each database can have a different collation and charsets. So, I suggest you give it a try.

Hope this helps you.

22 May
2 months ago

diegoaurino left a reply on PHPUnit Will Not Use :memory: Database

@NEXXAI - Are you running those tests from the command line? Take a look at this line in your error: "/Users/nexxai/.composer/vendor/phpunit/phpunit/phpunit:61" . It is using the phpunit globally installed in your machine for your user and not the one used by the app installation in vendor/bin/phpunit. The configuration I showed you above is all you need to run tests in memory. Thus, make sure both your application configurations and your local machine (PHP, composer, etc) are correctly set. Also, if you are running these tests from an IDE, you need to configure it there as well to point the phpunit.xml and the composer autoload correctly. Another thing I noticed is that your composer installation is not using the standard folder for Windows. Make sure your composer variables are correctly set for your system.

diegoaurino left a reply on PHPUnit Will Not Use :memory: Database

@NEXXAI - In other words, just append the following inside the php key of your phpunit.xml file:

 <env name="DB_CONNECTION" value="sqlite"/>
 <env name="DB_DATABASE" value=":memory:"/>

diegoaurino left a reply on PHPUnit Will Not Use :memory: Database

Hello, @nexxai !

You need to add the ":memory:" not in your .env file, but in the phpunit.xml file. Like this:

    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="BCRYPT_ROUNDS" value="4"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="MAIL_DRIVER" value="array"/>
        <env name="QUEUE_CONNECTION" value="sync"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>
        <env name="TELESCOPE_ENABLED" value="false"/>
 </php>

So,

 <env name="DB_CONNECTION" value="sqlite"/>
 <env name="DB_DATABASE" value=":memory:"/>

Let the .env file to set only your main databases.

That is more than enough. You can also use the RefreshDatabase trait to avoid database persistent changes. If you are just starting a new project, undo your configuration and start again to avoid misconfigurations.

That is all I do to run tests in memory.

Hope this reply helps you. Let me know if so.

diegoaurino left a reply on Feature Tests Do Not Work (404)

@PILAT - Hello, @pilat ! Hope you are doing great!

As I said, you need to set up your webserver properly to manage it. If you are using a shared hosting service and you don't have access to the webserver directives, contact the support. They need to hide your root folder, only expose your /public folder publicly and properly configure mod_rewrite, alias, etc. So, you will be able to use the http://MYSITE_REPLACED.info/back/ to access your application and the test should work by following http://MYSITE_REPLACED.info/back/api/vote, excluding the /public path. If you are unsure, do php artisan route:list to check your routes and API endpoints.

I do not recommend doing this only by changing your .htaccess. Both your main website .conf (if you are using Apache) and the .conf of the application in question need to be customized. Also, be aware that folders permissions and ownership need to be adapted to this situation.

Hope this reply helps you.

21 May
2 months ago

diegoaurino left a reply on Policy Always Returns 403

@THREEEL - I thought this was Laravel 0.1... Make sure there is no mistakes in the model and/or policies imports namespaces. Double check if your getEndpoint method is returning the correct path. Another point: your test says the "lectures" are open. So, you do not need a policy for the index. Do you? Also, take a look if other authentications, routes with the can key in the middleware method, gates or policies are not interfering in the process.

diegoaurino left a reply on Policy Always Returns 403

Hello, @threeel !

Also, try to change the protected $policies array. Instead of using the scope resolution operator to designate the class, like ::class, use the full autoload path, for example, 'App\Model' => 'App\Policies\ModelPolicy'.

Make sure your test method does not require authentication. If so, you need to authenticate first.

Hope this reply helps you. Let me know if so.

20 May
2 months ago

diegoaurino left a reply on WYSIWYG Image Upload

@MEMELE - Hello, @memele!

Are you using Jquery or Vue?

There is a package for Vue called vue-trumbowyg. I've used Trumbowyg before, but I found TinyMCE a much better option.

FileFieldName means the key expected by your $request->file('key').

For example,

$path = $request->file('image')->store($dir);.

A simple store method in your controller for image uploads would look like this:

    public function store(Request $request)
    {
        $dir = 'public/images';
        $path = $request->file('file')->store($dir);
        $name = str_replace("$dir/", '', $path);
        $response = [
            'success' => true,
            'url' => asset("storage/images/" . $name)
        ];

        return response()->json($response);
    }

This will return a response to your front-end with "url" and "success". You actually don't need to store the path in the database, since it will be stored in the body as a img tag that includes the src attribute.

The docs for Trumbowyng says it expects a JSON response like that.

{
    success: true, // Must be false if upload fails
    url: 'https://example.com/myimage.jpg'
}

So, my suggestion should fit your needs. Take a look: https://alex-d.github.io/Trumbowyg/documentation/plugins/#plugin-upload

Also, make sure you have properly set your back-end API to receive this post request.

Hope this reply helps you. Let me know if so.

18 May
2 months ago

diegoaurino left a reply on Laravel Resource Route

@RUSLANJOHNBELL - Hello, @ruslanjohnbell !

Check if your model IndividualCraftPerson is defining (or expecting) a different key for your model bidding. You can use dd($person) inside your show method to check if the model is properly injected.

I also suggest you paste both the related model and routes/api.php here. So, others can have a better idea of your problem.

Let me know if it helps.

diegoaurino left a reply on Laravel - Grouping Service Providers?

Hello, @h2onock !

I believe your controller is doing too much. I suggest you redesign your app a little bit. For example, since each user can have a single NewsProvider, you can create a Model where you can define the relationship and also set the default news channel. As you described, it looks like a simple one-to-many relationship. Then, in the front-end, you just need to fetch the "choice" made by the user.

To avoid the repetition on your "providers", you can apply the very basics principle of design patterns by separating what changes from what stays the same. To make it easier for you, you can put it in an interface or simply create a trait.

Then, create a separate controller to deal with each step.

Hope this reply helps you. Let me know if so.

17 May
2 months ago

diegoaurino left a reply on Feature Tests Do Not Work (404)

@PILAT - Hello, @pilat!

The test suite will not understand that it needs to follow this long path ( http://MYSITE_REPLACED.info/back/public/ ) to hit the API endpoints. You need to correctly define your root directory and your application directory on your web server. Then, set the application variables in the correct way.

Hope this reply helps you.

diegoaurino left a reply on Composer Laravel Installer Permission Denied On Windows 10

@PATRICKMACIEL - Hello, @patrickmaciel !

Could you show me your system and user variables? Follow the path I showed you in my comment above.

16 May
2 months ago
15 May
2 months ago

diegoaurino left a reply on RecursiveDirectoryIterator::hasChildren(): Open_basedir Restriction In Effect. File(/home/admin/web/connect.lightningwallet.online/public_html/phpsysinfo) Is Not Within The Allowed Path(s):

Hello, @coderathore !

It can be related to many different things. As I do not know much about your deployment setup, I would suggest the following:

  1. Check if the folder's permissions and ownership are properly set.
  2. Check if your web servers are configured to follow symbolic links in the correct way.
  3. Check if your base directory is not occulted to the web server or to the application.

Also check the PHP documentation to understand why this can be related to many problems in your deployment: https://www.php.net/manual/en/class.recursivedirectoryiterator.php

Give us more details and let me know if it helps.

diegoaurino left a reply on Composer Laravel Installer Permission Denied On Windows 10

Hello, @patrickmaciel !

I hope you installed Composer via the official ".exe" installer as @jlrdw suggested. But besides that, you also need to include the vendors/bin folder in your user path variable if you want to run the packages .bat from PowerShell or CMD with ease.

Go to system properties -> Advanced -> Environment Variables. In the variables for you user, append to the "path" variable something like %USERPROFILE%\AppData\Roaming\Composer\vendor\bin

If you did a custom/script installation, you need to define the COMPOSER_HOME variable as well. Look at the docs: https://getcomposer.org/doc/03-cli.md#composer-home

Let me know if it helps.

diegoaurino left a reply on Why Are My Tests Is Slower Than Jeffrey's Tests?

@UNTYMAGE - If you are working on projects that require Vagrant, run a single PHPUnit method at a time. Only run the entire suite to check if everything is okay.

Nowadays, I tend to simplify my environment as much as possible. I just use a simple and local PHP installation together with a MySQL server. I also recommend running tests on memory. Thus, when you run your tests, you never touch the MySQL service. For projects that require Unix tools, like Redis, I use it from WSL using the default ports.

If you need to make sure your app is compatible with your deployment machine, you can do that by creating a custom VM on Hyper-V (or VirtualBox) that matches your remote machine. In that case, you have an option to access your files via SSH or Samba. Even better, you can use some tools provide by big IDEs like PHPstorm to access it the same way we did in the old days by uploading via SFTP on save. Set git hooks to upload the files to the VM are also options.

I would stay with the local option. I have a long background in using Linux distributions, but I am very satisfied with Windows nowadays and, in some scenarios, it can be much faster than Linux.

14 May
2 months ago

diegoaurino left a reply on Why Are My Tests Slower Than Jeffrey's Tests?

Hello, @untymage !

Are you sharing folders between the Vagrant box and Windows?   This slowness is the case when you are sharing folders between different filesystems. There are some things you can do to optimize it, but it will never be as faster than running it on the same filesystem.   The docs for Homestead says the following:  

When using NFS on Windows, you should consider installing the vagrant-winnfsd plug-in. This plug-in will maintain the correct user / group permissions for files and directories within the Homestead box.

  Take a look: https://laravel.com/docs/master/homestead#configuring-homestead   The docs also say to specify the filesystem like:  

folders:
    - map: ~/code
      to: /home/vagrant/code
      type: “nfs”

  So check the plugins available for Vagrant. It will help a little.   If speed is important to you, install PHP directly on Windows to run it locally or put your projects inside the VM and access it remotely or via SSH or Samba share. Microsoft is customizing its own Linux kernel to be used on WSL2; so it will be an option for the future.   For now, a local Windows installation or a customized VM on Hyper-V is the best options.   Let me know if it helps.