如何在 laravel 5.2 中只显示最新的 post 而没有 html <p> 标签?

How to display only latest post in laravel 5.2 and that too without html <p> tag?

我只想显示用户最新 post(或状态)post。问题是所有 post 都显示有 <p> 标签。我正在 summernote 编辑器中输入。

我正在做的是:

 $accounts=Account::orderBy('updated_at','')->get();

我在我的视图文件中将其输出为:{{$account->estado}}

要删除 html 标签,您可以使用:strip_tags()

echo strip_tags("Hello <b>world!</b>");

结果:

Hello world!

并且仅获取 $x 最后一个帐户:

$x = 5;
$accounts = Account::orderBy('updated_at','desc')
    ->limit($x)
    ->get();
$accounts=Account::orderBy('updated_at','')->first();

这只会获取您请求的第一个元素。

您可以使用此方法按日期获取最后一次输入:

$accounts=Account::orderBy('updated_at','desc')->first();

你可以使用 ->select('field1, field2');如果您需要 select在要检索的字段中,也在查询中。

您可以在此处找到更多信息:https://laravel.com/docs/5.2/queries

要删除标签,您可以使用 strip_tags 或类似的。

或者存储删除标签的字符串。

这里有一些关于 blade 模板的信息:https://laravel.com/docs/5.2/blade

这将获取最新的帐户并限制为您想要的某些号码, 例如获取最新的 5 post.

$accounts=Account::orderBy('updated_at','desc')->limit(5)->get();