jeudi 27 décembre 2018

Ag-grid - Data does not load in laravel view

I am using Laravel Framework 5.7.19 and the latest version of ag-grid.

I am loading the needed libraries from the example in my app.blade.php:

<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="">

    <title></title>

    <!-- Scripts -->
    <script src="" defer></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <link href="" rel="stylesheet">

    <!-- ag-grid -->
    <script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.min.noStyle.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/ag-grid-community/dist/styles/ag-grid.css">
    <link rel="stylesheet" href="https://unpkg.com/ag-grid-community/dist/styles/ag-theme-balham.css">

</head>
<body>
<div id="app">
    @include('layouts.nav.mainNav')

    <main class="py-4">
        @yield('content')
    </main>
</div>
</body>
</html>

My grid.blade.php looks like the following:

@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row justify-content-center">
            <div class="">

                <h1>Hello from ag-grid!</h1>
                <button onclick="getSelectedRows()">Get Selected Rows</button>
                <div id="myGrid" style="height: 600px;width:500px;" class="ag-theme-balham"></div>

                <script type="text/javascript" charset="utf-8">
                    // specify the columns
                    var columnDefs = [
                        {headerName: "Make", field: "make", rowGroupIndex: 0 },
                        {headerName: "Price", field: "price"}
                    ];

                    var autoGroupColumnDef = {
                        headerName: "Model",
                        field: "model",
                        cellRenderer:'agGroupCellRenderer',
                        cellRendererParams: {
                            checkbox: true
                        }
                    }

                    // let the grid know which columns and what data to use
                    var gridOptions = {
                        columnDefs: columnDefs,
                        enableSorting: true,
                        enableFilter: true,
                        autoGroupColumnDef: autoGroupColumnDef,
                        groupSelectsChildren: true,
                        rowSelection: 'multiple'
                    };

                    // lookup the container we want the Grid to use
                    var eGridDiv = document.querySelector('#myGrid');

                    // create the grid passing in the div to use together with the columns & data we want to use
                    new agGrid.Grid(eGridDiv, gridOptions);

                    fetch('https://api.myjson.com/bins/ly7d1').then(function(response) {
                        return response.json();
                    }).then(function(data) {
                        gridOptions.api.setRowData(data);
                    })

                    function getSelectedRows() {
                        const selectedNodes = gridOptions.api.getSelectedNodes()
                        const selectedData = selectedNodes.map( function(node) { return node.data })
                        const selectedDataStringPresentation = selectedData.map( function(node) { return node.make + ' ' + node.model }).join(', ')
                        alert('Selected nodes: ' + selectedDataStringPresentation);
                    }
                </script>

            </div>
        </div>
    </div>
@endsection

It is basically the simple example from the Ag-grid JS example.

enter image description here

The data does not load within the example. Any suggestions what I am doing wrong?

I appreciate your replies!



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Spj4HS
via IFTTT

How to set laravel app on Digital Ocean under docker?

I installed laravel 5 app on Digital Ocean Server (under kubuntu 18) using Docker So now url of mysite looks like http://NNN.NN.NNN.N:8085/public/login, where http://NNN.NN.NNN.N - is ip of my server 8085 - port I set in docker-compose.yml file :

version: '3.1'

services:

    web:
        build:
            ...
        ports:
            - 8085:80
        working_dir: ${APP_PTH_CONTAINER}

I want to include youtube video for this app, so I have to set client ID/ client secret and getting Authorized redirect URIs I have to enter Authorized domains value like :

NNN.NN.NNN.N:8085

I got error message : Invalid domain: cannot contain port.

Can you give me a hint how to salve this task? have I to use new domain for this app, like https://my.freenom.com But how to work with it as I have port set ?

Thanks!



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2ERp3Bh
via IFTTT

use from a variable in layouts pages

I want use from $unreadMessages in my layout pages but I don't know which controller is for layouts pages. Hello, I want to use the $unreadMessages variable defined in the layouts page, it is in dashboardController, but This error appear:

Undefined variable: unreadMessages (View: /myhost/resources/views/layouts/app.blade.php) (View: / myhost /resources/views/layouts/app.blade.php)

In which controller can I define this variable so I can use it in layouts?

And this code is for $unreadMessages in dashboardController:

class DashboardController extends Controller
{

public function index()
{
    \Artisan::call('status:check');
    $unreadMessages = TicketMessage::where(['is_read' => 0])->whereIn('ticket_id', $ticketIds)->whereNotIn('user_id', [Auth::user()->id])->count();


    return view('dashboard', compact(
        'unreadMessages'
    ));
}
}



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2BHsSWE
via IFTTT

Need mysql data with grouped values based on column values in php

I have table schema as below

name   type  total
name1  type1  10
name1  type1  10
name1  type2  20
name1  type3  30
name2  type1  30
name2  type2  40
name2  type3  50
name2  type4  25

i need output as

name  type1 type2 type3 type4
name1 20    20     30    0
name2 30    40     50    25

How can i achieve this using php and mysql. Can anyone please help me out to solve this



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2LD3LbY
via IFTTT

How to make laravel run on my local server

I bought a laravel script, is working online and is not running locally. when i run it locally i see error Fatal error: Interface 'Psr\Container\ContainerInterface' not found in C:\xampp72\htdocs\investment\cronlab\vendor\laravel\framework\src\Illuminate\Contracts\C ontainer\Container.php on line 8 but online is ok

my composer.json file{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": ">=7.0.0", "adamwathan/eloquent-oauth-l5": "^0.5.2", "barryvdh/laravel-debugbar": "^3.1", "fideloper/proxy": "~3.3", "graham-campbell/markdown": "^9.0", "greggilbert/recaptcha": "^2.2", "guzzlehttp/guzzle": "^6.3", "laravel/framework": "5.5.*", "laravel/tinker": "~1.0", "paypal/rest-api-sdk-php": "*", "unicodeveloper/laravel-paystack": "^1.0" }, "require-dev": { "filp/whoops": "~2.0", "fzaninotto/faker": "~1.4", "mockery/mockery": "~1.0", "phpunit/phpunit": "~6.0" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\\": "app/", "Meow\\Halum\\": "vendor/meow/halum/src" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "extra": { "laravel": { "dont-discover": [ ] } }, "scripts": { "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true } } s



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2EMVTUa
via IFTTT

Laravel - Get data by Month and sum it (varchar)

I´ve seen similiar questions but honestly i didn´t see anything that could take me to the right way and that´s because i´m also looking for a better way of doing this.

At certain point in my app i´m using chartjs, where i need to show months and then the values(sales). For that i know(or i think) i have to retrieve data group by months, and i got here so far:

$records = TabelaAngariacao::select('preco', 'created_at')->where('estado', '=', 'Vendido')
            ->get()
            ->groupBy(function($date) {

                return Carbon::parse($date->created_at)->format('m');
            });

Well...as you can see, i´m not SUMING anything, and that´s because in my database my values are getting stored in varchar(with dot´s!) and i know that´s not the proper way of doing things, but at this point changing everything it´s not a solution for me right now, so how could i change that function in order to remove the dot´s and do a proper sum? i have tried using CAST but it´s giving me undefinied function.

Any suggestions? Thanks for your time, regards.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2ESqK2i
via IFTTT

Laravel with Oracle

I'm trying to connect oracle 10g XE with laravel 5.7 for checking connection I'm using the following code

<?php
try {
DB::connection()->getPdo();
print_r('connected');
} catch (\Exception $e) {
echo '<pre>';
    die("Could not connect to the database.  Please check your configuration. error:" . $e );
}
?>

I'm facing following error

Please check your configuration. error:Yajra\Pdo\Oci8\Exceptions\Oci8Exception: ORA-00000: normal, successful completion in \laravelOracle\vendor\yajra\laravel-pdo-via-oci8\src\Pdo\Oci8.php:464

following are my .env configuration for Oracle

DB_CONNECTION=oracle
DB_HOST=127.0.0.1
DB_PORT=1521
DB_DATABASE=XE
DB_USERNAME=admin
DB_PASSWORD=admin
DB_CHARSET=AL16UTF16
DB_SERVER_VERSION=10.2



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Sox1Ww
via IFTTT