John Davidson

php - Undefined variable $addtailer

0 comments
Message:


List item


Controller


use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\TailerInfo;
use App\Models\AddTailer;

class ClothnaapController extends Controller
{
public function index()
{
// forgin key data code
$tailerinfo = TailerInfo::where('add_tailer_id', 'id')->get();
$addtailer = Addtailer::get();

return view('frontend.clothesnaap', compact('tailerinfo', 'addtailer'));
}
}

View


<div class="p-2">
<label class="leading-7 text-sm text-gray-600" for="tailer name">
Tailer Name
</label>
<select name="tailername" id="">
@foreach ($addtailer as $addtailers)
<option value="{{$addtailers->id}}">{{$addtailers->name}}</option>
@endforeach
</select>
</div>


My Answer:
> It seems like you are trying to access the variable `$addtailer__` in your code, but it is not defined anywhere in the provided snippet. Make sure to define the variable before trying to use it in your code.

Here is an example of how you can define and use the variable `$addtailer__` in your code:

php
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\TailerInfo;
use App\Models\AddTailer;

class ClothnaapController extends Controller
{
public function index()
{
// foreign key data code
$addtailer__ = AddTailer::find($id); // Assuming $id is defined somewhere in your code
$tailerinfo = TailerInfo::where('add_tailer_id', $addtailer__->id)->get();

// Rest of your code
}
}


In this example, I assumed that you want to retrieve the `AddTailer` object based on the `$id` and then use its `id` property to filter the `TailerInfo` records. Make sure to adjust the code according to your specific requirements.

Rate this post

5 of 5 based on 2371 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us