Reputation: 33
@foreach ($modules as $module)
@if ($module->name === "h_car_positions") $module_name == "history_car_positions"; @endif
<tr>
<td>{{ $module->id }}</td>
<td><a href="{{ url(config('laraadmin.adminRoute') . '/modules/'.$module->id) }}">{{ $module->name }}</a></td>
<td>{{ $module->name_db }}</td>
<td>{{ Module::itemCount( $module_name ) }}</td>
<td>
<a href="{{ url(config('laraadmin.adminRoute') . '/modules/'.$module->id)}}#fields" class="btn btn-primary btn-xs" style="display:inline;padding:2px 5px 3px 5px;"><i class="fa fa-edit"></i></a>
<a href="{{ url(config('laraadmin.adminRoute') . '/modules/'.$module->id)}}#access" class="btn btn-warning btn-xs" style="display:inline;padding:2px 5px 3px 5px;"><i class="fa fa-key"></i></a>
<a href="{{ url(config('laraadmin.adminRoute') . '/modules/'.$module->id)}}#sort" class="btn btn-success btn-xs" style="display:inline;padding:2px 5px 3px 5px;"><i class="fa fa-sort"></i></a>
<a module_name="{{ $module->name }}" module_id="{{ $module->id }}" class="btn btn-danger btn-xs delete_module" style="display:inline;padding:2px 5px 3px 5px;"><i class="fa fa-trash"></i></a>
</td>
</tr>
@endforeach
i want to assign history_car_positions to $module name when the if statment is true how to do that in blade
Upvotes: -1
Views: 386
Reputation: 10877
Use php tags
@if ($module->name === "h_car_positions") <?php $module_name = "history_car_positions"; ?> @endif
Upvotes: 0
Reputation: 3319
I should first note that your syntax is incorrect - you're comparing (==
), not assigning (=
).
But Blade, being an interpreter, has its own control structure for raw PHP.
However, if you're simply passing this variable into itemCount
, you may want to evaluate and assign this in your view, rather than directly in the template. It'll be much cleaner for you to maintain.
Upvotes: 1
Reputation: 624
You could try the php
directive laravel docs
@if ($module->name === "h_car_positions")
@php
$module_name = "history_car_positions"; // use = instead of ==
@endphp
@endif
Upvotes: 0