Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index()
- {
- $clients = Client::where('business_id', '=', Auth::user()->business_id)->orderBy('updated_at', 'DESC')->get();
- return Response::json([
- 'clients' => $this->transformClientCollection($clients)
- ], 200);
- }
- public function transformClientCollection($clients)
- {
- return array_map([$this, 'transformClient'], $clients->toArray());
- }
- public function transformClient($clients)
- {
- return [
- 'clientid' => $clients['id'],
- 'first_name' => $clients['first_name'],
- 'last_name' => $clients['last_name'],
- 'address_1' => $clients['address_1'],
- 'address_2' => $clients['address_2'],
- 'city' => $clients['city'],
- 'state' => $clients['state'],
- 'postal_code' => $clients['postal_code'],
- 'phone_number_1' => $clients['phone_number_1'],
- 'phone_number_2' => $clients['phone_number_2'],
- 'email' => $clients['email']
- ];
- }
- <div ng-app="instantsearch">
- <div ng-controller="instantSearchCtrl">
- <div class="row">
- <div class="col-sm-12">
- <input type="text" class="form-control search" ng-model="searchString" placeholder="Enter your search terms" />
- </div>
- </div>
- <div class="row data-ctrl" ng-repeat="i in items | filter:searchString | limitTo:20 ">
- <div class="col-sm-12">
- @{{ i.first_name }} @{{ i.last_name }} @{{ i.address_1 }} @{{ i.address_2 }} @{{ i.city }} @{{ i.state }} @{{ i.phone_number_1 }} @{{ i.phone_number_2 }} @{{ i.email }}
- </div>
- </div>
- </div>
- </div>
- var app = angular.module('instantsearch',[]);
- app.controller('instantSearchCtrl',function($scope,$http,$location){
- var urlapiclients = $location.protocol() + "://" + $location.host() + "/api/clients" ;
- $http.get(urlapiclients).success(function(data, status, headers, config) {
- $scope.items = data.clients;
- }).error(function(data, status, headers, config) {
- console.log("No data found..");
- });
- });
- app.filter('searchFor', function(){
- return function(arr, searchString){
- if(!searchString){
- return arr;
- }
- var result = [];
- searchString = searchString.toLowerCase();
- angular.forEach(arr, function(item){
- if(item.first_name.toLowerCase().indexOf(searchString) !== -1){
- result.push(item);
- }
- });
- return result;
- };
- });
- "clients":[
- {
- "clientid":4981,
- "first_name":"Sid",
- "last_name":"Hodkiewicz",
- "address_1":"6659 Hackett Ways",
- "address_2":"",
- "city":"New Estherville",
- "state":"Tennessee",
- "postal_code":"27281-0870",
- "phone_number_1":"00700300842",
- "phone_number_2":"",
- "email":"hNitzsche@Stokes.biz"
- },
- {
- "clientid":4982,
- "first_name":"Braulio",
- "last_name":"Bechtelar",
- "address_1":"7558 Anne Land Suite 876",
- "address_2":"",
- "city":"Rauview",
- "state":"Alabama",
- "postal_code":"01837-9601",
- "phone_number_1":"1-017-001-8215",
- "phone_number_2":"",
- "email":"nBaumbach@gmail.com"
- },
- {
- "clientid":4983,
- "first_name":"Loma",
- "last_name":"Dibbert",
- "address_1":"805 Jones Fields Suite 411",
- "address_2":"",
- "city":"Lake Billychester",
- "state":"New Jersey",
- "postal_code":"69315-4595",
- "phone_number_1":"(691)511-6275x891",
- "phone_number_2":"",
- "email":"dHegmann@Bashirian.net"
- },
- {
- "clientid":4984,
- "first_name":"Verla",
- "last_name":"Schulist",
- "address_1":"89529 Bode Village Suite 344",
- "address_2":"",
- "city":"West Jessy",
- "state":"Virginia",
- "postal_code":"69116",
- "phone_number_1":"(248)211-3643",
- "phone_number_2":"",
- "email":"Friesen.Ruthie@Hand.biz"
- },
- {
- "clientid":4985,
- "first_name":"Jimmie",
- "last_name":"Fadel",
- "address_1":"4355 Marquardt Heights",
- "address_2":"",
- "city":"South Conrad",
- "state":"District of Columbia",
- "postal_code":"55751",
- "phone_number_1":"(414)901-2495",
- "phone_number_2":"",
- "email":"Koepp.Wayne@yahoo.com"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement