Do you mean something like this ?
How to make tabs and data dynamic
Hi Awesome People
I have created a service page "views/pages/service.blade.php " Which contains 5 tabs now they are static on clicking a tab details related to that should display which is now static bu passing id, i wan to make it dynamic which i really don't know how to do
My "service.blade.php"
<div role="tabpanel">
<!-- Nav tabs -->
<ul class="nav nav-tabs nav-justified" role="tablist">
<li role="presentation" class="active">
<a href="#home" aria-controls="home" role="tab" data-toggle="tab">
Graphic Designing
</a>
</li>
<li role="presentation">
<a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">
Mobile App Development
</a>
</li>
<li role="presentation">
<a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">
Website Development
</a>
</li>
<li role="presentation">
<a href="#testing" aria-controls="testing" role="tab" data-toggle="tab">
Software Testing
</a>
</li>
<li role="presentation">
<a href="#prodserv" aria-controls="prodserv" role="tab" data-toggle="tab">
Product Engineering
</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<div class="col-md-9 col-xs-12">
<p> Description Goes here </p>
</div>
<div class="col-md-3 col-xs-9">
<img class="img-responsive" src="images/serv/csdevelop.png">
</div>
</div>
<div role="tabpanel" class="tab-pane" id="profile">
<div class="col-md-9 col-xs-12">
<p> Description Goes here </p>
</div>
<div class="col-md-3 col-xs-9">
<img class="img-responsive" src="images/serv/madevelop.png">
</div>
</div>
<div role="tabpanel" class="tab-pane" id="settings">
<div class="col-md-9 col-xs-12">
<p> Description Goes here </p>
</div>
<div class="col-md-3 col-xs-9">
<img class="img-responsive" src="images/serv/wadevelop.png">
</div>
</div>
<div role="tabpanel" class="tab-pane" id="testing">
<div class="col-md-9 col-xs-12">
<p> Description Goes here </p>
</div>
<div class="col-md-3 col-xs-9">
<img class="img-responsive" src="images/serv/stesting.png">
</div>
</div>
<div role="tabpanel" class="tab-pane" id="prodserv">
<div class="col-md-9 col-xs-12">
<p> Description Goes here </p>
</div>
<div class="col-md-3 col-xs-9">
<img class="img-responsive" src="images/serv/peservece.png">
</div>
</div>
</div>
</div>
And My Controller and Model And Route are cool, i mean i'm getting the data
//AvoServices.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class AvoService extends Model {
protected $table = "avo_services";
}
//AvoServiceController.php
<?php
namespace App\Http\Controllers;
use View;
use App\AvoService;
use Illuminate\Routing\Controller as BaseController;
class AvoServiceController extends BaseController {
public function servicepage()
{
$serve = AvoService::all();
return view('pages.services')->with(['serve' => $serve]);
}
}
//Route
Route::get('services', 'AvoServiceController@servicepage');
The table structure is
id services services_description service_image
1 Graphic Design Description 1 image link
2 App Development Description 2 image link
So on.......
The problem is i'm not getting how to slit the data or loop through the data on clicking a tab particular data should be displayed
Looking forward for much needed help
Thank You
@MrRobot21 Spamming won't make me work any faster you know.. I also have a day job and do this for free and in my free time!
So I already see that something is going wrong here! The link in the list item doesn't match the id of the tab. Here is a basic example that is working fine. I suggest you to check out the code below and see the differences ;)
Note: you don't need the extra javascript code. Bootstrap already activated the tabs for you be default ;)
<div class="tabpanel">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
@foreach($serve as $count => $serves)
<li role="presentation" @if($count == 0) class="active" @endif>
<a href="#tab-{{ $serves->id }}" aria-controls="#tab-{{ $serves->id }}" role="tab" data-toggle="tab">{{ $serves->service }}</a
</li>
@endforeach
</ul>
<!-- Tab panes -->
<div class="tab-content">
@foreach($serve as $count => $serves)
<div role="tabpanel" @if($count == 0) class="tab-pane active" @else class="tab-pane" @endif id="tab-{{ $serves->id }}">
<h2>{{ $serves->service }}</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias enim obcaecati praesentium repellat. Est explicabo facilis fuga illum iusto, obcaecati saepe voluptates! Dolores eaque porro quaerat sunt totam ut, voluptas.</p>
</div>
@endforeach
</div>
</div>
Please or to participate in this conversation.