Ben Ben - 1 month ago 6
PHP Question

Laravel - return text stored from DB without the default formatting

I want to return some text stored within the database, but without the current formatting of brackets and quotations that appears to be included when I get the row from the DB:


["Aut ducimus et deleniti quaerat. Autem minima amet et totam et
incidunt culpa. Ullam enim est maxime veniam expedita aut. Magni
tempora autem iste repudiandae quisquam. Libero nisi delectus incidunt
aut rerum incidunt."]


Database seed:

public function run()

{
$faker = Faker\Factory::create('en_GB');

$terms = [[
'terms' => $faker->paragraph(3)

]];

DB::table('miscellaneous')->insert($terms);

}


Controller.php:

$terms = Miscellaneous::where('id', 1)->pluck('terms');


View:

<textarea class="form-control" rows="15">{{ $terms }}</textarea>


How can I output the
raw
text that's stored within the DB like such:


Aut ducimus et deleniti quaerat. Autem minima amet et totam et
incidunt culpa. Ullam enim est maxime veniam expedita aut. Magni
tempora autem iste repudiandae quisquam. Libero nisi delectus incidunt
aut rerum incidunt.

Answer

In Eloquent pluck() returns an array containing the data from one column of each row. If you select a single row, the attributes can be used to access to the right column.

Try this (suppose that column id is the primary key):

$terms = Miscellaneous::findOrFail(1)->terms;
Comments