Laravel backend not saving to database

I’m uploading files using laravel as backend apirest. When I upload a file in the frontend, its sends a 200 OK status code in the response, but doesnt save it to the database. Something weird that I see its that in the response the data comes empty, and the array of the files comes in the config section of the response.
200 ok response

This is the controller that handles this situation

 public function makeFile(Request $request)
    {
        $fileArray = [];
    if (isset($request->files) && is_array($request->files)) {
        foreach ($request->files as $key => $fileEntity) {
            $file= new File();
            $file->file=$fileEntity['file'];
            $file->shipment_id=$fileEntity['shipment_id'];
            $file->user_id=$fileEntity['user_id'];
            $file->date=date('Y,m,d,G,i,s');
            $file->fileName=$fileEntity['fileName'];
            $file->fileType=$fileEntity['fileType'];
            $file->status=$fileEntity['status'];
            $file->save();

            $fileArray[] = $file;
        }
    }
    return response()->json($fileArray);
    }


Source: stackoverflow-javascript

how to access parents controller data within component in angularjs

I have been told to incorporate AngularJS’s component into my app. Before using components, I had two controllers, patentList and patentItem. When a user clicked on an item from the patent list, it would load more details on that specific patent item.

Now I have included the controllers in the components, data is failing to populate the patent item table. This is down to (I think) that the patent item is a child of patent list and I was able to access the parents data.

When I log the selected item, it shows with all properties and values.
console log of item selected

My question is, how do I access the data of parent controller now I have used components? Any help would be greatly appreciated

list-patents

<tr ng-repeat="x in $ctrl.patents">
    <td ng-click="$ctrl.select(x)"><a ui-sref="patents.list.item({id: x.id})">{{x.applicationNumber}}</a></td>
    <td ng-bind="x.clientRef"></td>
    <td ng-bind="x.currentRenewalCost">$</td>
    <td ng-bind="x.costBandEndDate"></td>
    <td ng-bind="x.renewalCostNextStage"></td>
    <td ng-bind="x.renewalDueDate"></td>
</tr>

patent-item

<tr ng-repeat="x in $ctrl.patentItem">
    <td><input type="text" ng-model="x.patentApplicationNumber"></td>
    <td><input type="text" ng-model="x.clientRef"></td>
    <td><input type="text" ng-model="x.renewalStatus"></td>
    <td><input type="text" ng-model="x.costBandEndDate"></td>
    <td><input type="text" ng-model="x.renewalCostNextStage"></td>
    <td><input type="text" ng-model="x.renewalDueDate"></td>
</tr>

app.js

var app = angular.module('myApp', ['ngRoute', 'ui.router']);

app.config(function($stateProvider, $locationProvider, $urlRouterProvider, localStorageServiceProvider) {

    app.component('patentList', {
        scope: {},
        templateUrl: "templates/patents/list/list-patents.htm",
        controller: function(loadPatentsService, loadPatentItemService) {

            var vm = this;

            vm.select = function(item) { 
               vm.patentItem = loadPatentItemService.select(item);
               console.log(item)
            }
        }
    })
});

app.component('patent', {
    scope: {},
    templateUrl: "templates/patents/list/patent-item.htm",  
    controller: function(patentTabService, loadPatentItemService) {

        var vm = this;

       //LOAD OF CODE FOR A TAB PANEL

    }
})

app.factory('loadPatentItemService', function() {

    var factory = {};

        factory.select = function(item) {
            factory.storeSelect = [];
            selectedItem = item; 
            factory.storeSelect.push(selectedItem)
            return [selectedItem];
        }      

    return factory;

})

app.factory('patentTabService', function() {

    var factory = {};

        //CODE RELATED TO THE TAB PANEL

    return factory;

});


Source: stackoverflow-javascript

VoiceOver in Chrome appears to read the opposite state of toggle buttons in AngularJS

I’m working on an AngularJS app and have created a directive for a toggle button. I’m using role="button" and aria-pressed="true|false" to make the element behave like a toggle button. When testing A11y with VoiceOver, the state of the button is spoken correctly when you first tab to it: something like “label text – selected – toggle button” if the toggle is checked, and “label text – toggle button” if it’s unchecked.

The problem is: when you trigger the toggle, the voice feedback is pretty much the opposite of what I want. If it’s an unchecked toggle and you trigger it to check it, the voice speaks “deselect label text toggle button”. If it’s checked and you trigger it to uncheck it, it speaks “select label text toggle button”.

I can’t help thinking this will be confusing to blind users – what the voice is saying about what has just happened is the opposite of what the user actually did.

My template looks like this:

{{toggleOnLabel}} {{toggleOffLabel}}
</div>

The directive code looks like this:

.directive('desktopLockToggle', ['$timeout', function($timeout) {
        return {
            require: '^form',
            restrict: 'E',
            template: *[see above]*,
            scope: {
                toggleOnLabel: '@',
                toggleOffLabel: '@',
                name: '@',
                lockId: '@',
                lockModel: '='
            },
            link: function ($scope, $element, $attrs, form) {
                $scope.form = form;
                $timeout(function() {
                    $element.find('div.desktopLockToggle').attr('aria-pressed', $scope.lockModel.locked);
                }, 0);
            },
            controller: function ($scope, $element, $attrs, $transclude) {
                $scope.toggleMe = function(event) {
                    var $toggle = $(event.currentTarget);
                    var $checkBox = $toggle.find('input');
                    var toggledValue = $scope.lockModel.locked;

                    if (event.target.nodeName.toLowerCase() !== 'input') {
                        toggledValue = $scope.lockModel.locked = !$scope.lockModel.locked;
                    }
                    $toggle.attr('aria-pressed', toggledValue);
                    $checkBox.prop('checked', toggledValue);
                };
            }
        };
    }]);


Source: stackoverflow-javascript

Angular 2 static page routing

i build a static page using angluar 2, when i run ng serve and go to my page it run like i want. what i mean with what i want is, it can go to specific page by typing in url, like www.mysite.com/resume but when i uploaded it to my site after doing ng build --prod i can’t go to www.mysite.com/resume by typing, it shows 404 page not found.

This is my app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule, Routes } from '@angular/router'
import { NgsRevealModule } from 'ng-scrollreveal';

import { AppComponent } from './app.component';
import { HomeComponent } from './components/home/home.component';
import { NavbarComponent } from './components/navbar/navbar.component';
import { ResumeComponent } from './components/resume/resume.component';
import { FooterComponent } from './components/footer/footer.component';
import { PortofolioComponent } from './components/portofolio/portofolio.component';

const appRoutes: Routes = [
  {path:'', component: HomeComponent},
  {path:'resume', component: ResumeComponent},
  {path:'portofolio', component: PortofolioComponent},
  {path:'**', component: HomeComponent}
]

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    NavbarComponent,
    ResumeComponent,
    FooterComponent,
    PortofolioComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule.forRoot(appRoutes),
    NgsRevealModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

this is my app.component.html

<app-navbar></app-navbar>
<app-footer></app-footer>

in my navbar.component.html i have button to specific component and it works well.

this is my navbar.component.html

Angular 2 – How to set max date to today for date input?

 <input class="alert-input date-input" #dob="ngModel" name="dob" max="2017-04-01" [(ngModel)]="leadDetail.dob" type="date"></div>

How can i set the max date to today instead of 2017-04-01?

I tried following methods –

 <input  max="today" type="date"></div>
 <input  max="{{today | date:'yyyy-mm-dd'}}" type="date"></div>

Class –

public today = new Date();

but no luck.


Source: stackoverflow-javascript

angular js in multiple images add one by one also delete images with div

I have a need to loop through multiple images file and I’m using AngularJS for that. i want one upload images after option second image like is continue many images, after any images delete shift position left
my code below

<td style="width: 0px;" ng-show="procedureStepDetail.Record.procedure_step_image || procedureStepDetail.Record.procedure_step_image1">

image

Select Change Edit Delete
</div>

controler js

$scope.getTheProcedureStepFiles1 = function($files){

    $('.LoaderDiv').removeClass('ng-hide');
    $('body').addClass('bodyLoading');
    var reader = new FileReader();
    reader.onload = procedureStepTmageIsLoaded;
    reader.readAsDataURL($files[0]);
    //var data = new FormData();
    data.append('procedure_step_image1', $files[0]);
    $http({
        method: 'POST',
        url: baseurl+'api/images/upload',
        data: data,
        headers: {"Content-Type" :  undefined}
    }).success(function(data){
        //console.log(data);
        $('.LoaderDiv').addClass('ng-hide');
        $('body').removeClass('bodyLoading');
        //var temp_procedure_step_image_name = data.Root[0].Record.procedure_step_image_data.name;
        $scope.temp_procedure_step_image_src = data.Root[0].Record.procedure_step_image_data.path;

      //  launchEditorProcedureStep('tempProcedureStepImg1', $scope.temp_procedure_step_image_src);
        //var data = new FormData();

    });
    }
}

How can I fix that?


Source: stackoverflow-php

Angular1.6 Factory

Hii I m using following code. I am reading a json file name is “users.json”. If i read this file in controller through $http everything works fine. but i want to use the data that i read from file, again and again in different controller so i made a factory for this. but in factory when i read data from that json file through $http.get() and in return when i call that service method in my controller and it returns Object { $$state: Object }

app.factory('AboutFactory',['$http',function ($http) {
    return {
        getter: function () {
            return $http({
                method : 'GET',
                url : '/home/penguin/Modeles/users.json',
                cache : true
            })
            .then(function (response) {
                return response.data
            })
        }         
    }
}])


Source: stackoverflow-javascript

angular.forEach looping through string array

I have a function that checks for userPermissions and it is part of a Service called MyService . I am passing in an array with only one string. The issue I am facing is angular.forEach is looping through character by character instead of the complete string. Please can you advise?

//Service changes

MyService.userHasPermission("['Read']")

//Permission function

 function userHasPermission (permissions){
        var found = false;
        angular.forEach(permissions, function(expectedPermission, index){
            if ($localStorage.userPermissions.indexOf(expectedPermission) >= 0){
                found = true;
                return;
            }
        });

        return found;
    };


Source: stackoverflow-javascript

AngularJS to Mysql

I must be missing something… because I’m really a noob at this.

I have this angularjs data:

$scope.todoList = [
      { text: 'Check me out' },
      { text: 'Lorem ipsum dolor sit amet, possit denique oportere at his, etiam corpora deseruisse te pro' },
      { text: 'Ex has semper alterum, expetenda dignissim' },
    ];

And I wanted to put it in a mysql table instead. I created the table and then tried to get table data:

JS:

$http({method:'POST',url:'process.php'})
          .then(
            function successCallback(response) { $scope.todoList = response.data;}, 
            function errorCallback(response) {$scope.todoList = "ERROR!";});

PHP:

    $sql = "SELECT * from `todolist`";
    $result = $conn->query($sql);
    $data = array();
    while ($row = mysqli_fetch_assoc($result)) {
        $data[] = array("text" => $row['text']);
    }
    echo json_encode($data);

When I manually try the PHP the output is:

[{"text":"Check me out"},{"text":"Lorem ipsum dolor sit amet, possit denique oportere at his, etiam corpora deseruisse te pro"},{"text":"Ex has semper alterum, expetenda dignissim"}]

Does someone know where the problem is?


Source: stackoverflow-php