I have something similar to create a dynamic eloquent model. I'm assuming the Model you reference is extending Eloquent.
Try,
$temp_table_data = new TempTable();
$temp_table_data->setTable("selected_postcodes_{$timestamp_string}_{$userid}");
$data = $temp_table_data->payment()->get()->toArray();
I'm not sure why you made your own setTable name function, there is one in eloquent already.
Yeah it's still not working. Do my models look correct? Are you sure that Eloquent is meant to return multiple rows in this way and not just one row? (I know that might sound like a ridiculous question if it is).
I'm not sure how well it will work with a foreign key with spaces in it.
You might make sure the base table, without the payment relationship, is loading correctly.
$data = $temp_table_data->get()->toArray();
dd($data); // make sure there is data
Eloquent should return as many rows as there are in the db query.
One way to get the raw query is
$q = DB::getQueryLog();
dd($q);
You might make sure the base table, without the payment relationship, is loading correctly.
Just doing $data = $temp_table_data->get()->toArray();
does print out all the postcodes data from TempTable as hoped. So that's not the problem..
I'm not sure how well it will work with a foreign key with spaces in it.
Possibly... I took that space out in 'Vendor ZIP' temporarily just to see. It still doesn't work. I still see a []
in the browser. But the source code is a big line of CSS/Javascript - which I have never seen before. What is that all about?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community