Giorgiovski

Giorgiovski

Member Since 10 Months Ago

Experience Points
11,200
Total
Experience

3,800 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
95
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 3
11,200 XP
Oct
21
1 week ago
Activity icon

Started a new Conversation Passing Arguments Between Factories In Seeders

I want to make a seeder that creates data in multiple tables related to some data(pin model). The problem is, I need data from pins to pass to secondary factories and that fact creates 100 pins instead of 50. I need a way to get pin info and pass it directly to UserStatus for avoiding pin records duplication.

PinSeeder class

class PinSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        factory(Pin::class, 50)->create()->each(function ($pin) {
            $userStatus = factory(UserStatus::class)->make(['info' => $pin->info]);
            $pin->userStatus()->save($userStatus);

//userStatus() method is the relationship
        });
    }
}

UserStatus factory

$factory->define(UserStatus::class, function (Faker $faker) {

    $pin = factory(Pin::class)->create();
    $info = $pin->info;

    return [
        'address' => $info['pinAddress'],
        'code_series' => $info['pinCode'],
        'defaultName' => $info['pinName'],
        'pin_id' => $pin->id,
];
)};

How can I do that? Thank you.

Oct
08
3 weeks ago
Activity icon

Started a new Conversation Nova Filter - Search By Multiple Values In The Same Filter

I'm using Laravel Nova and MegaFilter

https://novapackages.com/packages/digital-creative/nova-mega-filter

I have only one filter and I want to pass multiple values in the filter input, but separated by -.

Example: add firstValue - secondValue - thirdValue in the search input and return all the records which contain these values.

Thank you.

Oct
02
4 weeks ago
Activity icon

Replied to Testing Nova With Laravel Dusk

@bugsysha No, but I will try. Thank you.

Oct
01
4 weeks ago
Activity icon

Replied to Testing Nova With Laravel Dusk

@bugsysha Thank you! It works in case of creating fields, but how about filters? How can I assign an attribute to them?

Sep
30
1 month ago
Activity icon

Started a new Conversation Testing Nova With Laravel Dusk

In my Nova project, I have auto-generated elements with "data-v-111112" div names. I want to use Dusk for testing from the browser but I don't know how to pass to tests their auto-generated names. Is there a way to do that?

Thank you.

Sep
21
1 month ago
Activity icon

Started a new Conversation Getting URL Path In Nova Action

Hello!

I'm trying to get the URI which contains my filters for saving them in DB. I use handleRequest() function in some action.

The returned path is nova-api/resource/lens/etc/action. I want to get all the long URL created from filters.

How can I do that? Thank you.

Sep
15
1 month ago
Activity icon

Started a new Conversation Distinct Does Not Work In Left Join

Hello.

I have table A and table B. Table B has multiple table A records. I need to create a left join for taking only unique items. I tried with distinct, unique, selectRaw, DB raw but nothing works. Maybe I have a mistake in my code:

->leftJoin(DB::raw("(SELECT DISTINCT B.product_id FROM B)"),'B.product_id', '=', 'A.product_id');

I want to take the B records but only which are not duplicates. Thanks.

Aug
16
2 months ago
Activity icon

Replied to Parallel Requests With Guzzle Async

Hello, @franciscool004 !

This is my function. So the time is the same slowly even I do the requests in a concurrent way. For 30 requests last minutes. My goal is to send 30 requests once, like from 30 different computers and to load the content in 10 seconds, like for a single request.

<?php

use GuzzleHttp\Promise;
use GuzzleHttp\Client;

class Elasticsearch
{
    
    public static function getDataByHash($hash)
    {
        $client = new Client(['base_uri' => 'My ELASTIC SEARCH URL]);

        //here will be 30 requests on 30 different indexes
        $promises = [
            'data1' => $client->getAsync('/index01/_search?q=hash:'.$hash),
            'data2'   => $client->getAsync('/index02/_search?q=hash:'.$hash),
            'data3'  => $client->getAsync('/index03/_search?q=hash:'.$hash),
            'data4'  => $client->getAsync('/index04/_search?q=hash:'.$hash)
        ];

        $responses = Promise\settle($promises)->wait();
        $convertToJson = json_decode($responses['data1']['value']->getBody());
        $convertToJson = json_encode($convertToJson);

        echo $convertToJson;
    }

}

I hope there is just a wrong approach from me. :)) Thank you!

Aug
14
2 months ago
Activity icon

Started a new Conversation Parallel Requests With Guzzle Async

I'm using Elastic Search and I have a size of 15TB there. A simple search in a single index lasts 10 seconds. I want to make 30 request, each for an index.

If I'm using Guzzle Asynchronous Requests, why the requests takes minutes? The async is not really async? Why it doesn't return all the requests fast supossed those are called in parallel?

Is maybe about Elastic search requests per server?

Aug
07
2 months ago
Activity icon

Replied to Installing Vagrant And Xamp On The Same Machine

Hello @marianomoreyra ! Thank you for your time. I strictly want Xamp installed directly on my computer to run a project on local and to run another project with Vagrant. The question is if I can open both of them in the same time and there won't be errors.

Thank you.

Activity icon

Started a new Conversation Installing Vagrant And Xamp On The Same Machine

Can I run two separate environments on the same machine like one server with Vagrant and another one with Xampp?

If I have Vagrant for a project and I will install Xampp, there are some interferences at ports? I can install it without broke the vagrant stuffs?

Thank you.

Jul
08
3 months ago
Activity icon

Started a new Conversation Clearing Redis Cache With Cache:clear

I am trying to learn Redis by testing it.

I created a custom function in my routes:

Route::get('/', function () {
    // redis has posts.all key exists 
    // posts found then it will return all post without touching the database
    if ($roles = Redis::get('role.all')) {
        return json_decode($roles);
    }
    
    // get all post
    $posts = Role::all();
 
    // store into redis
    Redis::set('role.all', $roles);
 
    // return all posts
    return $roles;
});

I run that once and after that, I delete all the roles from the DB but REDIS still showing the saved values from Database. I cleared the cache from chrome, I run cache:clear and config:cache in artisan, but nothing happens. Redis continue to show me the values.

In my .env the driver is CACHE_DRIVER=redis

and in my cache.php the default driver is 'default' => env('CACHE_DRIVER', 'redis')

How can I clear my Redis cache?

Activity icon

Started a new Conversation PgSql Error When Trying To Get Users

My database runs properly when I run the tests and when I migrate but when I'm trying to get users from DB I have this error: (With the same settings!)

SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 54321? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 54321? (SQL: select * from "users")

I have a test route in web.php

Route::get('/', function () {
    if ($posts = Redis::get('users.all')) {
        return json_decode($posts);
    }
 
    // get all post
    $posts = User::all();
 
    // store into redis
    Redis::set('posts.all', $posts);
 
    // return all posts
    return $posts;
});

I'm using Docker containers for all the services.

This is my docker-compose file:

version: "3"

######### Services ###################################

services:
  # Server container
  nginx:
    build:
      context: docker/dev/nginx
      dockerfile: Dockerfile
    volumes:
      - ./:/var/www
      - ./docker/dev/nginx/logs:/var/log/nginx
    ports:
      # Nuxt port
      - 8080:80
      # Laravel port
      - 8081:81
    links:
      - client
      - php

  # PHP FastCGI Process Manager container
  php:
    build:
      context: docker/dev/php
      dockerfile: Dockerfile
    volumes:
      - ./api:/var/www/api
    environment:
      # If you down want to use xDebug, set remote_enable=0
      XDEBUG_CONFIG: "remote_enable=1"
      PHP_IDE_CONFIG: "serverName=Docker"
    links:
      - postgres
      - postgres-testing
      - redis
      - mailhog

  # Supervisor container (schedule and queue runner)
  supervisor:
    build:
      context: docker/dev/supervisor
      dockerfile: Dockerfile
    volumes:
      - ./:/var/www/
      - ./docker/dev/supervisor/conf.d:/etc/supervisor/conf.d
      - ./docker/dev/supervisor/logs:/var/log
    links:
      - postgres
      - redis
      - mailhog

  # PostgreSQL database container
  postgres:
    build:
      context: docker/dev/postgres
      dockerfile: Dockerfile
    volumes:
      # Database volume: Does not work with ./database before in WIN 10. 
      - /var/lib/postgresql/data
      # Temp volume to allow using dumps
      - ./docker/dev/postgres/dumps/:/tmp/
    ports:
      - 54321:5432
    environment:
      - LC_ALL=C.UTF-8
      - POSTGRES_DB=app
      - POSTGRES_USER=app
      - POSTGRES_PASSWORD=app

  # PostgreSQL testing database container
  postgres-testing:
    build:
      context: docker/dev/postgres
      dockerfile: Dockerfile
    environment:
      - LC_ALL=C.UTF-8
      - POSTGRES_DB=app
      - POSTGRES_USER=app
      - POSTGRES_PASSWORD=app

  # Redis container
  redis:
    build:
      context: docker/dev/redis
      dockerfile: Dockerfile
    volumes:
      - redis:/data
    ports:
      - 63791:6379

  # Mailhog container (SMTP testing)
  mailhog:
    build:
      context: docker/dev/mailhog
      dockerfile: Dockerfile
    ports:
      - 8026:8025

  # Client container
  client:
    build:
      context: docker/dev/client
      dockerfile: Dockerfile
    volumes:
      - ./client:/var/www/client

######### Volumes ###################################

volumes:
  database:
    driver: local
  redis:
    driver: local

Jun
26
4 months ago
Activity icon

Started a new Conversation Endpoint Returns Home Page Instead JSON

I reinstalled my Windows and I can't understand why my endpoints return my localhost home page instead of JSON response. I'm using POSTMAN and I filled the body properly. The database record is inserted but still, the endpoint does not return JSON.

I have that in my vhosts

127.0.0.1       myapp.test

and my API route(in api.php)

Route::post('register', 'Common\[email protected]');

My endpoint is like:

myapp.test/api/gym/USERid

It's the same project but I don't know why now it goes wrong. What I did wrong?

PS: I'm using laradock with the Nginx server.

May
27
5 months ago
Activity icon

Replied to Installing Swagger In Laravel 7 With Laradock

The problem is at installation. Does it mean I need to add a provider before installing something? It's not logical to add it before installing that package(generally example).

Activity icon

Replied to Installing Swagger In Laravel 7 With Laradock

No, it wasn't. And to try also to avoid error I wrote this line and I run composer update. I receive the same error.

Activity icon

Replied to Installing Swagger In Laravel 7 With Laradock

Thank you, mate, but I can't clear the cache and config cache because the composer command is not finishing the process. I got this error before completing it and the composer.json returns at the initial state.

May
26
5 months ago
Activity icon

Started a new Conversation Installing Swagger In Laravel 7 With Laradock

I'm trying to install Swagger and I gave an error. I'm using Laradock and I think the path is the problem or something because of the environment. Some guys recommend to use swagger php 2, but it returns the same error. I tried also to install swagger without being in laradock workspace bash, it gives the same error.

When I run

composer require "darkaonline/l5-swagger"

I gave the error

TypeError

  Argument 2 passed to L5Swagger\Generator::__construct() must be of the type string, null given, called in /var/www/vendor/darkaonline/l5-swagger/src/L5SwaggerServiceProvider.php on line 66

  at vendor/darkaonline/l5-swagger/src/Generator.php:62
    58|      * @var string
    59|      */
    60|     protected $swaggerVersion;
    61|
  > 62|     public function __construct(
    63|         $annotationsDir,
    64|         string $docDir,
    65|         string $docsFile,
    66|         string $yamlDocsFile,

      +20 vendor frames
  21  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Thank you very much.

May
12
5 months ago
Activity icon

Awarded Best Reply on Laradock Docker Filesharing Errors

Update: I solved that by stoping Windows Firewall.

Activity icon

Replied to Laradock Docker Filesharing Errors

Update: I solved that by stoping Windows Firewall.

Activity icon

Started a new Conversation Laradock Docker Filesharing Errors

I installed windows 10 again and I'm trying to set my environment through laradock from my git account. I have these errors:

ERROR: Encountered errors while bringing up the project.

ERROR: for postgres  Cannot create container for service postgres: status code not OK but 500: {"Message":"Unhandled exception: Filesharing has been cancelled","StackTrace":"   at Docker.ApiServices.Mounting.FileSharing.<DoShareAsync>d__6.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\Mounting\FileSharing.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Docker.ApiServices.Mounting.FileSharing.<ShareAsync>d__4.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\Mounting\FileSharing.cs:line 47\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Docker.HttpApi.Controllers.FilesharingController.<ShareDirectory>d__2.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.HttpApi\Controllers\FilesharingController.cs:line 21\r\n--- End of stack trace
from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__1`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"}
May
11
5 months ago
Activity icon

Replied to Fixing RequestGuard::attempt Does Not Exist

Thank you @nakov. It does not work because I don't have the same issue, but the error is the same. I just moved from JWT and maybe it overrides some things. I can't get who those are. I repeated the process and the error is still there.

May
10
5 months ago
Activity icon

Started a new Conversation Fixing RequestGuard::attempt Does Not Exist

I'm moving from JWT to Passport. In my opinion I added all things properly. I tried a lot of things from others issues but nothing works. When I'm trying to test login api I receive this error:

Method Illuminate\Auth\RequestGuard::attempt does not exist.

My login function:

    public function login(Request $request)
    {
      $credentials = $request->only(['email', 'password']);

      if (!auth()->attempt($credentials)) {
        return response()->json(['error' => 'Unauthorized'], 401);
      }

      $accessToken = auth()->user()->createToken('authToken')->accessToken;
      return response(['user' => Auth::user(), 'access_token' => $accessToken]); 
    }

My user model:

namespace App\Models\Common;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'role_id','first_name', 'last_name', 'email', 'password',  'social_media_token', 'profile_picture', 
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

My config/auth.php:

  'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],

  'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
            'hash' => false,
        ],
    ],

My API routes:

Route::middleware(['auth:api','trial'])->group(function () {
    Route::get('profile', 'Common\[email protected]');
    Route::get('profile/{userId}', 'Common\[email protected]');
    Route::put('profile/update/{userId}', 'Common\[email protected]');
    Route::delete('profile/delete/{userId}', 'Common\[email protected]')->middleware('deletePasswordConfirmation');
});
May
04
5 months ago
Activity icon

Replied to Testing Image Upload With Intervention Image Bundle

Man, I had hours to find what's wrong. I can't believe only that was the problem.

You made my day, seriously. Thank you very much and have a great day!

Activity icon

Started a new Conversation Testing Image Upload With Intervention Image Bundle

I wrote a test for testing the uploaded image. When I'm testing the API with Postman and Insomnia it works well. But the test fail because the intervention image returns an error. If I switch from intervention image to normal save it works. But I want to use it for resizing images.

This is the line which returns errors:

Image::make($request->file('profile_picture'))->fit(250, 250)->save($path.$fileNameToStore);

The error:

Can't write image data to path (storage/profile_pictures/avatarForTesting_1588586805.jpg)

Test

 public function testIfUsersCanUploadFirstAvatar(){

          $this->withoutExceptionHandling();

        // Create user
        $user = factory(User::class)->create();
        $trainee = factory(Trainee::class)->create(['trainee_id' => $user->id]);
        
        // Login user
        $this->actingAs($user);
        
        // Update profile with filled file upload request
        $response = $this->json('POST','http://api.'.env('APP_URL').'/profile/update/avatar/'.$user->id, 
            [
                'profile_picture' => UploadedFile::fake()->image('avatarForTesting.jpg', 200)
            ]);
        
        
        // Check if the avatar path is updated regarding uploaded picture
        $getImageName = User::find($user->id);
        $this->assertEquals(substr($getImageName->profile_picture, 0, -15), 'avatarForTesting');
    }

Upload Image

public function saveProfilePicture(Request $request, $userId)
     {
         $request->validate([
             'profile_picture' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:5120',
         ],
 
         ['Please select an avatar before trying to upload',]
     );

         //Users avatar uploading
         if ($request->hasFile('profile_picture')) {
             // Get filename with the extension
             $filenameWithExt = $request->file('profile_picture')->getClientOriginalName();
             // Get just filename
             $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
             // Get just ext
             $extension = $request->file('profile_picture')->getClientOriginalExtension();
             // Filename to store
             $fileNameToStore= $filename.'_'.time().'.'.$extension;
 
             //Reduce the size of the image and upload image
             $path = 'storage/profile_pictures/';
            // $path = $request->file('profile_picture')->storeAs('storage/profile_pictures', $fileNameToStore);
             Image::make($request->file('profile_picture'))->fit(250, 250)->save($path.$fileNameToStore);
         } else {
             $fileNameToStore = 'no_profile_picture.jpg';
         }

Thank you in advance.