laravel - Why $bgprofiles is undefine if I do not place the isset? -
here codes. how define $bgprofile correctly? wonder why $bgprofile undefine error appears if not place isset. evenso, not picture collection appearing except see. clue? below posted settingcontroller.php, setting.blade.php , routes.php .
settingcontroller.php
public function getbackgroundprofile(request $request) { $domain = $_server['server_name']; $user = user::where('domain', $domain)->first(); $bgprofiles = db::table('user_bgprofile')->where('user_id', $user->id)->get(); return view('soulfy.setting', [ 'bgprofiles' => $bgprofiles, 'user' => $user, ]); } setting.blade.php
<form action="{{url::to('/home/theme')}}" method="post"> <span class="setting-name">theme</span> <!-- <form method="post" action="/posts"> --> {{ csrf_field() }} <span class="setting-value center"> <select name="menu"> <option value="">all</option> <option value="handicraft">handicraft</option> <option value="farming">farming</option> <option value="services">services</option> <option value="tour & travel">tour & travel</option> <option value="trading">trading</option> <option value="fishery">fishery</option> <option value="lifestyle">lifestyle</option> <option value="music">music</option> <option value="property">property</option> <option value="hobby">hobby</option> <option value="politic">politic</option> </select> <input type="submit" value="submit"> <br><br> </span> </form> <form action="{{ action('settingcontroller@sendpicture') }}" method="post"> {{ csrf_field() }} <table> @foreach ($themes->chunk(3) $chunk) <tr> @foreach ($chunk $theme) <td> <a href="{{url('/')}}/uploads/theme/{{$theme->pic_name}}.jpg" data-lightbox="image-gallery" data-title="{{$theme->pic_name}}" > <img width="100px" height="100px" src="{{url('/')}}/uploads/theme/{{$theme->pic_name}}.jpg"/></a> <input type="checkbox" name="pic[{{$theme->pic_name}}]" value="{{$theme->pic_name}}"/> </td> @endforeach </tr> @endforeach </table> @if ( $themes->currentpage() != 1) <a href="{!! $themes->previouspageurl() !!}"> << </a>@endif {!! $themes->currentpage() !!} of {!! $themes->lastpage() !!} @if ( $themes->currentpage() != $themes->lastpage()) <a href="{!! $themes->nextpageurl() !!}"> >> </a>@endif <input type="submit" value="purchase"> </form> <form action="{{ action('settingcontroller@getbackgroundprofile') }}" method="post"> {{ csrf_field() }} <table> @if(isset($bgprofile)) { @foreach ($bgprofiles->chunk(3) $chunk) <tr> @foreach ($chunk $bgprofile) <td> <a href="{{url('/')}}/uploads/bgprofile/{{$bgprofile->bgprofile}}.jpg" data-lightbox="image-gallery" data-title="{{$bgprofile->bgprofile}}" > <img width="100px" height="100px" src="{{url('/')}}/uploads/bgprofile/{{$bgprofile->bgprofile}}.jpg"/></a> <input type="checkbox" name="pic[{{$bgprofile->bgprofile}}]" value="{{$bgprofile->bgprofile}}"/> </td> @endforeach </tr> @endforeach } @endif </table> </form> routes.php
route::get('home/bgprofile', 'settingcontroller@getbackgroundprofile');
where defining $bgprofile in settings.blade.php file? variable you're passing view $bgprofiles (plural), if there's no definition anywhere - you're bound thrown error unless you're adding isset condition, in case it'll see isn't defined , proceed no further.
Comments
Post a Comment