Punksolid

Punksolid

Member Since 3 Years Ago

Culiacán, México

Experience Points
89,160
Total
Experience

840 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
703
Lessons
Completed
Best Reply Awards
28
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 18
89,160 XP
May
15
1 week ago
Activity icon

Awarded Best Reply on Failed Asserting That Two Strings Are Equal

Hi @browniecoffee look like in your [email protected] you have a redirect that sends you to /home in your URL. If not, a middleware could be checking if you are a guest or an authenticated user, so it don't let you stay in your not logged / main route.

Could you share what it says when you do a php artisan route:list please?

May
14
2 weeks ago
Activity icon

Replied to Failed Asserting That Two Strings Are Equal

Lol, I literally told you to check your middlewares and you marked your own response as a best answer. :P Glad you solved it anyways.

Activity icon

Replied to How To Create A Function And Automatically Called In Every Function Block?

Hi @drewlim7 I did not understand what are you trying to accomplish but to execute a method before each method in a class you could define __call function

https://stackoverflow.com/a/3716750/716211

Activity icon

Replied to Failed Asserting That Two Strings Are Equal

Hi @browniecoffee look like in your [email protected] you have a redirect that sends you to /home in your URL. If not, a middleware could be checking if you are a guest or an authenticated user, so it don't let you stay in your not logged / main route.

Could you share what it says when you do a php artisan route:list please?

Activity icon

Replied to How To Build Sql Query Automatically According To The Use Request?

@carleogden if it can avoid it he should not use store procedures and accept the advantage of Eloquent, he could have all the queries only in one place.

@ptl I think that the simplest way is the one given by @martinbean, however there is a package by spatie that it could be useful if you have a lot of dinamic searchs. https://github.com/spatie/laravel-query-builder#selecting-fields-for-a-query-usersfieldsidemail

Activity icon

Replied to Having Issue To Upload My Laravel Project To My Server

Hi @alodon I think its cleaner if you use Git for your deployment.

Are you deploying to a shared server? How are you uploading it?

May
12
2 weeks ago
Activity icon

Replied to Big Increments Performnace?

Hi @panthro Yes bigIncrements is less performant, however I don't think that performance is an issue more important than the time you will have to do refactoring later.

https://stackoverflow.com/a/9377107/716211

May
09
2 weeks ago
Activity icon

Awarded Best Reply on Using Larastan And Making Sense Of The Suggestions

Hi @trevorpan First of all keep in mind that rules helps and have a reason (almost always) but sometimes are to be broken.

I have used larastan in two projects and it helped me to understand why somethings are bad practices. Or keep the project codebase consistent which helps other developers.

In this specific case your docblock its not updated to the action of your method, so its not consistent, but also, larastan helps you to identify scenarios that maybe dont happen in real life but if a small change is done later in another part of your code it could not behave as expected.

 Method App\Http\Controllers\Auth\LoginController::authenticate() should return App\Http\Controllers\Auth\Response but return statement is missing.

Your function will work only if Auth::attempt works, if attempt fails your app could behave weird. Because your method it will be void and return a redirect at the same time. And thats not consistent, your methods should preferably return the same type almost always.

Activity icon

Replied to Using Larastan And Making Sense Of The Suggestions

No problem @trevorpan When I said void its because its the same if you do


public function helloWorld() 
{
}

public function helloWorld() 
{
	return void;
}

both are considered the same, thats why you had this

Method App\Http\Controllers\Auth\LoginController::authenticate() should return App\Http\Controllers\Auth\Response but return statement is missing. 

because its was not explicitly specified.

About your handle function, you should do a return or delete the @return tag in your docblock so yes, its bad code quality to not keep consistent your documentation of your code. When you put mixed you said that whatever return its fine, that does include the void of your SendDeadlineExpiredEmails

May
08
2 weeks ago
Activity icon

Replied to Google Map API Or GPS - Loaction Alternatives

Because this thread still appears in google, what you need for realtime its websockets https://laravel.com/docs/7.x/broadcasting#introduction

Activity icon

Replied to Best Practices To Minimize Database Hits

Cool @commish now I understand.

Keep the user model as simple as possible, for data related to a profile use a relationship 1 to 1, there you could store anything, so yes, 1 to one its the right path. If there are a lot of columns for your profile model, then maybe you could separate by their purpose.

But don't attach at first those to your user table.

Activity icon

Replied to Best Practices To Minimize Database Hits

Hi @commish I think the scope of your question its too big.

Could you share the code of the models you want to implement?

Sometimes things just get clear with the hands on it. Also if you follow clean code practices you could refactor your code if somethings its wrong.

Regards

Activity icon

Replied to Could Not Find Driver (User Login)

Hi @monstajamss it looks that some dependency is not installed. Check that all this requirements are installed

https://laravel.com/docs/7.x#server-requirements

Activity icon

Replied to Using Larastan And Making Sense Of The Suggestions

Hi @trevorpan First of all keep in mind that rules helps and have a reason (almost always) but sometimes are to be broken.

I have used larastan in two projects and it helped me to understand why somethings are bad practices. Or keep the project codebase consistent which helps other developers.

In this specific case your docblock its not updated to the action of your method, so its not consistent, but also, larastan helps you to identify scenarios that maybe dont happen in real life but if a small change is done later in another part of your code it could not behave as expected.

 Method App\Http\Controllers\Auth\LoginController::authenticate() should return App\Http\Controllers\Auth\Response but return statement is missing.

Your function will work only if Auth::attempt works, if attempt fails your app could behave weird. Because your method it will be void and return a redirect at the same time. And thats not consistent, your methods should preferably return the same type almost always.

May
06
3 weeks ago
Activity icon

Awarded Best Reply on Could Not Open Input File: Composer.phar

Hi @muhammadmaaz normally, when composer its installed globally, you can just execute it like this composer require intervention/image

Activity icon

Replied to Could Not Open Input File: Composer.phar

Hi @muhammadmaaz normally, when composer its installed globally, you can just execute it like this composer require intervention/image

May
02
3 weeks ago
Activity icon

Replied to Very Hard An About Laravel Project ?

@app_dev If I understood the issue, you wanna develop an app where the user will not need to be registered in order to use the application?

In that case you could do the application creating "ghosts" users, you can generate users with some fake emails in order to do all the process, and later if needed fix to consistent information, so the user can log in and have their previous activity saved.

Activity icon

Replied to Very Hard An About Laravel Project ?

Hi @app_dev What do you mean by index model,view and controllers to the user?

Apr
30
4 weeks ago
Activity icon

Awarded Best Reply on Problem With Populating Database Column With Seeding In Laravel

yes, exactly like that. Let me now if it worked.

Extra question, why do you use make and not create?

Apr
29
4 weeks ago
Activity icon

Replied to Problem With Populating Database Column With Seeding In Laravel

yes, exactly like that. Let me now if it worked.

Extra question, why do you use make and not create?

Activity icon

Replied to Problem With Populating Database Column With Seeding In Laravel

Ok, I understand now that you did a model for your pivot table. You have several options for seeding what you need, one is the one that I proposed you using models. The other one is doing an extra foreach loop inside your foreach and iterating through $user_interest_values and only then assigning to your factory. interested_in only accepts a value and you should have$user_interest_values = [1,2,3,4,5] like that.

Activity icon

Replied to Problem With Populating Database Column With Seeding In Laravel

Thats the problem, thats not the way to declare many to many relationships in your user model.

https://laravel.com/docs/7.x/eloquent-relationships#many-to-many In your User Model you should set it like this


public function interests() 
 {
     return $this->belongsToMany(Interest::class, 'user_interests');
 }

And in your Interest Model

public function users() 
 {
      return $this->belongsToMany(User::class, 'user_interests', 'id', 'user_id');    
 }

Also do you have another type of interests model? If not, a cleaner code should be Interest model, prepending user to a model it could lead you to confusion because almost every model it will interact with the user somehow.

Activity icon

Replied to Problem With Populating Database Column With Seeding In Laravel

well I think I showed you the main part. It all depends in which interests you want to retrieve. How is your Interest and user model declared?

$users = User::all();
$interest = Interest::all();
foreach($users as $user){
	$user->interests()->attach($interests->pluck('id')->toArray()); // I forgot to add the interest method relationship
}

regards

Activity icon

Replied to Problem With Populating Database Column With Seeding In Laravel

Hi @dr24 So a User has Many interest is it a simple many to many relationship?, why don't you use models instead?

$users = User::all();

foreach($users as $user){
	$user->attach($interests->pluck('id')->toArray());
}
Apr
22
1 month ago
Activity icon

Replied to Can't Connect With MariaDB And Laradock

UPDATE: I opened PHPStorm that has a secction of services, I deleted everything that sound like a mariadb or laradock, then excecuted the installation again and it works, I dont know why it wasnt working nor why I didnt deleted it the first time.

But now it works with mariadb10.4

Thanks

Apr
16
1 month ago
Activity icon

Replied to Best Design Pattern For Consuming Multiple API's

Yes @salahy, its very scalable. You could do an interface very well defined to use it for all 200 classes. And when you start seeing similar processes through lets say 10 different Pharmacies APIs, you could add a trait or a parent class to do that part of the process.

In some way you cant dismiss the decode/mapping part for each api response.

You don't need to do any of the 200 classes to have it working, you will just have to add each one after you finish it, so it will not interfere with the already done classes.

Apr
14
1 month ago
Activity icon

Replied to How To Handle API Response In Controller

Well, if the client pays there is no too much choice, but it will be expensive, slow performant and even slower development.

In that case I suggest to do a mirror in frontend and use Repository Classes that will do the fetch, and the controller in client call the methods in the repository class. In that way it will be easier to have everything in order.

Activity icon

Replied to Can't Connect With MariaDB And Laradock

Hi again @dunsti and @bobbybouwmann

Y set PMA_DB_ENGINE=mariadb and executed docker-compose up -d nginx mariadb phpmyadmin bug failed

flag to clean it up.
Creating laradock_mariadb_1          ... done
Creating laradock_docker-in-docker_1 ... done
Creating laradock_workspace_1        ... 
Creating laradock_phpmyadmin_1       ... 
Creating laradock_phpmyadmin_1       ... error

Creating laradock_workspace_1        ... done
04b39e5c8522659385826c7aa43665898af9619e8): Bind for 0.0.0.0:8080 failed: port is already allocated
Creating laradock_php-fpm_1          ... done
Creating laradock_nginx_1            ... done

however I remembered that once showed me the same error as laravel.

I also set

MARIADB_DB_HOST=mariadb

Rebuild the container with docker-compose build mariadb entered the workspace bash and executed artisan migrate and failed again with the same error as before

[email protected]:/var/www/simpligps-api# php artisan migrate:fresh --seed
   Illuminate\Database\QueryException 
  SQLSTATE[HY000] [2006] MySQL server has gone away (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')
  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:670

I think its worth mention that I upgraded manually laravel 5.6 to 7.0, I don't think I missed any important step but don't know it any of that its important enough to make it fail now.

Regards

Activity icon

Replied to How To Handle API Response In Controller

Hi @azeem202 Do you have two PHP apps one as a frontend and another as a backend? That will be really hard to maintain. Its better to just connect a vuejs application to your main backend app.

Apr
13
1 month ago
Activity icon

Replied to I Will Need To Build An API For A Big Project. Need Advice.

@t3rm1n4l Well I have used this https://github.com/DarkaOnLine/L5-Swagger but its true that it looks bloated, the cool part its that the annotation its where your code is so its easier to update both and not forget.

Its up to you if you use annotations or https://stoplight.io/.

Activity icon

Replied to Route [service.leave_requests.allLeaves] Not Defined

Hi @noblemfd the route and the route name are/could be different. If you execute php artisan route:list you could see all your routes and the right name.

It looks that the right route name is service.allLeaves so discard the .leave_requests. part.

Regards

Activity icon

Replied to I Will Need To Build An API For A Big Project. Need Advice.

Hi @t3rm1n4l I have done that and I have some tips that would have been good for myself

Use TDD for the endpoints always and since the beginning of the project, start with a test that checks the success API response, and that param/values are right.

Use all the opinionated classes that laravel has, for a simple crud it could be a little bit overwhelming but with time its a lot easier to maintain. Model, Controller, FormRequest, ApiResource, Middlewares. And use migrations properly always.

Keep your api restful with no more than 2 levels deep in routes. For example if you have a project where Hotels, have rooms, that have guests. Avoid using a route like /hotels/1/rooms/31/guest/1 for retrieving the data of a guest. If you could, just keep one level.

Use OpenAPI for documentation, there are other ways of documenting that are more automated, but OpenApi has several tools that will help the other developers see the details more easily.

In the response of the endpoints just add the attributes they need, dont give more data "just in case", when more data is needed if you follow the separation of concerns advice, it will really easy to add it later.

Don't worry a lot in the beginning with the performance of a response, just check that no response takes more than 2 seconds, later you could optimize by checking the queries.

Any specific doubt feel free to ask, happy to help. Regards

Activity icon

Replied to Can't Connect With MariaDB And Laradock

@dunsti well docker-compose exec mariadb bash was a good advice, at least now I have some access to the database.

I'm not goot at SQL but I tried this

[email protected]  ~/projects/simpligps/laradock   master ●  docker-compose exec mariadb bash
[email protected]:/# mysql --version
mysql  Ver 15.1 Distrib 10.4.12-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
[email protected]:/# mysql --user=root --password=root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[email protected]:/# mysql default
ERROR 1049 (42000): Unknown database 'default'
[email protected]:/# mysql --user=default --password=secret
ERROR 1045 (28000): Access denied for user 'default'@'localhost' (using password: YES)
[email protected]:/# mysql --user=root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 27
Server version: 10.4.12-MariaDB-1:10.4.12+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mysql]> exit
Bye
[email protected]:/# mysql mysql  
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 28
Server version: 10.4.12-MariaDB-1:10.4.12+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mysql]> update user set Password=PASSWORD('root') where user='root';
ERROR 1348 (HY000): Column 'Password' is not updatable
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

MariaDB [mysql]> 

I think now I can search in how to reset things as if it were on my machine, but I still don't understand why I can't access from the workspace

UPDATE:

This is weird, there is no default database

MariaDB [mysql]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.001 sec)

MariaDB [mysql]>

Activity icon

Replied to Can't Connect With MariaDB And Laradock

Hi @dunsti thanks for your response.

Yes it is running.

docker-compose ps gives this

           Name                          Command              State                                                          Ports                                                        
----------------------------------------------------------------------------------------------------------------------------------------
laradock_docker-in-docker_1   dockerd-entrypoint.sh           Up      2375/tcp, 2376/tcp                                                                                                  
laradock_mariadb_1            docker-entrypoint.sh mysqld     Up      0.0.0.0:3306->3306/tcp                                                                                              
laradock_nginx_1              /bin/bash /opt/startup.sh       Up      0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:81->81/tcp                                                        
laradock_php-fpm_1            docker-php-entrypoint php-fpm   Up      9000/tcp                                                                                                            
laradock_workspace_1          /sbin/my_init                   Up      0.0.0.0:2222->22/tcp, 0.0.0.0:3000->3000/tcp, 0.0.0.0:3001->3001/tcp, 0.0.0.0:8001->8000/tcp, 0.0.0.0:8080->8080/tcp

Yes I started my environment with docker-compose up -d nginx mariadb

@bobbybouwmann thank you for helping me. Yes I ran docker-compose up -d nginx mariadb exactly. I checked my .env and I have set PMA_DB_ENGINE=mariadb I think I set that trying to debug with some mariadb administrator that exists within laradock but I don't remember which was it.

Apr
12
1 month ago
Activity icon

Started a new Conversation Can't Connect With MariaDB And Laradock

I have a project that in a past computer it ran with MariaDB with laradock, now I'm trying with a new computer with all within laradock, but I can't figure it whats the problem, even with other databases I cant connect, but don't know what changed.

My laravel project .env

#####for maria db using laradock #######
DB_CONNECTION=mysql
DB_HOST=mariadb
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=root
DB_PASSWORD=root
####################### #######

My .env whitin laradock

### MARIADB ###############################################

MARIADB_VERSION=latest
MARIADB_DATABASE=default
MARIADB_USER=default
MARIADB_PASSWORD=secret
MARIADB_PORT=3306
MARIADB_ROOT_PASSWORD=root
MARIADB_ENTRYPOINT_INITDB=./mariadb/docker-entrypoint-initdb.d

my error when running php artisan migrate:fresh --seed

[email protected]:/var/www/simpligps-api# php artisan migrate:fresh --seed

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2006] MySQL server has gone away (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:670
    666|         // If an exception occurs when attempting to run a query, we'll format the error
    667|         // message to include the bindings with SQL, which will make this exception a
    668|         // lot more helpful to the developer instead of just the database's errors.
    669|         catch (Exception $e) {
  > 670|             throw new QueryException(
    671|                 $query, $this->prepareBindings($bindings), $e
    672|             );
    673|         }
    674| 

      +48 vendor frames 

Should I do any configuration?

Feb
26
3 months ago
Activity icon

Awarded Best Reply on Laravel Pusher Doesn't Join Private Channel

well, maybe, so the request to /auth is not happening? maybe as you said, now the request should be happening in /en/auth

Feb
25
3 months ago
Activity icon

Replied to Laravel Pusher Doesn't Join Private Channel

well, maybe, so the request to /auth is not happening? maybe as you said, now the request should be happening in /en/auth

Feb
22
3 months ago
Activity icon

Replied to Laravel Pusher Doesn't Join Private Channel

Hi @orhdoga, when you use a private channel, first it makes an authentication that will bring a token that will be used on pusher later. Check if that your '/auth' request on the network tab of your browser is not giving you a 404 or another bad status code. That request is done automatically by laravel echo.

Jan
29
3 months ago
Activity icon

Replied to Fractal Library Vs Json:api Library?

Hi @dingo_d I haven't used any of those but why not to just use the laravel API Resources classes? Is there any specific functionality you want? API resources are great for mapping and formating resource. I think the reasons the packages you mentioned are popular is because they were released before laravel api resources.

Jan
28
4 months ago
Activity icon

Replied to Eloquent: Relationships - Help!

Do another table for categories and products_categories

Or another approach is that if you will use categories only for showing data you could add it as a json field in your products table and then use model array casting.