Kareimovich

Kareimovich

Member Since 1 Year Ago

Caito

Web Developer at Egypt

Experience Points 6,590
Experience Level 2

3,410 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 18
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

13 Apr
2 months ago

Kareimovich started a new conversation Add Input Helpers

i have task-variations that have tables

        +---------------------------+
        |task-variations|
        +------------------+
        |      id           |
        |  task_id      |
        |  variant      |
        |   option      |
        +-----------------+

i have some options in variant like

programming Code 
Description
image
links 
list Array

So How Could i define options so i could return all of theme in right way should i create Controller For each one and i need to do it outside my blade to keep it clean any ideas ?

05 Mar
3 months ago

Kareimovich started a new conversation Reset Password Using 6 Or 8 Digits Of Code Instead Of Reset Link

Hi, Everybody, I need to reset the password using code instead of the reset link So When The User Enter His Mail he receives the code by email and after adding the code He Can Change password he will just add The Password and the passowrd_conformation Any Help.

18 Feb
4 months ago

Kareimovich started a new conversation Add Custom Ace Theme To Laravel Voyager

Hi everyone in My Voyager.php in config i added

'additional_js' => [ //'js/custom.js', 'js/theme-dracula.js', 'js/mode-php.js', ], and in voyager admin panel table bread i added

      {
           "theme": "dracula",
           "language": "php"
   }

so i get this errors in database

            theme-dracula.js:1 Uncaught ReferenceError: define is not defined
            at theme-dracula.js:1

            mode-php.js:1 Uncaught ReferenceError: define is not defined
            at mode-php.js:1

            GET http://127.0.0.1:8000/admin/posts/theme-racula.js net::ERR_ABORTED 404 (Not Found)

            GET http://127.0.0.1:8000/admin/posts/mode-php.js net::ERR_ABORTED 404 (Not Found) 
            Some ScreenShots For the error

http://prntscr.com/mmmrvx

16 Feb
4 months ago

Kareimovich started a new conversation Online Users In Larravel

Hi everyone I'm trying to make the user status like (ONline, Offline, Away) any idea How I'm going to do that and what is different between Socket.io and Pusher and what is the idea for Away Status so any tutorials or example would be very helpful.

09 Feb
4 months ago

Kareimovich left a reply on Laravel Vue Validation

@bobbybouwmann the problem is in the create and i'm not the one how write this vue but this is what i can understand please help

  Newnews: {},

createnews() { this.loading = true; let news = this.Newnews; let formData = new FormData();

  formData.append("name", news.name);
  formData.append("place", news.place);
  formData.append("date", news.date);
    news.img && news.img.name
    ? formData.append("img", news.img, news.img.name)
    : "";


  axios
    .post("api/news", formData)
    .then(resp => {
      this.onSuccess(resp.data.message);
      this.updateTable();
    })
    .catch(error => {
      this.errors.record(error.response.data.data);
      this.loading = false;
    });
  this.loading = false;
},

Kareimovich left a reply on Laravel Vue Validation

@bobbybouwmann Here is a screenShot For name in Vue hope it be helpful http://prntscr.com/miwxo4

Kareimovich started a new conversation Laravel Vue Validation

Hi everyone I have My validator here and in my form when I let the name field empty I don't get required error

           $validator = Validator::make($request->all(), [
                'name' => 'required',
              ]);

    if ($validator->fails()) {
        return $this->sendError('error validation', $validator->errors());
    }

i just get it when i change

        'name' => 'required',

To

        'name' => 'required|10',

Note i tried

        'name' => 'required|max:8',

when the field is empty and i get this error

    The name may not be greater than 8 characters.
26 Jan
4 months ago

Kareimovich started a new conversation Laravel Image Url Not Redirecting To Home Page

Hi everybody in my laravel project the url of any image like http://kemakon-app.com/storage/images/Screenshot_10.png is redirected to homepage storage link but still getting the error any idea why

24 Jan
5 months ago

Kareimovich started a new conversation Return Product Column From Database With Exploded Column

Hi everyone in my Products table i have product_properties that should return as an array with other columns I could do

$Product = Product::find(33); $properties = explode(",", ($Product ->product_properties));

but I will get product_properties as an array but will not return other product columns https://prnt.sc/mbp3tk all that i need is to return product_properties as an array with other columns like in image https://prnt.sc/mbp2yh but in image, product_properties is not an array

23 Dec
6 months ago

Kareimovich started a new conversation Laravel Socialite Save Avatar

everybody, I need to Save image name in the avatar column in the database and save the image in public/Storage/users My Code Here Save image link in the database any help, please.

public function handleProviderCallback($service)

{ $user = Socialite::driver($service)->user(); $FindUser = User::where('email',$user->getEmail())->first(); if($FindUser){ Auth::login($FindUser); } else{ $NewUser = new User; $NewUser->email = $user->getEmail(); $NewUser->name = $user->getName(); $NewUser->avatar = $user->getAvatar(); $NewUser->password = bcrypt(123456); $NewUser->save(); Auth::login($NewUser); } return redirect('/'); }

14 Dec
6 months ago

Kareimovich 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
6 months ago

Kareimovich 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
6 months ago

Kareimovich 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
6 months ago

Kareimovich 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
6 months ago

Kareimovich 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
6 months ago

Kareimovich 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
6 months ago

Kareimovich 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
6 months ago

Kareimovich 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);

Kareimovich 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();

Kareimovich 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?

Kareimovich 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
7 months ago

Kareimovich 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

Kareimovich 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>

Kareimovich 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
7 months ago

Kareimovich 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
7 months ago

Kareimovich left a reply on Get Array From Foreach

oops i forget to add

    @php
        $ATask = [];
             @endphp

before foreach

Kareimovich 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
7 months ago

Kareimovich 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
7 months ago

Kareimovich 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

Kareimovich 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

Kareimovich 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
8 months ago

Kareimovich 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

Kareimovich 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
8 months ago

Kareimovich left a reply on Trying To Get Specific Data

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

Kareimovich left a reply on Trying To Get Specific Data

@Snapey yes did not return anything

Kareimovich 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();

Kareimovich 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

Kareimovich 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

Kareimovich left a reply on Trying To Get Specific Data

@Snapey yes you are right

Kareimovich 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

Kareimovich 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

Kareimovich 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

Kareimovich 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
8 months ago

Kareimovich 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();

Kareimovich 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();


        
    

Kareimovich 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();