i have few simple code and i wanna paginate when my condition is correct
here my codes
Route:
Route::resource('lang','zabanController');
Controller :
public function index(){
$show=DB::table('zaban')->paginate(5);
return view('twoLang.index',compact('show'));
}
public function show($id)
{
DB::table('zaban')->where('default_lang','!=',$id)->update([
'default_lang'=>$id
]);
}
View :
<div class="container-fluid">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div>
<a href="">Per</a>
<a href="">ENG</a>
</div>
<table class="table table-hover table-bordered table-striped">
<thead>
<tr>
<th>id</th>
<th>lang ID</th>
<th>Default lang</th>
<th>Content</th>
</tr>
</thead>
<tbody>
@foreach($show as $content)
@if($content->my_lang==$content->default_lang)
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
</div>
</div>
DB -> Table Name 'zaban'
table Fields => id , my_lang , default_lang ,created_at , updated_at
and here my problem
i wanna paginate content that 'my_lang' = 'default_lang'
just like this
id = 1 , my_lang = 0 , default_lang = 1
id = 2 , my_lang = 1 , default_lang = 1
id = 3 , my_lang = 0 , default_lang = 1
ok.here just need return id=2
ofcourse default_lang may change in process but my_lang always is fix (if i wrote correct :) )
meaning if table field change like this :
id = 1 , my_lang = 0 , default_lang = 0
id = 2 , my_lang = 1 , default_lang = 1
id = 3 , my_lang = 0 , default_lang = 0
need to return id=1 and id=3
hope clear my mind
i wrote this in my controller but no chance
$show=DB::table('zaban')->where('my_lang','default_lang')->paginate(5);
and this
$alls=DB::table('zaban')->get();
foreach($alls as $al)
{
$show = DB::table('zaban')->where('my_lang','default_lang')->paginate(5);
}
via siros