Member Since 2 Years Ago


Experience Points

2,430 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
Best Reply Awards
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.


    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
2,570 XP
1 month ago
Activity icon

Started a new Conversation Some Thing Like Soft Delete In Model For Returning Only Active Models

i Have product model (Belongs to products table),

and i want to tell model when i select any product you have to return the models that their Active column is True, like soft delete that just return the models that not soft deleted.

is there any way?

3 months ago
Activity icon

Started a new Conversation Have Accessors Or Some Thing Like That For Pivot Table And Return Sorted Columns As List

hi i have 3 tabel(Prodcuts Table and Sellers Table and their pivot table that is product_seller )

sellers table like below


products table like below


and product_seller table like below


its means that product can have many seller that every seller can sell product by different prices (why? because seller say if you buy 10 quantity of this product you can pay less price, 'product_quantity' is for that reason in the pivot table),

so i want to have sellers list of specific product with their prices that is sorted from lowest to highest

if product have two seller in pivot table and seller(id=1) have 3 price for it and seller(id=3) have two price for this product i need json format like below in product detail route or some thing like that. as you see in Below json i need list of pivots

in below Json format (product detail);

 "Product": {
        "id": 1,
        "name": "Dr.",
        "image": "test.jpg",
        "body": "lorem",
        "sellers": [
                "id": 1,
                "name": "Talon Mraz",
                  	  "product_id": 1,
                   	 "seller_id": 1,
                   	 "product_quantity": 16,
                    	"price": "176.0000",
                  	  "product_id": 1,
                   	 "seller_id": 1,
                   	 "product_quantity": 20,
                    	"price": "170.0000",
                  	  "product_id": 1,
                   	 "seller_id": 1,
                   	 "product_quantity": 30,
                    	"price": "160.0000",

                "id": 3,
                "name": "Talon Mraz",
                  	  "product_id": 1,
                   	 "seller_id": 3,
                   	 "product_quantity": 30,
                    	"price": "180.0000",
                  	  "product_id": 1,
                   	 "product_quantity": 40,
                    	"price": "170.0000",


i dont know i can define many to many relation for it or i have to define new model for seller_product table and new functions on it to and have sellers of product inside of product Object in Json?

if you have any point,let me know

Activity icon

Started a new Conversation Laravel Eloquent Accessors Not Working On Shared Online Host But Working In Local Host !!


i have strange problem with my code,

below Code is my Product model. i can access my Accessors in local host when i load product model but when i use shared host i cant see my product Accessors in product detail.

class Product extends Model
  protected $fillable=['price','price_unit','image_alt','lang','persian_category','english_category','title','slug','description','body','image','meta_keywords','meta_description','category_id'];
  protected $appends = ['most_cheapest_seller_name','has_pelekani','count_cart','most_cheapest_seller_id','most_cheapest_seller_price'];
   * Return the sluggable configuration array for this model.
   * @return array

      public function categories()
          return $this->belongsToMany(Category::class);
      public function gallery()
         return $this->hasMany(Gallery::class);
     public function sellers()
         return $this->belongsToMany(Seller::class)->withPivot('from_quantity','to_quantity','price','seller_name')->orderBy('price','asc');

    public function getMostCheapestSellerPriceAttribute()
        return $seller_info->price;
    public function getMostCheapestSellerNameAttribute()
        return $seller_info->seller_name;
    public function getMostCheapestSellerIdAttribute()
        return $seller_info->seller_id;
    public function getHasPelekaniAttribute(){

        //$has_pelekani=DB::raw('count(*) as user_count, status')->get();
        $has_pelekani = DB::table('product_seller')
            ->select(DB::raw('seller_id, COUNT(seller_id)'))
            ->where('product_id'  ,$this->id)
            ->havingRaw('COUNT(seller_id) > 1')
        if (count($has_pelekani)==0){
            return false;
            return true;
    public function getCountCartAttribute(){
          return 2;


if you have any point, please let me know.

3 months ago
Activity icon

Replied to Show Products Of Categories Of A User

Thank you so much,

Activity icon

Replied to Show Products Of Categories Of A User

hi there

i tried but i got below error

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous (SQL: select * from `products` where exists (select * from `categories` inner join `category_product` on `categories`.`id` = `category_product`.`category_id` where `products`.`id` = `category_product`.`product_id` and `id` in (5, 1, 4, 2, 5)))

i thought i need to change id in below line of your code to product_id, so i changed $query->whereIn('id', $user->categories->pluck('id')); to $query->whereIn('product_id', $user->categories->pluck('id'));

but result products was wrong.

do you have any idea?

3 months ago
Activity icon

Started a new Conversation Show Products Of Categories Of A User

hi i want to find all products that belongs to categories of logged in user.

user have ManyToMany relationship with category and category have ManyToMany relationship with product that's it, why i have this relationships? user can buy products that belongs to specific categories (like Cosmetics products) and i wanna show user products of the categories that he can buy, i have below migrations in category migration

Schema::create('categories', function (Blueprint $table) {

        Schema::create('category_user', function (Blueprint $table) {
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('NO ACTION');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('NO ACTION');

        Schema::create('category_product', function (Blueprint $table) {
            $table->foreign('category_id')->references('id')->on('categories')->onDelete('NO ACTION');
            $table->foreign('product_id')->references('id')->on('products')->onDelete('NO ACTION');

and product table have below columns


and user table have below columns


if you need more info or have any question please let me know,

i found below thread but its relations is not like mine

this link:

4 months ago
Activity icon

Replied to Returned Variable From Function Is Undefined Sometimes

@snapey thank you it works by replacing $this->between_dates = [];

but still i cant understand why it worked and why i had problem. for example i have two product (room) both of them have reservations. and one of them works fine for returning $this->between_dates and other one throw an error. its so weird.

5 months ago
Activity icon

Started a new Conversation Returned Variable From Function Is Undefined Sometimes


i have below code in my class for finding dates between two date of a room that called product in my DB

class FrontController extends Controller

    private $between_dates=Array();

  public function unit_single($slug){

        if (!$product){
        //find selected dates of selected product
        foreach ($product->reservations as $orders) {
            //get all days beetween two days and join returned array to existed function==
            $selected_dates=array_merge($selected_dates, $this->get_dates($orders->check_in,$orders->check_out));
        $all_dates = array_unique($selected_dates);



private function get_dates($check_in,$check_out) {
        //start date should be before end date otherwise the Carbon will throw a null
        $period = CarbonPeriod::create($check_in,$check_out);
        foreach ($period as $date) {
        //var dump data for watch its exist or not

      //Error Happen in below code and says 
        return $this->between_dates ;


some times it says undefined property when i want to return $this->between_dates from 'get_dates' function. but every time i check $this->between_dates by dd( $this->between_dates); there is exist array of dates but some times function return it and some times not and say you have problem in this line of code.

Undefined property: App\Http\Controllers\Website\FrontController::$between_dates

For EXMAPLE: for one product that $this->between_dates from 'get_dates' have below array every things works fine

array:13 [▼
  0 => "2020-01-01"
  1 => "2020-01-02"
  2 => "2020-01-03"
  3 => "2020-01-04"
  4 => "2020-01-05"
  5 => "2020-01-06"
  6 => "2020-01-07"
  7 => "2020-01-08"
  8 => "2020-01-09"
  9 => "2020-01-10"
  10 => "2020-01-11"
  11 => "2020-01-12"
  12 => "2020-01-13"

but for another product (room) that i have below dates as reserved date, Laravel will throw an error

array:10 [▼
  0 => "2020-01-21"
  1 => "2020-01-22"
  2 => "2020-01-23"
  3 => "2020-01-24"
  4 => "2020-01-25"
  5 => "2020-01-26"
  6 => "2020-01-27"
  7 => "2020-01-28"
  8 => "2020-01-29"
  9 => "2020-01-30"

any one have any idea?

if you need more info please let me know.