Reputation: 915
The following is a sample of an array inside an array :
array:2 [▼
0 => {#338 ▼
+"id": 25
+"created_at": "2019-10-18 11:13:17"
+"updated_at": "2019-10-18 11:13:17"
+"title": "question"
+"body": """
\r\n
aasasas
"""
+"ttype": 0
+"cat": 0
+"a_id": 25
+"tag": ""
+"appr": 0
+"user_id": 6
+"comment_id": 0
+"parent_id": null
+"ppoints": null
+"status": 0
+"arank": 1
+"qatype": 1
+"country": "Egypt"
+"wwide": 0
}
Is there a way to display the required array values based on a condition inside the blade ?
For example, the following will show the title in the view : {{$updt_11->title}}
.
Can I display the title if the id=25 for example ?
A wrong example for demonstration:
{{ $updt_11->where('id',25)->select('title')->first()->title}}
Upvotes: 0
Views: 689
Reputation: 8338
Basically if you want to use Model output in your blade, you can do something like:
{{ \App\Models\MyModel::where('id',25)->first()->title}}
\App\MyModel
Your Model should look like (just an example) :
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MyModel extends Model
{
protected $table = 'my_table';
protected $guarded = [];
}
Upvotes: 1
Reputation: 2945
Inside blade file, you can be able to use if a condition like:
@if($updt_11->id == '25')
{{ $updt_11->title }}
@endif
Try it.
Upvotes: 2