@TorchSK : Thank you very much for your help. I've also used the way you provided, but I don't know how to access the data returned to the view. Could you guide me about that?
For access your data into view, you need just to do loop. For example:
@foreach($langs as l) <div>{!! $l->datafromdatabase !!} @endforeach
@jonitopsg : I tested what you adviced but there is no result seen in output ! How can I check if any data has been exploited and if it is passed to the view before being processed and shown ?
Yes, and the result indicates I've not retrieved anything from the database (at least I think so). The output is :
Collection {#194 ▼
#items: []
}
There is actually values assigned to database columns at the time of their creation and I can view them in phpmyadmin. I wonder what can be the error in my work. I have even tried the code below before passing it to the view, but still nothing is displayed :
$flattened = $langs->flatten();
Have you tried to access another table of your DB to show if you got something?
I have set the values in .env and /config/database.php , Is it not enough? I checked the table contents by mysql from bash and
SELECT * FROM TABLE_NAME;
returns :
Empty set (0.62 sec)
while I can see the columns have values when viewed in phpmyadmin. Should I have done something after creating the table in homeController.php
to make the default values saved? Considering the nature of the application (I needed to create the a table per user dynamically) I wrote the codes below to be able doing it :
$user_id = Auth::user()->id;
$user_name = Auth::user()->name;
$table_name = $user_name . '_' . $user_id;
Schema::connection('mysql')->create($table_name, function ($table){
$value = 0;
$table->string('langs')->default('langs');
$table->string('en')->default($value);
$table->string('fr')->default($value);
$table->string('sp')->default($value);
});
$langs = DB::table($table_name)->get();
Just set values into the .env file. You saw the values into DB? I saw the docs of laravel and you can do the same with:
Schema::create($table_name, function ($table) { $table->increments('id'); });
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community