How do I set a default value to a variable in a blade partial?
So for example I have 2 variables:
- softDelete
- delete
witch I want by default to be true.
@if($softDelete)
<span data-toggle="tooltip" title="Publish">
<a href="#delete-{{ $id }}" class="btn btn-default btn-xs btn-flat">
<i class="fa fa-check"></i>
</a>
</span>
@endif
@if($delete)
<span data-toggle="tooltip" title="Delete">
<a href="#delete-{{ $id }}" class="btn btn-danger btn-xs btn-delete btn-flat details" data-toggle="modal" data-target="#delete_modal">
<i class="fa fa-trash"></i>
</a>
</span>
@endif
And when I send the view from controller to change the value for some of the variables, depending the case I need.
return view('platform.pages.blocks.property_table_actions',
[
'id' => $model->id,
'delete' => false
]);
I tried with a provider:
public function composeActionButtons()
{
view()->composer('platform.pages.blocks.property_table_actions', function ($view) {
$view
->with('softDelete', true)
->with('delete', true)
->with('view', true)
->with('edit', true);
});
}
but override the false values from controller.
{{ $delete or true }}