Hello guys I am trying to retrieve data from my database to a livewire component and I keep getting this error: Property [destination] does not exist on this collection instance.
here is my migration table:
public function up()
{
Schema::create('delivery_fees', function (Blueprint $table) {
$table->id();
$table->string('destination');
$table->integer('domicile');
$table->integer('stopdesk');
$table->timestamps();
});
}
*am trying to retrieve the destination value like this:
public function render()
{
$delivery_fees = DeliveryFee::all();
dd($delivery_fees->destination);
return view('livewire.form-elements');
}
Note
when I try dd($delivery_fees)
It show me all the database values but when I try this dd($delivery_fees->destination)
to retrieve only the destination value it throws back an error.
Please feel free to tell me what I am doing wrong and tell me how to fix it. thanks
use App\Models\DeliveryFee;
public function render(){
return view('livewire.form-elements')
->with([
'Delivery_fee' => DeliveryFee::all()
]);
}
In the livewire.form-elements
page you can now access all the columns like this: Delivery_fee->destination
and other propoerties in the Table.
Make sure you import the model in DeliveryFee
in the live wire component