jj.dcruz 0 Junior Poster

Hi there been having this problem for a while now and i need guidance the only thing that is showing me only 111 when looping through i have 3 data in my database and its not showing me the result i want any ideas?? thanks in advance

edit
the result would be 1 2 3 not 1 1 1

$cruds = DB::table('cruds')->where('id', $id)->get();
        $user_name = $request->Division;
        $users = DB::table('users')->where('division' ,$user_name)->get();

foreach($users as $key){
    foreach($cruds as $cey => $name){

        $user_id = $key->id;
        $cruds_id = $key->id;
        $cruds_owner = $cey->document_owner;
        $cruds_division = $key->division;
        $cruds_document = $cey->document;
        $cruds_year_release = $cey->year_release;
        $cruds_sharetoken = $cey->sharetoken;
        $cruds_privacy = $cey->privacy;
        $cruds_item_code = $cey->item_code;
        $cruds_file = $cey->file;
        $cruds_created_at = $cey->created_at;
        $cruds_updated_at = $cey->updated_at;

       if(Auth::id() == $user_id){
            echo "don't insert my id <br>";
            continue;

       }else{  

                echo $cey->user_id;
                echo $cey->document_owner;
                echo "<hr>";

                if($cey->user_id <>  $cey->document_owner ){
                    $result=DB::table('cruds')->insert([

                    'division'         => $cruds_division, 
                    'document'         => $cruds_document,
                    'year_release'     => $cruds_year_release,
                    'item_code'        => $cruds_item_code,
                    'file'             => $cruds_file,
                    'user_id'          => $user_id,     //share to this user
                    'sharetoken'       => $cruds_sharetoken,
                    'privacy'          => $cruds_privacy,
                    'document_owner'   => $cruds_owner,   //user who owns the file
                    'created_at'       => $cruds_created_at,
                    'updated_at'       => $cruds_updated_at

                    ]);
                    continue;

                }else{
                    echo "<hr>not insert";
                } 
            }
    }       
}