isadma

isadma

Member Since 9 Months Ago

Experience Points
3,270
Total
Experience

1,730 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
19
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 1
3,270 XP
Oct
25
5 days ago
Activity icon

Replied to Best Way To Cache Js And Css Files On Browser Except Laravel-mix

Now I understood @Sinnbeck. Thank you very much for your support.

Activity icon

Replied to Best Way To Cache Js And Css Files On Browser Except Laravel-mix

Thank you for your reply.

Now I am adding ?v={id} end of the css and js URLs for version. For example: /css/style.css?v=1602795152

Do I need to add also ?v=... end of image files?

Activity icon

Started a new Conversation Best Way To Cache Js And Css Files On Browser Except Laravel-mix

Hello.

Every time I reload the page, the app fetches all the css and js files. How can I cache them to prevent this and save traffic?

I need a solution other than laravel-mix.

What is the best way for caching assets for Laravel and Nginx?

Oct
06
3 weeks ago
Activity icon

Started a new Conversation Install GRPC For PHP Failed

I want to install gRPC to ubuntu 16.04 for PHP. I followed the official documentation: https://cloud.google.com/php/grpc#build-from-source

When I run this command:

sudo make install

I am getting this error:

Installing via 'make' is no longer supported. Use cmake or bazel instead. Please consult BUILDING.md to get more information.

How can I use cmake or bazel to install? Please, help me.

Note: I can not user PECL. PECL's website is blocked by my hosting provider. That's why I need to build it manually.

Activity icon

Replied to Install GRPC For PHP

I tried manually build. When I run this command:

sudo make install

I am getting this error:

Installing via 'make' is no longer supported. Use cmake or bazel instead. Please consult BUILDING.md to get more information.

Can you help me, please? How can I use cmake or bazel to install?

Activity icon

Replied to Install GRPC For PHP

Ok, thank you.

Activity icon

Replied to Install GRPC For PHP

No no, it is a government hosting provider. So they do what they want. And I need to deploy the project only to this server... Please if you have in idea, share with me

Activity icon

Replied to Install GRPC For PHP

I realized that my server provider blocked the pecl's website (pecl.php.net). I couldn't ping it.

Are there any alternatives for pecl? Or how can I install a VPN for my server? Or can I copy this gRPC package from another server that I already have installed? Pls help if you have an idea

Oct
05
3 weeks ago
Activity icon

Replied to Install GRPC For PHP

Ubuntu 16.04 x64 PEAR Version: 1.10.8

Activity icon

Started a new Conversation Install GRPC For PHP

I want to install gRPC for PHP 7.3. I followed Google Cloud documentation (https://cloud.google.com/php/grpc#using-pecl).

I use:

Ubuntu 16.04 x64
Nginx, PHP 7.3
PEAR Version: 1.10.8 

I install:

sudo apt-get install autoconf zlib1g-dev php-dev php-pear
sudo pecl install grpc

But I am getting this error:

No releases available for package "pecl.php.net/grpc"
install failed

I don't know what is wrong.

It is php -v:

PHP 7.3.22-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep  9 2020 06:46:12) ( NTS )   
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.22-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies 

Please, help me.

Sep
17
1 month ago
Activity icon

Awarded Best Reply on Laravel Queue Not Working On Deployment

Make sure your app is not in maintenance mode...

Queue doesn't work in maintenance mode.

Activity icon

Replied to Laravel Queue Not Working On Deployment

Make sure your app is not in maintenance mode...

Queue doesn't work in maintenance mode.

Activity icon

Started a new Conversation Laravel Queue Not Working On Deployment

I use laravel 6. It works on my local but after uploading, it stopped to work. I use the queue database (MySQL).

Console:

dispatch((new FirestoreSetJob($collection, $faq->id, json_decode((new FaqResource($faq))->toJson(), true))));

Job:

class FirestoreSetJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $collection, $id, $data;

    public function __construct($collection, $id, $data)
    {
        $this->collection = $collection;
        $this->id = $id;
        $this->data = $data;
    }

    public function handle()
    {
        Firestore::set($this->collection, $this->id, $this->data);
    }
}

And for to run, I used:

php artisan queue:work database --queue=default

When I enter this command on the terminal, nothing happens and appears. But it works on my local.

Please, help me. What is my problem?

Activity icon

Started a new Conversation __construct On Eloquent Observer

How can I use __construct function on Obserber.

It is my observer:

class CityObserver
{
    public $collection, $data;

    public function __construct(City $city)
    {
        $this->collection = 'cities';
        $this->data = json_decode((new CityResource($city))->toJson(), true);
    }

    public function created(City $city)
    {
        dispatch(new FirestoreSetJob($this->collection, $city->id, $this->data));
    }

    public function updated(City $city)
    {
        dispatch(new FirestoreSetJob($this->collection, $city->id, $this->data));
    }
}

See all of the functions use $this->collection and $this->data.

How can I set these two variables in __construct?

Sep
16
1 month ago
Activity icon

Replied to Add Queue To Eloquent Observer

In my case, I need to store my data on MySQL and firebase.

My main database is MySQL.

So when data changes on MySQL, it should also change on firebase. The Firebase update process takes a little bit of time, that's why I want to add a queue to Eloquent observer

Activity icon

Replied to Add Queue To Eloquent Observer

Yes, you are right.

Activity icon

Started a new Conversation Add Queue To Eloquent Observer

How can I queue Eloquent Observers?

class ExampleObserver
{
    public function created(Example $example)
    {
        //do something on queue
    }
}
Sep
12
1 month ago
Activity icon

Replied to Add A Custom Item To Eloquent Collection

Thank you for your answer. It works

Activity icon

Started a new Conversation Add A Custom Item To Eloquent Collection

I am using Laravel 7.

I have Category model. I sent categories as API with laravel resources. But now I want to add "all" value to categories.

Controller:

'categories' => CategoryResource::collection(Category::all()->push([
      'id' => 0,
      'name' => "All",
      'subcategories' => []
 ]))

My resource:

public function toArray($request)
{
     return [
          'id' => $this->id,
          'name' => $this->name,
          'subcategories' => SubcategryResource::collection($this->subcategories)
     ];
}

Also, I wanted to add this custom value to the beginning of the collection.

But I am getting this error:

Trying to get property 'id' of non-object

Please, help me. How can I solve my problem?

Sep
02
1 month ago
Activity icon

Replied to How Can I Add TLSv1.2 And TLSv1.1 To Ssl Protocols?

Ok. So, how can I add just TLSv1.2?

Because TLSv1.3 is a problem for flutter.

Activity icon

Started a new Conversation How Can I Add TLSv1.2 And TLSv1.1 To Ssl Protocols?

Even if I don't add TLSv1.3, still only TLSv1.3 appears.

How can I add TLSv1.2 and TLSv1.1 to ssl protocols?

You can check on this link: https://ibb.co/4WYd0Jw

it is my nginx conf:

ssl_session_cache shared:le_nginx_SSL:1m;
ssl_session_timeout 1440m;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

It is my nginx and openssl version:

nginx version: nginx/1.18.0
built with OpenSSL 1.1.1g  21 Apr 2020
TLS SNI support enabled
Jul
29
3 months ago
Activity icon

Replied to Handshake Error On Flutter With Laravel 7

I checked these stackoverflow link before. It didn't help.

Activity icon

Replied to Handshake Error On Flutter With Laravel 7

Thank you for your reply. How can I check that SSL certificate is valid or not?

Activity icon

Started a new Conversation Handshake Error On Flutter With Laravel 7

I use Laravel 7 for backend, Nginx on the server, and flutter for apps.

I installed an SSL layer for my server by using Let's encrypt and Certbot. Before SSL everything was fine, it was working. But after installing SSL I got this error on flutter:

HandshakeExceiption: Handshake error in client (OS error: TLSV1_ALERT_PROTOCOL_VERSION(tls_record.cc:587))

It is my flutter request code:

import 'package:package_info/package_info.dart';
import 'dart:io';
import 'package:dio/dio.dart';
import './home.dart';
import './auth.dart';

String token;

class RootProvider {
  static Dio http = Dio();
  static final baseUrl = "https://my_domain.com/api";
  static String locale = '';

  static Future<void> setRequestHeaders() async {
    token = await AuthProvider.getToken();
    String _locale = await HomeProvider.getLocale();
    locale = _locale == 'en' ? 'tm' : _locale;
    PackageInfo packageInfo = await PackageInfo.fromPlatform();
    String platform = "";

    if (Platform.isAndroid) {
      platform = "android";
    } else if (Platform.isIOS) {
      platform = "ios";
    }

    var headers = {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
      'Language': _locale == 'en' ? 'tm' : _locale,
      'Version': packageInfo?.version,
      'Platform': platform,
    };
    if (token != null) headers['Authorization'] = "Bearer $token";
    http.options.baseUrl = baseUrl;
    http.options.headers = headers;
  }

  static init() async {
    await setRequestHeaders();

    http.interceptors.add(
      InterceptorsWrapper(
        onRequest: (RequestOptions options) {
          print('Making request to ${options.method} ${options.uri}');
        },
        onResponse: (Response response) {
          // if response successful then return data
          if (response.data['success'] == true && response.data['success']) {
            return http.resolve(response);
          }

          return http.reject(response.data['message']);
        },
        onError: (DioError e) async {
          return http.reject(e);
        },
      ),
    );
  }
}

It is my Nginx conf:

server {
    listen 80;
    listen [::]:80;

    server_name my_domain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name my_domain.com;
    root /var/www/my_domain/public;

        ssl_certificate /etc/letsencrypt/live/my_domain.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/my_domain.com/privkey.pem;

        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Content-Type-Options "nosniff";

        index index.php index.html index.htm index.nginx-debian.html;

    charset utf-8;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }

    location ~ /.well-known {
            allow all;
    }
}

Note: I tried to send a request by Axios on javascript and I got a success response. It works on Axios and Javascript. It is only not working on flutter.

Please, help me to find problem. Thank you in advance

Jul
11
3 months ago
Activity icon

Started a new Conversation Laravel Websockets: WebSocket Is Closed Before The Connection Is Established.

I want to use Laravel Websockets. But I am getting error on deployment.

I use Laravel 6, PHP 7.4, Ubuntu 18.04, Nginx.

Actually it is working on locale without a problem. But after uploading, I don't see any results on the console. I didn't forget to work laravel jobs.

When I visit the laravel websockets dashboard, I get this error:

WebSocket is closed before the connection is established.	
Channels current state is unavailable

And when I visit my '/' route, I get var_dump('Done');. But I can not see it on the console. The console is empty.

config/broadcasting.php

 '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'),
                'encrypted' => true,
                'host' => '127.0.0.1',                                                                                                                                                  
                'port' => 6001,
                'scheme' => 'https',
                'curl_options' => [
                    CURLOPT_SSL_VERIFYHOST => 0,
                    CURLOPT_SSL_VERIFYPEER => 0,
                ]
            ],
            'log' => true
        ],

config/websockets.php

<?php

use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;

return [

    /*
     * Set a custom dashboard configuration
     */
    'dashboard' => [
        'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
    ],

    'apps' => [
        [
            'id' => env('PUSHER_APP_ID'),
            'name' => env('APP_NAME'),
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'path' => env('PUSHER_APP_PATH'),
            'capacity' => null,
            'enable_client_messages' => false,
            'enable_statistics' => true,
        ],
    ],

    'app_provider' => BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider::class,

    'allowed_origins' => [
        //
    ],

    'max_request_size_in_kb' => 250,

    'path' => 'websockets',

     'middleware' => [
        'web',
        Authorize::class,
    ],

     'statistics' => [
        'model' => \BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry::class,

        'interval_in_seconds' => 60,

        'delete_statistics_older_than_days' => 60,

        'perform_dns_lookup' => false,
    ],  

    'ssl' => [
        'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),

        'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),

      	'passphrase' => null,

        'verify_peer' => false,
    ],

    'channel_manager' => \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers\ArrayChannelManager::class,
];    

.env:

PUSHER_APP_ID=abcdefid
PUSHER_APP_KEY=abcdefkey
PUSHER_APP_SECRET=abcdefsecret
PUSHER_APP_CLUSTER=mt1
LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT=/var/www/pursat/storage/fullchain2.pem
LARAVEL_WEBSOCKETS_SSL_LOCAL_PK=/var/www/pursat/storage/privkey2.pem

Event:

<?php

namespace App\Events;

use App\User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class SendSms implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $user;

    public $broadcastQueue = 'sms-queue';

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('sms');
    }

    public function broadcastAs(){
        return 'sms.created';
    }

    public function broadcastWith()
    {
        return [
            'user_id' => $this->user->id,
            'name' => $this->user->name,
            'phone' => '+993'.$this->user->phone,
            'message' => 'PURSAT üçin belgiňiz: '.$this->user->otp,
        ];
    }
}

Route:

Route::get('/', function (){
        $user = \App\User::wherePhone(64381045)->first();
        event(new \App\Events\SendSms($user));
        var_dump('Done');
    });

Nginx:

server {
    listen 80;
    listen [::]:80;

    server_name pursat.safedevs.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name pursat.safedevs.com;
    root /var/www/pursat/public;

    ssl_certificate /etc/letsencrypt/live/pursat.safedevs.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/pursat.safedevs.com/privkey.pem;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
        ssl_prefer_server_ciphers on;

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Content-Type-Options "nosniff";

        index index.php index.html index.htm index.nginx-debian.html;

    charset utf-8;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }
    location ~ /.well-known {
            allow all;
    }
}
May
31
4 months ago
Activity icon

Awarded Best Reply on Convert API Resource To Array

This code works fine

public function set(User $user){
    $this->firestore->document($user->id)->set(json_decode((new UserResource($user))->toJson(), true));
}
Activity icon

Replied to Convert API Resource To Array

This code works fine

public function set(User $user){
    $this->firestore->document($user->id)->set(json_decode((new UserResource($user))->toJson(), true));
}
Activity icon

Replied to Convert API Resource To Array

Because I use same format in all places. User model has also relations. I haven't added relation data to ApiResource yet. The same data I need to send to another place as a son. I didn't want to code twice. That's why I wanted to use ApiResource

Activity icon

Replied to Convert API Resource To Array

I got this error:

Too few arguments to function App\Http\Resources\MobileApi\UserResource::toArray()
Activity icon

Started a new Conversation Convert API Resource To Array

I want to store data on Firestore. I need to send an array to Firestore. I have API resources and I wanted to use it.

My resource:

    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'phone' => $this->phone,
            'addresses' => AddressResource::collection($this->addresses),
        ];
    }

Firestore:

    public function set(User $user){
        $userResource = new UserResource($user);
        $this->firestore->document($user->id)->set($userResource);
    }

The error:

Argument 1 passed to Google\Cloud\Firestore\DocumentReference::set() must be of the type array, object given...
May
01
5 months ago
Activity icon

Replied to Collection Filter

No, I haven't tried. Can you help me?

Activity icon

Started a new Conversation Collection Filter

I have this kind of $contracts collection:

[
  {
    id: 129,
    user_id: 32,
    edara_id: 6,
    etrap_id: 6,
    contract_number: "1/96-987835s",
    from: 1583002800,
    to: 1588186800,
    type_id: 131,
    name: "Maksat Meredow",
    director_name: "Maksat Meredov",
    hs: "3456789",
    bank_id: 214,
    mfo: "45678",
    salgyt_kody: "345678",
    bas: "BH8435734N",
    patent: "39483958",
    bellik: null,
    viewer_note: null,
    uzatmak: 0,
    yatyr_bellik: null,
    yatyr_operator: null,
    yatyr_onki_wagt: null,
    operator_id: 32,
    created_at: "2020-04-27 14:23:17",
    updated_at: "2020-04-27 14:23:17",
    karende_yer: [
      {
        id: 136,
        user_id: 32,
        operator_id: 32,
        edara_id: 6,
        etrap_id: 5,
        karendeche_id: 129,
        gaty: 135,
        uzatmak: 0,
        note: null,
        status: 1,
        shertnamanyn_bahasy: 142.78,
        kone_shertnamanyn_bahasy: null,
        wagt_shertnamanyn_bahasy: null,
        shertnamanyn_konelme: 32.19,
        kone_shertnamanyn_konelme: null,
        wagt_shertnamanyn_konelme: null,
        karende_meydany: 79,
        kone_karende_meydany: null,
        wagt_karende_meydany: null,
        created_at: "2020-04-27 14:24:12",
        updated_at: "2020-04-27 14:24:12",
        yatyrylan_senesi: null,
        address: {
          id: 225,
          karendeche_id: null,
          karende_yer_id: 136,
          state_id: 1,
          welayat: null,
          shaher: null,
          etrap: "5",
          etrapcha: "380",
          geneshlik: null,
          oba: null,
          gechelge: null,
          koche: "360",
          korpus: null,
          girelge: null,
          jay: "78",
          otag: "23",
          created_at: "2020-04-27 14:24:12",
          updated_at: "2020-04-27 14:24:12"
        },
        ulan_mak: [
          {
            id: 160,
            type: 6,
            name: "Ammar",
            slug: "ammar",
            status: 1,
            created_at: "2019-12-14 03:57:13",
            updated_at: "2019-12-14 03:57:13",
            pivot: {
              karende_yer_id: 136,
              address_content_id: 160
            }
          },
          {
            id: 165,
            type: 6,
            name: "Aragatnaşyk enjamlaryny otyrtmak",
            slug: "aragatnasyk-enjamlaryny-otyrtmak",
            status: 1,
            created_at: "2019-12-14 04:01:24",
            updated_at: "2019-12-14 04:01:24",
            pivot: {
              karende_yer_id: 136,
              address_content_id: 165
            }
          }
        ]
      }
    ],
    payments: [
      {
        id: 3,
        karendechi_id: 129,
        toleg: 96.8,
        wagt: 1587927600,
        kwitansiya: "KJN343434",
        bellik: null,
        created_at: "2020-04-27 14:25:24",
        updated_at: "2020-04-27 14:25:24"
      }
    ]
  },
  {
    id: 41,
    user_id: 32,
    edara_id: 6,
    etrap_id: 5,
    contract_number: "1/96-34376s",
    from: 1514746800,
    to: 1609354800,
    type_id: 132,
    name: ""Dertdeş"",
    director_name: "Halmuhammedow M.",
    hs: "23201934120181900038000",
    bank_id: 347,
    mfo: "390101201",
    salgyt_kody: "103131010971",
    bas: "0",
    patent: "0",
    bellik: null,
    viewer_note: null,
    uzatmak: 0,
    yatyr_bellik: null,
    yatyr_operator: null,
    yatyr_onki_wagt: null,
    operator_id: 32,
    created_at: "2019-12-26 15:28:23",
    updated_at: "2019-12-26 15:28:23",
    karende_yer: [
      {
        id: 38,
        user_id: 32,
        operator_id: 32,
        edara_id: 6,
        etrap_id: 8,
        karendeche_id: 41,
        gaty: 135,
        uzatmak: 0,
        note: null,
        status: 1,
        shertnamanyn_bahasy: 1572.3,
        kone_shertnamanyn_bahasy: null,
        wagt_shertnamanyn_bahasy: null,
        shertnamanyn_konelme: 10.58,
        kone_shertnamanyn_konelme: null,
        wagt_shertnamanyn_konelme: null,
        karende_meydany: 174.7,
        kone_karende_meydany: null,
        wagt_karende_meydany: null,
        created_at: "2019-12-26 15:42:05",
        updated_at: "2019-12-26 15:42:44",
        yatyrylan_senesi: null,
        address: {
          id: 40,
          karendeche_id: null,
          karende_yer_id: 38,
          state_id: 1,
          welayat: null,
          shaher: null,
          etrap: "8",
          etrapcha: "287",
          geneshlik: null,
          oba: null,
          gechelge: null,
          koche: null,
          korpus: null,
          girelge: null,
          jay: "44",
          otag: null,
          created_at: "2019-12-26 15:42:05",
          updated_at: "2019-12-26 15:42:05"
        },
      ulan_mak: [
        {
          id: 32,
          type: 6,
          name: "Dükan",
          slug: "dukan",
          status: 1,
          created_at: "2019-11-02 08:08:18",
          updated_at: "2019-12-11 02:08:31",
          pivot: {
            karende_yer_id: 38,
            address_content_id: 32
          }
        },
        {
          id: 148,
          type: 6,
          name: "Iş jaýy",
          slug: "is-jayy",
          status: 1,
          created_at: "2019-12-14 03:50:01",
          updated_at: "2019-12-14 03:50:01",
          pivot: {
            karende_yer_id: 38,
            address_content_id: 148
          }
        }
      ]
    },
    {
      id: 39,
      user_id: 32,
      operator_id: 32,
      edara_id: 6,
      etrap_id: 8,
      karendeche_id: 41,
      gaty: 137,
      uzatmak: 0,
      note: null,
      status: 1,
      shertnamanyn_bahasy: 262.8,
      kone_shertnamanyn_bahasy: null,
      wagt_shertnamanyn_bahasy: null,
      shertnamanyn_konelme: 10.58,
      kone_shertnamanyn_konelme: null,
      wagt_shertnamanyn_konelme: null,
      karende_meydany: 131.4,
      kone_karende_meydany: null,
      wagt_karende_meydany: null,
      created_at: "2019-12-26 15:43:43",
      updated_at: "2019-12-26 15:43:43",
      yatyrylan_senesi: null,
      address: {
        id: 41,
        karendeche_id: null,
        karende_yer_id: 39,
        state_id: 1,
        welayat: null,
        shaher: null,
        etrap: "8",
        etrapcha: "287",
        geneshlik: null,
        oba: null,
        gechelge: null,
        koche: null,
        korpus: null,
        girelge: null,
        jay: "44",
        otag: null,
        created_at: "2019-12-26 15:43:43",
        updated_at: "2019-12-26 15:43:43"
      },
      ulan_mak: [
        {
          id: 32,
          type: 6,
          name: "Dükan",
          slug: "dukan",
          status: 1,
          created_at: "2019-11-02 08:08:18",
          updated_at: "2019-12-11 02:08:31",
          pivot: {
            karende_yer_id: 39,
            address_content_id: 32
          }
        },
        {
          id: 148,
          type: 6,
          name: "Iş jaýy",
          slug: "is-jayy",
          status: 1,
          created_at: "2019-12-14 03:50:01",
          updated_at: "2019-12-14 03:50:01",
          pivot: {
            karende_yer_id: 39,
            address_content_id: 148
          }
        }
      ]
    }
  ],
    payments: [
      {
        id: 1,
        karendechi_id: 41,
        toleg: 30000,
        wagt: 1583348400,
        kwitansiya: "KJ343353M",
        bellik: "Gijirak girizdim",
        created_at: "2020-03-26 14:42:07",
        updated_at: "2020-03-26 14:42:07"
      },
      {
      id: 2,
      karendechi_id: 41,
      toleg: 10000,
      wagt: 1585681200,
      kwitansiya: "JN343L",
      bellik: "dfgkmdfgkd",
      created_at: "2020-04-01 22:28:47",
      updated_at: "2020-04-01 22:28:47"
      }
    ]
  }
]

And I want to filter by

$collection->karende_yer->address->etrapcha == 380

My code:

$contracts = $contracts->map(function ($contract) {
	$contract->karende_yer = collect($contract->karende_yer)->filter(function ($yer) {
                    return $yer->address->etrapcha == 380;
        })->all();
        return $contract;
});

But it is not filtering. It is returning the same data without a filter.