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();

            $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


<tr ng-repeat="x in $ctrl.patents">
    <td ng-click="$"><a ui-sref="patents.list.item({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 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>


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;

   = function(item) { 
               vm.patentItem =;

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

        var vm = this;



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

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

    return factory;


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

    var factory = {};


    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}}

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 ( !== '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 but when i uploaded it to my site after doing ng build --prod i can’t go to 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}

  declarations: [
  imports: [
  providers: [],
  bootstrap: [AppComponent]
export class AppModule { }

this is my app.component.html


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">


Select Change Edit Delete

controler js

$scope.getTheProcedureStepFiles1 = function($files){

    var reader = new FileReader();
    reader.onload = procedureStepTmageIsLoaded;
    //var data = new FormData();
    data.append('procedure_step_image1', $files[0]);
        method: 'POST',
        url: baseurl+'api/images/upload',
        data: data,
        headers: {"Content-Type" :  undefined}
        //var temp_procedure_step_image_name = data.Root[0];
        $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) {

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


//Permission function

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

        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:


            function successCallback(response) { $scope.todoList =;}, 
            function errorCallback(response) {$scope.todoList = "ERROR!";});


    $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