Debug School

rakesh kumar
rakesh kumar

Posted on • Updated on

All Laravel,jquery and javascript Commands

how-to-send-email-in-multiple-client-in-laravel

pay_users = addcart::where('admin_id', $param3)->get();
Enter fullscreen mode Exit fullscreen mode
$influencer_adminids = $pay_users->pluck('influencer_admin_id')->toArray();
Enter fullscreen mode Exit fullscreen mode
 foreach ($influencer_email as $email) { }===> on array
Enter fullscreen mode Exit fullscreen mode
$json_encoded = json_encode($influencer_adminids->toArray());
Enter fullscreen mode Exit fullscreen mode
$decoded_array = json_decode($json_encoded, true);
Enter fullscreen mode Exit fullscreen mode
$json_encoded = json_encode($influencer_adminids);
Enter fullscreen mode Exit fullscreen mode
foreach ($influencer_adminids as $index => $adminId) {}
Enter fullscreen mode Exit fullscreen mode
@foreach(json_decode($user->json_data, true) as $key => $value)
            <li>{{ $key }}: {{ $value }}</li>
        @endforeach
Enter fullscreen mode Exit fullscreen mode
$InfluencerMailsend = [];
  $InfluencerMailsend = [
        'name' => $influencername,
        'email' => $email,
        'token' => $validToken,
    ];
Enter fullscreen mode Exit fullscreen mode
$InfluencerMailsend = array(
    'name' => $influencername,
    'email' => $email,
    'token' => $validToken,
);
Enter fullscreen mode Exit fullscreen mode
$InfluencerMailsend = [];
  $InfluencerMailsend['name'] = $influencername;
$InfluencerMailsend['email'] = $email;
$InfluencerMailsend['token'] = $validToken;
Enter fullscreen mode Exit fullscreen mode
$pay_users = collect([
    ['id' => 1, 'influencer_admin_id' => 101],
    ['id' => 2, 'influencer_admin_id' => 102],
    ['id' => 3, 'influencer_admin_id' => 103],
]);
$influencer_adminids = $pay_users->pluck('influencer_admin_id')->toArray();
Enter fullscreen mode Exit fullscreen mode

 @if ($user->json_data)
        <tr>
            <th colspan="2">JSON Data</th>
        </tr>
        @foreach(json_decode($user->json_data, true) as $key => $value)
            <tr>
                <td>{{ $key }}</td>
                <td>{{ $value }}</td>
            </tr>
        @endforeach
    @endif
Enter fullscreen mode Exit fullscreen mode
<h1>{{ $user->name }}</h1>

<p>Email: {{ $user->email }}</p>

@if ($user->json_data)
    <h2>JSON Data:</h2>
    <ul>
        @foreach(json_decode($user->json_data, true) as $key => $value)
            <li>{{ $key }}: {{ $value }}</li>
        @endforeach
    </ul>
@endif
Enter fullscreen mode Exit fullscreen mode
$currentURL = url()->current(); 
Enter fullscreen mode Exit fullscreen mode
    $id = Auth::user()->id; 
Enter fullscreen mode Exit fullscreen mode
 $users = Paytm::where('admin_id', $id)->with('otherTableData')->get();
Enter fullscreen mode Exit fullscreen mode
 <td>{{ \Illuminate\Support\Str::limit($user->created_at, 10) }}</td>
                <td>
Enter fullscreen mode Exit fullscreen mode

how-to-store-array-of-value-in-database-records-in-laravel

$Paytm->influencer_admin_id = implode(',', $influencer_adminids);
Enter fullscreen mode Exit fullscreen mode
 YourModel::create([
            'socialsite' => $jsonData,
        ]);
Enter fullscreen mode Exit fullscreen mode

how-to-get-two-table-data-using-eloquent-relationship-in-laravel

  @php
      $customIndex = 1; // Initialize the custom index variable
 @endphp
 @foreach($users as $user)
              @foreach(json_decode($user->influencer_name) as $influencer)
              @foreach ($user->otherTableData as $data) 
/// all renders data in table
 @php
  $customIndex++; // Increment the custom index
 @endphp
 @endforeach
 @endforeach

Enter fullscreen mode Exit fullscreen mode
foreach ($users as $user) {
//render nested data
if ($user->otherTableData->isNotEmpty()) {

foreach ($user->otherTableData as $data) {
// render nested field is in array
 }
    } else {
        echo "No data found in 'other_table' for this user.<br>";
    }
Enter fullscreen mode Exit fullscreen mode
      @php
          $customIndex = 1; // Initialize the custom index variable
                @endphp
              @foreach($users as $user)
              @for ($i = 0; $i < count(json_decode($user->influencer_name)); $i++)
    // display nested data is
             @php
        $customIndex++; // Increment the custom index
           @endphp         
           @endfor
           @endforeach 
Enter fullscreen mode Exit fullscreen mode

get data from multiple table

  public function otherTableData()
    {
        return $this->hasMany(addcart::class, 'admin_id', 'admin_id');
    }

    public function table2Data()
    {
        return $this->hasMany(Table2::class, 'admin_id', 'admin_id');
    }

    public function table3Data()
    {
        return $this->hasMany(Table3::class, 'admin_id', 'admin_id');
    }
Enter fullscreen mode Exit fullscreen mode

Taking alias

$users = Paytm::where('admin_id', $id)
    ->with('otherTableData', 'table2Data', 'table3Data')
    ->select(
        'payment_paytm.*',
        'addcart.column_name as other_table_column',
        'table2.column_name as table2_column',
        'table3.column_name as table3_column'
    )
    ->get();
Enter fullscreen mode Exit fullscreen mode

how-to-display-array-of-element-in-different-row-in-laravel-blade-file

how to give route in array decoded from the JSON string stored in db

 @foreach($users as $user)            
              @for ($i = 0; $i < count(json_decode($user->influencer_name)); $i++) 
<a href="{{ route('view-order', [
                    'user_id' => $user->id,
                    'influencer_name' => json_decode($user->influencer_name)[$i]
                ]) }}">{{ json_decode($user->influencer_name)[$i] }}</a>  
Enter fullscreen mode Exit fullscreen mode

inside td and inside foreach

 {{ json_decode($user->cart_id)[$i] }}
Enter fullscreen mode Exit fullscreen mode

how-the-nested-foreach-loop-is-used-to-fetch-and-display-dynamic-data

 food_type = AddFoodType.objects.all()

    category = AddFoodType.objects.filter(useraddfoodgi__isnull=False).distinct()

    context = {
        'food_type': food_type,
        'category': category,
    }
Enter fullscreen mode Exit fullscreen mode
    @foreach($food_type as $food)
// data here
  @foreach($category as $categoryItem)
    @if($categoryItem->food_type === $food->food_type)
// renders nested data
  @endif
   @endforeach
  @endforeach  
Enter fullscreen mode Exit fullscreen mode

how-to-sends-array-of-value-to-another-php-file

Top comments (0)