Farshad

Farshad

Member Since 2 Years Ago

Experience Points
630
Total
Experience

4,370 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
1
Lessons
Completed
Best Reply Awards
0
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.

Level 1
630 XP
Nov
13
2 days ago
Activity icon

Started a new Conversation Remove Object With Call By References

I have two array of object like bellow

category = {
cartsDescriptions = [
{
    id: 1,
    name: 'test'
},
{
    id: 2,
    name: 'test2'
}
]
}

cartsDescriptions = [
{
    id: 1,
    name: 'test'
},
{
    id: 2,
    name: 'test2'
}

]

I'm using redux and when I want to splice id: 1 from the cartsDescriptions it remove from both cartsDescriptions and category.cartsDescriptions

How I should stop remove data from category and just remove item from cartsDescriptions

Nov
04
1 week ago
Activity icon

Awarded Best Reply on Access Base Model Data In Accessor Of An Other Model With Relation

@nakov I found the way for stop run multiple query in ProductsMedia model I just call products relation in the model

class ProductsMedia extends Model{

protected $with = ['product']
}

and it just call one query to get the all products in media

Activity icon

Replied to Access Base Model Data In Accessor Of An Other Model With Relation

@nakov I found the way for stop run multiple query in ProductsMedia model I just call products relation in the model

class ProductsMedia extends Model{

protected $with = ['product']
}

and it just call one query to get the all products in media

Activity icon

Replied to Access Base Model Data In Accessor Of An Other Model With Relation

@nakov I have two model

class Products extends Model{
    public function default_media(){
            return $this->hasOne('App\Models\ProductsMediaXref', 'products_id')
                 ->where('is_default', 1);
    }
}
class ProductsMediaXref extends Model{

public function getImageAttribute(){
    //get product name
}

     public function product()
    {
        return $this->belongsTo('App\Models\Products', 'products_id');
    }
}

I want to generate the image url in accessor and need to append product name in url for site seo the url should be cdn.test/{segment}/{media_id}/{product_name}-{key}.png

and in my controller I call

Products::with('default_media')->get()

with help of laravel-debugbar if I didn't call product relation in image accessor of ProductsMedia I got 10 query and when call the relation to access the product name I got around 22 query because when call the relation in ProductsMedia for each media call the query to fetch the product

Nov
03
1 week ago
Activity icon

Replied to Access Base Model Data In Accessor Of An Other Model With Relation

@nakov I'm accessing media in product and not reverse.

and in products call the media and in media again I call product this way has not make sence

Activity icon

Replied to Access Base Model Data In Accessor Of An Other Model With Relation

If I do this It make my query double because It call in products and in media I call product

Activity icon

Started a new Conversation Access Base Model Data In Accessor Of An Other Model With Relation

I have to simple model

class Products extends Model{
    public function media(){
        return $this->hasMany(ProductsMedia::class, 'products_id');
    }
}

class ProductsMedia extends Model{
    //
    public function getImageAttribute(){
        //access the product name
    }   
}

I need to access the products name in ProductsMedia Image accessor

and i don't want to add other relation in ProductsMedia like

class ProductsMedia extends Model{
    public function product(){
        return $this->belongsTo(Products::class,  'products_id');
    }
}

I need some solution like pivot in belongsToMany

I do this in accessor

public function getImageAttribute(){
    $this->pivot->pivotParent->name;
}

because It make double my query

Sep
10
2 months ago
Activity icon

Started a new Conversation Change Laravel Cache Key

I have to app the first is api and the second is website. I'm cacheing data on the redis and when I'm cacheing the data lumen and laravel both put one string like 'lumen:cache' at the start of cache key name

How I could change the lumen cache key that laravel append to my cache key

Aug
26
2 months ago
Activity icon

Replied to Laravel Advance Where Query Builder

I found the way to handle this like below where accept four parameter and the last one is boolean and the operator

$query->where(function($q) use($filter, $field){
        $this->applyFilter($q, $filter, $field);
}, null, null, $filter->operation);
Activity icon

Started a new Conversation Laravel Advance Where Query Builder

I have an advance where query and need to set operation for that like below but it's not working

$query->where(function($q) use($filter, $field){
        $this->applyFilter($q, $filter, $field);
}, $filter->operation);

the $filter->operation could be one of or | and how I could implement this know it just and the query

Jun
26
4 months ago
Activity icon

Replied to Config Laravel Installation On Ubuntu

at last I'm adding

alias laravel="~/.config/composer/vendor/bin/laravel"

to the .bashrc of my root home directory and it work

Activity icon

Replied to Config Laravel Installation On Ubuntu

@TYKUS - I use this at first and install laravel globally but the command laravel new blog still not working and I get this error

Activity icon

Started a new Conversation Config Laravel Installation On Ubuntu

every time I need to install laravel need to use composer create-project --prefer-dist laravel/laravel blog

but on my ubuntu system config the composer and laravel and like to do this with laravel new blog command How I should achieve that?

I'm using ubunut as OS