Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

blade displaying multi array data with or

I want to display the old data in blade after redirect. So if the old data is empty or doesn't exists it should display my passed task data multidimensional array.

Laravel:

redirect()->withInput();

Blade:

name ="task[{{$dayKey}}][]"
value="{{old('task.'.$dayKey.'.'.$key) or $task}}"

Separately {{old('task.'.$dayKey.'.'.$key) and $task works fine but if i used or the output is every time 1.

like image 360
s1njar Avatar asked Jan 22 '26 00:01

s1njar


1 Answers

You can set default value with comma separated second argument.

value="{{old('task.'.$dayKey.'.'.$key, $task)}}"

This will check for old input value, if there is no old input value then will set the default one.

like image 105
Sohel0415 Avatar answered Jan 24 '26 21:01

Sohel0415