DivPro

DivPro

at Egypt

Hire Me

Member Since 9 Months Ago

Experience Points 4,970
Experience
Level
Lessons Completed 6
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

14 Dec
2 days ago

DivPro started a new conversation How To Count Two Array In Foreach Loop

Hi everybody here I have 2 paths so I return 2 arrays of tasks I need to count each array So in last I get

[6, 4]

  @foreach ($Submpaths as $path)
     @foreach ($path->pathtags as $Tag)

            @php
                         $a=array();
                    @endphp 
             @foreach ($Tag->Tasks as $Task)  

                     @if (!in_array($Task->id,$a))
    
            <li class="list-group-item"> Task : {{ $Task->task_name }}  </li>

                 @php
                 array_push($a,$Task->id);
            @endphp
           
           @endif
              @endforeach
               @endforeach
               @endforeach
               @endforeach
08 Dec
1 week ago

DivPro started a new conversation Laravel For Loop Not Working In Nested Function

Hi Everyone I have Multi-Array AllPathsTasgs[] that has 2 path tags That has in the example

  [
 [
 "php",
 "HTML5",
 "CSS3",
"XML"
],
 [
"HTML5",
"CSS3",
"JavaScript",
 "Bootstrab"
]
 ]

I'm Trying to get to Tasks that have tags like path tags using the line below

           $query->whereNotIn('name', $AllPathsTasgs[$x]);

and is working fine with first path but it use first array in every path that means

the first path should be like $query->whereNotIn('name', $AllPathsTasgs[$x]); and x here = 0 and this is ok but the problem is in next path $query->whereNotIn('name', $AllPathsTasgs[$x]); x = 0 not 1

don't know why this happens

foreach ($paths as $path){
        $AllPathsTasgs[]  = $path->pathtags->pluck('name');
    }
        $posts3 = Path::with(['ProgrammingField','pathtags' => function ($q) use ($AllPathsTasgs,$pathsTags) {
            $q->with(['Tasks' => function ($q) use ($AllPathsTasgs,$pathsTags)  {
            $q->has('tasktags', '=', 2)
            ->orderBy('id', 'ASC')
            ->whereDoesntHave('tasktags', function ($query) use ($AllPathsTasgs,$pathsTags) {
                for ($x = 0; $x < count($pathsTags); $x++) {
                       $query->whereNotIn('name', $AllPathsTasgs[$x]);
                }
                    
            })->with('tasktags')->orderBy('id', 'ASC');
            
        }]);
       }])->whereIn('id',$pathId)->get();
07 Dec
1 week ago

DivPro started a new conversation Return Tasks With Same Tags As Path

Hi Everyone I have made for loop so I can compare every path tasktags to AllPathsTasgs So I can return only tasks that have same tags like the path tags but it returns tasks that have tags in all path tags any help, please

foreach ($paths as $path){ $AllPathsTasgs [] = $path->pathtags->pluck('name'); }

        $posts3 = Path::with(['ProgrammingField','pathtags' => function ($q) use         
          ($AllPathsTasgs)
         {$q->with(['Tasks' => function ($q) use ($AllPathsTasgs)
             {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC')
           ->whereDoesntHave('tasktags',
           
           function ($query) use ($AllPathsTasgs) {
            for ($x = 0; $x < count($AllPathsTasgs); $x++) {
                $query->whereNotIn('name', $AllPathsTasgs[$x]);

            }
           
           }
       )
               ->with('tasktags')->orderBy('id', 'ASC');
                   }]);
            }])
        ->whereIn('id', $pathId)->get();
06 Dec
1 week ago

DivPro left a reply on Laravel Pluck An Array From Nested Relationship

@michapietsch I'm not looking one specific path, I'm looking for all path where path id is in $pathId if I'm looking for one path I will use

        $path = Path::with('pathtags')->where('id', '=', $Path->id)->first();
            $TagArray = $path->pathtags()->pluck('name')->toArray();

 $Task = Enrollee::
    with('path.ProgrammingField')

    ->with(['path.pathtags' => function ($q) use ($TagArray,$category)
    {
        $q->with(['Tasks' => function ($q) use ($TagArray)
          {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC')
        ->whereDoesntHave('tasktags',
                    function ($query) use ($TagArray) {
                        $query->whereNotIn('name', $TagArray);
                    }
                )
           ->with('tasktags')->orderBy('id', 'DESC');
       }]);
   }])

    ->where( 'user_id' , '=' , Auth::user()->id )
    ->where('Path_id', $Path->id)->get();

but I'm looking for all submitted Tasks

I tried

   $user = User::where('id' ,$user->id)->with('paths.pathtags')->first();
    $pathId = $user->paths->pluck('id');
    $paths = Path::with('pathtags')->whereIn('id',  $pathId)->get();


    foreach ($paths as $path){
        $AllPathsTasgs [] = $path->pathtags->pluck('name');
    }

but Stopped and don't have any idea how to continue please help

02 Dec
2 weeks ago

DivPro left a reply on Laravel Pluck An Array From Nested Relationship

Hi @michapietsch you did get it but you didn't understand what i want to do with it i need To Add Path tags Here :

     $query->whereNotIn('name', Path Tags Array );

So I could Compare every task tags with its path tags

I can't use it like this

       $Paths= Path::with(['ProgrammingField','pathtags' => function ($q) 
       {$q->with(['Tasks' => function ($q) 
       {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC')
       ->whereDoesntHave('tasktags',
         function ($query)  {
       $query->whereNotIn('name', $path->pathtags()->pluck('name')->toArray();
    );
            }
           )
                ->with('tasktags')->orderBy('id', 'DESC');
          }]);
              }])
              ->whereIn('id', $pathId)->get();

I Hope you get what I mean and thanks So Much for your Time

01 Dec
2 weeks ago

DivPro left a reply on Laravel Pluck An Array From Nested Relationship

@michapietsch yes you get it Now What Should I Do To add Path Tags and replace it with

    whereNotIn('name', ['XML','PHP','CSS3']);

So How I add every path tags into an array

$PathTags [] = Pathtags->pluck(name); whereNotIn('name', $PathTags );

30 Nov
2 weeks ago

DivPro left a reply on Laravel Pluck An Array From Nested Relationship

@michapietsch yes Paths have tags that have tasks that have tags So Every Path Has Many Tags and every Tag has many Tasks and every Task Has Many Tags

I need to Get Tasks where All Task Tags is in Path Tags So I Need To Replace ['XML','PHP','CSS3'] With current Path Tags= (pathtags->name ) $query->whereNotIn('name', ['XML','PHP','CSS3']);

27 Nov
2 weeks ago

DivPro started a new conversation Laravel Pluck An Array From Nested Relationship

I need to get pathtags and add it to a variable so I can replace it with ['XML','PHP','CSS3'].

   $Paths= Path::with(['ProgrammingField','pathtags' => function ($q) 
   {$q->with(['Tasks' => function ($q) 
   {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC')
   ->whereDoesntHave('tasktags',
     function ($query)  {
   $query->whereNotIn('name', ['XML','PHP','CSS3']);
        }
       )
            ->with('tasktags')->orderBy('id', 'DESC');
      }]);
          }])
          ->whereIn('id', $pathId)->get();

Tried

      $query->whereNotIn('name', $q->pathtags);

DivPro started a new conversation Need To Get Path Tags From Nested Relationship

Hi, everybody, I need to get pathtags and add it to a variable so I can replace it with

['XML','PHP','CSS3']

$Paths= Path::with(['ProgrammingField','pathtags' => function ($q) {$q->with(['Tasks' => function ($q) {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC') ->whereDoesntHave('tasktags', function ($query) { $query->whereNotIn('name', ['XML','PHP','CSS3']); } ) ->with('tasktags')->orderBy('id', 'DESC'); }]); }]) ->whereIn('id', $pathId)->get();

DivPro left a reply on Get Multi Path With Tasks Relation Instead Of 1 Path

The problem is Tag array should have tags for each path but she has all paths tags and every path is compared with it What Should I Do?

DivPro started a new conversation Get Multi Path With Tasks Relation Instead Of 1 Path

Hi Everybody This is My Controller it returns Path with tasks where Path is in URL and returns tasks only where Task Tags is in Path Tags

    $path = Path::with('pathtags')->where('id', '=', $Path->id)->first();
    $TagArray = $path->pathtags()->pluck('name')->toArray();

      $Path= Enrollee::
           with('path.ProgrammingField')

         ->with(['path.pathtags' => function ($q) use ($TagArray)
      {
                   $q->with(['Tasks' => function ($q) use ($TagArray)
             {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC')
               ->whereDoesntHave('tasktags',
                function ($query) use ($TagArray) {
                    $query->whereNotIn('name', $TagArray);
                }
            )
       ->with('tasktags');
        }]
          )->orderBy('id', 'ASC');
           }])

         ->where( 'user_id' , '=' , Auth::user()->id )
         ->where('Path_id', $Path->id) ->get();

Now I tried To get All User Enroller Paths Using

    $user = User::where('id' ,$user->id)->with('paths.pathtags')->first();
    $pathId = $user->paths->pluck('id');
    $paths = Path::with('pathtags')->whereIn('id',  $pathId)->get();


        foreach ($paths as $path){
            $AllPathsTasgs [] = $path->pathtags->pluck('name');
        } 


  $TagArray = $AllPathsTasgs;
        $posts3 = Path::with(['ProgrammingField','pathtags' => function ($q) use ($TagArray)
        {$q->with(['Tasks' => function ($q) use ($TagArray)
           {$q->has('tasktags', '=', 2)->orderBy('id', 'ASC')
           ->whereDoesntHave('tasktags',
           function ($query) use ($TagArray) {
               $query->whereNotIn('name', $TagArray);
           }
       )
               ->with('tasktags')->orderBy('id', 'DESC');
           }]);
       }])
       ->whereIn('id', $pathId)->get();

but Not Working Any ideas

16 Nov
1 month ago

DivPro left a reply on Need To Get Next Task After The One In The URL

was my bad thanks so much your code work fine

DivPro started a new conversation Redirect To NextTask Page After Submitting Form

I Want My Form to redirect To $NExtTask after user submit Task I tried it without the controller but it goes to the URL but not loading the site and using control getting the wrong URL any ideas?

My Controller

public function subPost(ProgrammingField $category, Path $Path,Task $task){

    $enrollee = Enrollee::where('path_id',1)->where('user_id',Auth::user()->id)->first();

    Enrollee::where('path_id',1 )->where('user_id',Auth::user()->id )->update([
        'user_id'  => auth()->user()->id,
        'task_id'  => $enrollee->task_id.','.request('Task_id')
    ]);

return redirect( 'category/'.'.$Tasks->ProgrammingField->slug.'/'.$Tasks->slug.'/'.Request::segment(4).'/'.$NextTask  ');

}

My Route

     Route::get('category/{category}/{path}/mid-senior/{task}', '[email protected]');

     Route::post('category/{category}/{path}/mid-senior/{task}', '[email protected]');

My Form

   <form method="POST"
  action="{{ url('category/'.$Tasks->ProgrammingField->slug.'/'.$Tasks->slug.'/'.Request::segment(4).'/'.$NextTask ) }}">
    @csrf

    <div class="form-group">
            <input  type="hidden" class="form-control"  name="Task_id" value="{{$itask->id}}">
            <input  type="hidden" class="form-control"  name="Next_id" value="{{$NextTask}}">

        </div>
 <button type="submit" class="btn btn-success">Submit & Continue</button>

</form>

DivPro left a reply on Need To Get Next Task After The One In The URL

get an empty result from

@if ($loop->remaining)

Next Task is: {{ $Tasks[$loop->iteration]->task_name }}

@endif

15 Nov
1 month ago

DivPro started a new conversation Need To Get Next Task After The One In The URL

this for each gave me task where task slug is the same as URL now I need to get the first task after this one so I make redirect link later

@foreach ($Tasks as $Task)
 @if (  $Task->slug == Request::segment(5) )
            <h2> {{ $Task->task_name }} </h2>
  @endif
@endforeach

I need to get the task how is after the one in URL from foreach

12 Nov
1 month ago

DivPro left a reply on Get Array From Foreach

oops i forget to add

    @php
        $ATask = [];
             @endphp

before foreach

DivPro started a new conversation Get Array From Foreach

Hi, everybody, I have foreach

@foreach ($Tag->Tasks as $Task)

@if (!in_array($Task->id,$a))
    @if ($Task->slug == Request::segment(5) )

    @php
    $ATask[] = $Task;
@endphp

          <a href="{{ url('category/'.$item->ProgrammingField->slug.'/'.$item- 
     >slug.'/'.Request::segment(4).'/'.$Task->slug ) }}" style="text-decoration: none">
           <li class="list-group-item active" > Task NOn :: {{ $Task->task_name }}   ++  {{ $Task->id 
       }}
           </li></a>

 @else
 <a href="{{ url('category/'.$item->ProgrammingField->slug.'/'.$item->slug.'/'.Request::segment(4).'/'.$Task->slug ) }}" style="text-decoration: none">
    <li class="list-group-item" > Task NOn :: {{ $Task->task_name }}   ++  {{ $Task->id }}
     </li></a>

 @endif

     @php
        array_push($a,$Task->id);
     @endphp

     @endif

    @endforeach

When I use

{{ $ATask }}

i get Undefined variable:

27 Oct
1 month ago

DivPro started a new conversation Prevent Foreach To Return Duplicated Tasks

hi, everybody, I'm trying to Prevent To return duplicated Tasks in relation

A Path has many Tags, every Tag has Many Tasks, every Task has many tags

My Code Prevent to return duplicated Tasks in Tag but I need to Prevent Duplicated Tasks in All Tasks of Path

My Controller

    $Paths = Path::with(['pathtags' => function ($q) use ($TagArray)
     {$q->with(['Tasks' => function ($q) use ($TagArray) {$q->has('tasktags', '=', 2)
            ->with('tasktags');
        }]);
    }])->where('id', '=', 1)->get();

My Blade

  @foreach ($Paths as $Path)
      <h2> {{$Path->name}}</h2>
      @foreach ($item->pathtags as $Tag)

        @php $a=array(); @endphp 
            @foreach ($Tag->Tasks as $Task)
               @if (!in_array($Task->task_name,$a))
                  <li> Task :: {{ $Task->task_name }} </li>
                 @php
                    array_push($a,$Task->task_name);
                @endphp
               @else 
       <li> Task :: Duplicated </li>
      @endif 

@foreach ($a as $item)
   <li>Array Task :::  {{$item}}</li>
@endforeach

   
 @endforeach 
    @endforeach 
        @endforeach

ScreenShot For Ouput of blade

25 Oct
1 month ago

DivPro left a reply on Removing Duplicates From My Relations

@lostdreamer_nl

'm getting the same result here

 @php($tasks = collect())

@foreach ($Tag->Tasks as $Task)
  <?php
  if($tasks->has($Task->id)) continue;
  $tasks->put($Task->id, $Task);
  ?>        
    
<li> Task :: {{ $Task->task_name }} </li>
@foreach ($Task->tasktags as $TaskTag)
<li> Task Tags :: {{ $TaskTag->name }} </li>

@endforeach
@endforeach

DivPro left a reply on Removing Duplicates From My Relations

@lostdreamer_nl No because of every tag in example PHP , css

May have the same Task so i will get it twice

DivPro started a new conversation Removing Duplicates From My Relations

i have relation tags that nave many tasks every tag have some tasks i need to return un duplicated Tasks values

My Controller

    $Tasks= Path::with(['pathtags' => function ($q) use ($TagArray)
     {$q->with(['Tasks' => function ($q) use ($TagArray) {$q->has('tasktags', '=', 2)
            ->with('tasktags');
        }]);
    }])->where('id', '=', 1)->get();

My Blade

     @foreach ($posts2 as $item)
              <h2> {{$item->name}}</h2>

     @foreach ($item->pathtags as $Tag)
           <li> Path Tag :: {{ $Tag->name }} </li>

   @foreach ($Tag->Tasks as $Task)          
          <li> Task :: {{ $Task->task_name }} </li>

   @foreach ($Task->tasktags as $TaskTag)
         <li> Task Tags :: {{ $TaskTag->name }} </li>

@endforeach
@endforeach   
@endforeach

@endforeach

23 Oct
1 month ago

DivPro started a new conversation Laravel View Return Different Data From Controller

Hi everybody, My code here is returning tasks that have more than 1 Tag and the code is working fine until I pass it to view it returns all tasks even tasks that have one tag My Code

My Controller :

$posts = Path::with(['pathtags' => function ($q)  {
        $q->with(['Tasks'=>function($q){
         $q->has('tasktags', '=' , 2)->with('tasktags');
          }]);
        }])
->where('id','>',1)->get();

My View : return view ('task',compact('posts'));

@foreach ($posts as $Task)
<h2>{{ $Task->name }}</h2>

@foreach ($Task->pathtags as $Tag)
<h3>{{ $Tag->name }}</h3>

@foreach ($Tag->tasks as $Ta)
<h2>{{ $Ta->task_name }}</h2>

@endforeach

@endforeach
@endforeach

DivPro started a new conversation Return View Is Returning Different Data

Hi, everybody, My code here is returning tasks that have more than 1 Tag and task tags are in $TagArray everything is working good in

   return $TaskData;

but When I pass TaskData into view I get different results even get Tasks with one tag

        return view ('task',compact('TaskData'));

My Code

$TaskData= Path::with(['pathtags' => function ($q) use ($TagArray) {
$q->with(['Tasks'=>function($q) use ($TagArray) { 
    $q->has('tasktags', '=' , 2)->whereDoesntHave ('tasktags', function ($query) use     
     ($TagArray) {
            $query->whereNotIn('name',$TagArray);

        })->with('tasktags');
    }]);
}])->first();
21 Oct
1 month ago

DivPro left a reply on Trying To Get Specific Data

@Snapey Nop and I'm going crazy because of it Can you use team viewr

DivPro left a reply on Trying To Get Specific Data

@Snapey yes did not return anything

DivPro left a reply on Trying To Get Specific Data

@Snapey like My Example here

$posts2 = Path::with(['pathtags' => function ($q) use ($TagArray) {
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '>' , 1)->whereHas('tasktags', function ($query) use ($TagArray) {
                $query->where(array_diff('name', $TagArray ,'==', flase),$tag);
            
        })->with('tasktags');
    }]);
}])->first();

DivPro left a reply on Trying To Get Specific Data

@Snapey you misunderstand me all What i want to continue my old code Can do other

$posts2 = Path::with(['pathtags' => function ($q) use ($TagArray) {
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '>' , 1);

            
        $q->whereHas('tasktags', function ($query) use ($TagArray) {
                
            $query->whereIn('name',$TagArray)->where();
            
            
        })->with('tasktags');
    }]);
}])->first();

need to find way to get tasks where all name of tasktags is in $TagArray

can you gave me your facebook or whatsapp

DivPro left a reply on Trying To Get Specific Data

@Snapey Thanks a lot Can you please remove

$tquery = Task::newQuery();

i can't use it

DivPro left a reply on Trying To Get Specific Data

@Snapey yes you are right

DivPro left a reply on Trying To Get Specific Data

@Snapey

  • tasktags belongs to many task
  • $TagArray is array contain many tags

I need to get tasks where all task tasktags is in $TagArray

and I tried

                  $query->whereIn('name',$TagArray);

but it return if one of tasktags is in $TagArray and

         foreach($TagArray as $tag){
                      $query->where('name',$tag);
            }

Not Returning anything

DivPro left a reply on Trying To Get Specific Data

@Snapey Sorry but

$posts2 = Path::with(['pathtags' => function ($q) use ($TagArray) {
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '>' , 1)->whereHas('tasktags', function ($query) use ($TagArray) {
            foreach($TagArray as $tag){
                $query->where('name',$TagArray);
            }
        })->with('tasktags');
    }]);
}])->first();

did't Work

DivPro started a new conversation Trying To Get Specific Data

I'm trying to get Tasks where All tasktags name is in $TagArray

$posts2 = Path::with(['pathtags' => function ($q) use ($TagArray) {
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '>' , 1)->whereHas('tasktags', function ($query) use ($TagArray) {
                $query->whereIn('name',$TagArray);
         
        })->with('tasktags');
    }]);
}])->first();

but instead, I get tasks where 1 of tasktags Name is in array I want to get task if only all tasktags name in $TagArray

DivPro left a reply on Can Not Get Data With Right Tags

@Snapey

$posts2 = Path::with(['pathtags' => function ($q) use ($TagArray) {
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '>' , 1)->whereHas('tasktags', function ($query) use ($TagArray) {
            foreach($TagArray as $tag){
                $query->where('name', $tag);
            }
        })->with('tasktags');
    }]);
}])->first();

Not Returning antything

20 Oct
1 month ago

DivPro started a new conversation Can Not Get Data With Right Tags

need to get Tasks where all tasktags-> name is in $TagArray array but instead, I get tasks where one of tasktags-> name is in $TagArray I'm using

                    $query->whereIn('name', $TagArray );

but not working as wanted

 $posts2 = Path::with(['pathtags' => function ($q) use ($TagArray) {
            $q->with(['Tasks'=>function($q) use ($TagArray) { 
             $q->has('tasktags', '=' , 2)->whereHas('tasktags', function ($query) use ($TagArray) {
                    $query->whereIn('name', $TagArray );
        })->with('tasktags');
    }]);
}])->first();

DivPro started a new conversation Retrieve Only Identical Array

Hi, everybody, I need to get tasks that all tasktags names is in $TagArray but instead if one is in an array it gets I need to get id if all name is in $TagArray

$posts2 = Path::with(['pathtags' => function ($q) use ($TagArray) {
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '=' , 2)->whereHas('tasktags', function ($query) use ($TagArray) {
            $query->whereIn('name' , $TagArray );
        })->with('tasktags');
    }]);
}])->first();


        
    

DivPro left a reply on Query Function Error

$posts2 = Path::with(['pathtags' => function ($q) use ($TagArray) { $q->with(['Tasks'=>function($q) use ($TagArray) { $q->has('tasktags', '=' , 2)->whereHas('tasktags', function ($query) use ($TagArray) { $query->whereIn('name' , $TagArray ); })->with('tasktags'); }]); }])->first();

DivPro started a new conversation Query Function Error

I'm getting this error

Undefined property: Illuminate\Database\Eloquent\Relations\BelongsToMany::$tasktags

for

$posts = Path::with(['pathtags' => function ($q) use ($TagArray) { // use $TagArray
    $q->with(['Tasks'=>function($q) use ($TagArray) {
   
        $q->has('tasktags', '=' , 2)->with('tasktags');
            $q->tasktags->whereIn('name', $TagArray)->get();

    }])->with('tasktags');
}])->first();

DivPro started a new conversation Need To Compare Relation Name To Array

Hi, Everybody, I need to get data where tasktags name is in $TagArray using wherein

    $TagsArray = Path::with('pathtags')->first();

$TagArray = [];

foreach ($TagsArray->pathtags as $tags) {
    $TagArray[] = $tags->name;
} 
    $TCompare = Path::with(['pathtags' => function ($q)  {
        $q->with(['Tasks'=>function($q){
            $q->has('tasktags', '=' , 2)->with('tasktags');
        }]);
    }])
    ->first();

I have tried $TCompare = Path::with(['pathtags' => function ($q) use ($TagArray) { $q->with(['Tasks'=>function($q) use ($TagArray) { $q->has('tasktags', '=' , 2)->whereIn('name', $TagArray)->with('tasktags'); }]); }])->first();

but I get this error

Illuminate \ Database \ QueryException (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name' in 'where clause' (SQL: select tasks., tag_task.tag_id as pivot_tag_id, tag_task.task_id as pivot_task_id from tasks inner join tag_task on tasks.id = tag_task.task_id where tag_task.tag_id in (1, 2) and (select count() from tags inner join tag_task on tags.id = tag_task.tag_id where tasks.id = tag_task.task_id) = 2 and name in (HTML5, PHP))

DivPro left a reply on Nested Query Function

@shez1983 I tried

$TCompare = Path::with(['pathtags' => function ($q) use ($TagArray) { 
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '=' , 2)->whereIn('tasktags.name', $TagArray)->with('tasktags');
    }]);
}])->first();
return  $TCompare;

but i get this error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tasktags.name' in 'where clause' (SQL: select tasks., tag_task.tag_id as pivot_tag_id, tag_task.task_id as pivot_task_id from tasks inner join tag_task on tasks.id = tag_task.task_id where tag_task.tag_id in (1, 2) and (select count() from tags inner join tag_task on tags.id = tag_task.tag_id where tasks.id = tag_task.task_id) = 2 and tasktags.name in (HTML5, PHP))

https://i.imgur.com/CF5LTXp.png

DivPro started a new conversation Nested Query Function

Hi EveryBody i'm getting this error for my code here

Call to undefined method App\Tag::tasktags()

$TCompare = Path::with(['pathtags' => function ($q) use ($TagArray) { 
    $q->with(['Tasks'=>function($q) use ($TagArray) { 
        $q->has('tasktags', '=' , 2)->with('tasktags');
        $q->with(['tasktags'=>function($q){
            $q->has('tasktags', '=' , 2)->whereIn('name', $TagArray)->with('tasktags');

        }]);
    }]);

}])->first();
return  $TCompare;

DivPro left a reply on Wherein In Query Function

@Sergiu17 now i get this error

Call to undefined relationship [tasktags] on model [App\Tag].

ScreenShot of output before wherein

https://i.imgur.com/CF5LTXp.png

DivPro left a reply on Wherein In Query Function

@Sergiu17 Thanks but Now I get Error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tasktags.name' in 'where clause' (SQL: select tasks., tag_task.tag_id as pivot_tag_id, tag_task.task_id as pivot_task_id from tasks inner join tag_task on tasks.id = tag_task.task_id where tag_task.tag_id in (1, 2) and (select count() from tags inner join tag_task on tags.id = tag_task.tag_id where tasks.id = tag_task.task_id) = 2 and tasktags.name in (HTML5, PHP))

The name is in tasktags relation What Should i Do

DivPro started a new conversation Wherein In Query Function

Hi, Everybody, I'm getting this error Undefined variable: TagArray When i write this Code

    $TagsArray = Path::with('pathtags')->first();

       foreach ($TagsArray->pathtags as $tags) {
       $TagArray[] = $tags->name;
    }

              $posts = Path::with(['pathtags' => function ($q)  {
             $q->with(['Tasks'=>function($q){
             $q->has('tasktags', '=' , 2)->whereIn('name', $TagArray)->with('tasktags');
                   }]);
          }])
             ->first();
18 Oct
1 month ago

DivPro started a new conversation Retrieve Specific Tasks From Database

Hi, Everybody, I need To retrieve Tasks That has (tasktag id > 1) But My Code returns all tasks With tasks but return the only tasktag that is id >1 i need to not return task i need not return Task and Tasktag when tasktag is <1

         $tasks = Path::with(array('pathtags.Tasks.tasktags' => function($query)
         {
             $query->where('tag_id', '=',3);
          }))
     ->first();

DivPro left a reply on SQLSTATE[42000]: Error In My Controller

@tykus no this is Relations Path->pathtags->Tasks->tasktags

DivPro left a reply on Get Tasks That Has Multi Tags

@Cruorzy i get this error

    Call to undefined method App\Path::pathtags.Tasks()

for withCount('pathtags.Tasks.tasktags')

and another error SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pathtags.Tasks.tasktags' in 'having clause' (SQL: select * from paths having pathtags.Tasks.tasktags > 1)

for having('pathtags.Tasks.tasktags','>',1)

should i tell you that pathtags.Tasks.tasktags is nested relation