mardi 28 mai 2019

Vuejs component not showing in my laravel blade

I am using laravel and vue and it is unable to load components into blade page. It showing empty.

I have tried many solutions but doesn't work.

welcome.blade

<!doctype html>
<html lang="">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
 <meta name="csrf-token" content="">
 <script>window.Laravel = { csrfToken: '' }</script>
    <title>App</title>

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css? family=Nunito:200,600" rel="stylesheet">  
</head>
<body>
<script type="text/javascripts" src="js/app.js"></script>
    <div id ="app">
    <div class="container">
    <articles></articles>
    </div> 
    </div>    
    </body>
    </html>

Articles.vue

<template>
<div>
<h2>Articles</h2>
</div>
</template>

App.js

/** * First we will load all of this project's JavaScript dependencies which * includes Vue and other libraries. It is a great starting point when * building robust, powerful web applications using Vue and Laravel. */

    require('./bootstrap');

import articles from './components/Articles'
    window.Vue = require('vue');

/** * The following block of code may be used to automatically register your * Vue components. It will recursively scan this directory for the Vue * components and automatically register them with their "basename". * */

Eg. ./components/ExampleComponent.vue -> <example-component></example-component>

 const files = require.context('./', true, /\.vue$/i);
 files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));

/** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */

Vue.component('articles', require('./components/Articles.vue'));

const app = new Vue({
el: '#app',
});

Composer.json

  "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.8.*",
        "laravel/tinker": "^1.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^7.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

I was expecting to see Articles as h2 but it shows nothing and when I inspect element I see this error

"Uncaught TypeError: Vue.components is not a function".

Any help will be appreciated.



via Chebli Mohamed

I want if user register successfully then user will come next time the registration will not be show for that user

Can you read my question let me know the solution on that.

I want if user register successfully then user will come next time the registration will not be show for that user.

Please help me to solve this issue.

Thank you.



via Chebli Mohamed

lundi 27 mai 2019

I have uploaded the pdf file and when clicked on website on link it's showing file not found

I am trying to click and open my pdf file on website that I have uploaded from admin , but it's showing not found 404

view

    <div class="entry-content">

   <a  target="_blank" href="">

   <p style="font-size: 18px;color: #468b10;"> 

    </p></a>

                                    </div>

Controller

         if (request('file')) {

        $file = request('file');

        $file=$file_name::get($file);

        $file_name = time() . $file->getClientOriginalName();

        $file->move('uploads/posts', $file_name);

        $data['file'] = 'uploads/posts/'.$file_name;
    }



via Chebli Mohamed

lundi 20 mai 2019

"Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP)" kn laravel

When I am trying to update the file then getting error like "Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP)" kn laravel

public function update(Request $request, $id) {

    $this->validate($request,[

        'name'=>'required',
        'designation'=>'required',
        'contact_ph'=>'required',
        'contact_email'=>'required',
        'featured'=>'mimes:jpeg,pdf,docx,png:5000',
    ]);

    $staff=Staff::find($id);

    if($request->hasFile('featured'))

    {
        $featured=$request->featured;
        $featured_new_name =time() .$featured->getClientOriginalName();
        $featured->move('uploads/srcpost', $featured_new_name);
        $staff->featured='uploads/srcposts/'. $featured_new_name;

    }

    $staff->name=$request=name;
    $staff->designation=$request=designation;
    $staff->ordering=$request=ordering;

    $staff->save();

    return redirect()->back();




}



via Chebli Mohamed

mardi 14 mai 2019

'Call to a member function paginate() on array' Error occurred for multiple join tables

Laravel query builder needs to paginate from multiple join tables.

I've tried many ways to paginate this query. But nothing.

Controller.php

$ord_heds = DB::select('select d.family, d.category, d.product_img, d.ord_ref, m.min_qty, m.max_qty, t.qty, t.value, SUM(replace(d.value,",","")) as ordval, SUM(replace(d.qty,",","")) as Tord_qty, COUNT(d.qty) as no_of_items_ordered, (select COUNT(itemCode) as mcount from item_statuses where '.'s'.$siteG.' ="'.$site.'" and itemCode in (select itemCode FROM items WHERE category=d.category and brand=d.family)) as manCount, (select COUNT(itemCode) as mcount1 from item_statuses where '.'s'.$siteG.' ="'.$site.'" and itemCode in (select itemCode FROM items WHERE category=d.category and brand=d.family and itemCode in (select itemcode FROM ord_dets where ord_dets.site = "'.$ordSite.'"))) as ordManCount FROM ord_dets d JOIN ord__heds h ON d.ord_ref = h.id INNER JOIN min__maxes m ON d.category = m.category AND d.site = m.site AND d.scode = m.season INNER JOIN targets t ON d.category = t.category AND d.family = t.brand AND d.month = t.month AND d.year = t.year AND d.site = t.site WHERE h.month = "'.$date[1].'" AND h.year = "'.$date[0].'" AND h.site = "'.$ordSite.'" GROUP BY d.family, d.category, d.product_img, d.ord_ref, m.min_qty, m.max_qty, t.qty, t.value');

$pag = $ord_heds->paginate(10);

dd($pag);

Above code result an error 'FatalThrowableError Call to a member function paginate() on array'.

Kindly appreciated in quick response.



via Chebli Mohamed

Laravel: Microsoft Single Sign On

I am working on an app with laravel 5.1 and added Google Single Sign On and it's working correctly but I also want to implement Microsoft Single Sign On and till now can not find any way.



via Chebli Mohamed

lundi 13 mai 2019

query builder with pagination in laravel frame work

i'm new in laravel and i have problem i want to make pagination with this query and at same time i want return data in array no in object can any one help me

this is my helper

public static function allData($Tablename,$Condition="",$data="")
        {


            $stattment = DB::table($Tablename)
                ->whereRaw(''.$Condition.'', $data)
                ->get()->toArray()
                ->paginate(1);



            return $stattment;

}

this is my controller

enter code here
    public function getall()
        {

   $dataView['products']=Helper::allData('products','`status`=? AND `deleted`=?',array(1,1));
            return view('productss.getall',$dataView);
        }



via Chebli Mohamed

laravel SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `sessions` where `id` =

I have uploaded working code to live site without changing anything.

but I am getting follow error.

SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from sessions where id = dgbEmZ9AufF9UD9GG8X7kkeUxLlppZ1Z37UHQbHd limit 1)

Session table is present and it is empty.

I am using laravel 5.x version.

error logs

[2019-05-13 11:08:31] local.ERROR: SQLSTATE[HY000] [2002] No such file or directory {"exception":"[object] (Doctrine\\DBAL\\Driver\\PDOException(code: 2002): 
SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, 
SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)
[stacktrace]
#0 /Database/Connectors/Connector.php(64): Doctrine\\DBAL\\Driver\\PDOConnection->__construct('mysql:host=loca...', 'root', 'root', Array)
#1 /Database/Connectors/Connector.php(43): Illuminate\\Database\\Connectors\\Connector->createPdoConnection('mysql:host=loca...', 'root', 'root', Array)
#2 /Database/Connectors/MySqlConnector.php(24): Illuminate\\Database\\Connectors\\Connector->createConnection('mysql:host=loca...', Array, Array)
#3 /Database/Connectors/ConnectionFactory.php(183): Illuminate\\Database\\Connectors\\MySqlConnector->connect(Array)
#4 [internal function]: Illuminate\\Database\\Connectors\\ConnectionFactory->Illuminate\\Database\\Connectors\\{closure}()
#5 /Database/Connection.php(915): call_user_func(Object(Closure))
#6 /Database/Connection.php(940): Illuminate\\Database\\Connection->getPdo()
#7 /Database/Connection.php(399): Illuminate\\Database\\Connection->getReadPdo()
#8 /Database/Connection.php(325): Illuminate\\Database\\Connection->getPdoForSelect(true)
#9 /Database/Connection.php(657): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select * from `...', Array)
#10 /Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#11 /Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from `...', Array, Object(Closure))
#12 /Database/Query/Builder.php(1719): Illuminate\\Database\\Connection->select('select * from `...', Array, true)
#13 /Database/Query/Builder.php(1704): Illuminate\\Database\\Query\\Builder->runSelect()
#14 /Database/Concerns/BuildsQueries.php(77): Illuminate\\Database\\Query\\Builder->get(Array)
#15 /Database/Query/Builder.php(1674): Illuminate\\Database\\Query\\Builder->first(Array)
#16 /Session/DatabaseSessionHandler.php(91): Illuminate\\Database\\Query\\Builder->find('dgbEmZ9AufF9UD9...')
#17 /Session/Store.php(96): Illuminate\\Session\\DatabaseSessionHandler->read('dgbEmZ9AufF9UD9...')
#18 /Session/Store.php(86): Illuminate\\Session\\Store->readFromHandler()
#19 /Session/Store.php(70): Illuminate\\Session\\Store->loadSession()
#20 /Session/Middleware/StartSession.php(102): Illuminate\\Session\\Store->start()
#21 /Support/helpers.php(1038): Illuminate\\Session\\Middleware\\StartSession->Illuminate\\Session\\Middleware\\{closure}(Object(Illuminate\\Session\\Store))
#22 /Session/Middleware/StartSession.php(103): tap(Object(Illuminate\\Session\\Store), Object(Closure))
#23 /Session/Middleware/StartSession.php(57): Illuminate\\Session\\Middleware\\StartSession->startSession(Object(Illuminate\\Http\\Request))
#24 /Pipeline/Pipeline.php(149): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 /Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#27 /Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#28 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#29 /Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#30 /Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#33 /Routing/Router.php(660): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#34 /Routing/Router.php(635): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#35 /Routing/Router.php(601): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#36 /Routing/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#37 /Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#38 /Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#39 /questionnaire/questionnaire/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#40 /Pipeline/Pipeline.php(149): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#41 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#42 /questionnaire/questionnaire/vendor/fideloper/proxy/src/TrustProxies.php(56): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#43 /Pipeline/Pipeline.php(149): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#45 /Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#46 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#47 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#48 /Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#49 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#50 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#51 /Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#52 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#53 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#54 /Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#55 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#56 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#57 /Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#58 /Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#59 /Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#60 /questionnaire/questionnaire/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#61 {main}
"} 
[2019-05-13 11:08:31] local.ERROR: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `sessions` where `id` = dgbEmZ9AufF9UD9GG8X7kkeUxLlppZ1Z37UHQbHd limit 1) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `sessions` where `id` = dgbEmZ9AufF9UD9GG8X7kkeUxLlppZ1Z37UHQbHd limit 1) at /Database/Connection.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)
[stacktrace]
#0 /Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#1 /Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from `...', Array, Object(Closure))
#2 /Database/Query/Builder.php(1719): Illuminate\\Database\\Connection->select('select * from `...', Array, true)
#3 /Database/Query/Builder.php(1704): Illuminate\\Database\\Query\\Builder->runSelect()
#4 /Database/Concerns/BuildsQueries.php(77): Illuminate\\Database\\Query\\Builder->get(Array)
#5 /Database/Query/Builder.php(1674): Illuminate\\Database\\Query\\Builder->first(Array)
#6 /Session/DatabaseSessionHandler.php(91): Illuminate\\Database\\Query\\Builder->find('dgbEmZ9AufF9UD9...')
#7 /Session/Store.php(96): Illuminate\\Session\\DatabaseSessionHandler->read('dgbEmZ9AufF9UD9...')
#8 /Session/Store.php(86): Illuminate\\Session\\Store->readFromHandler()
#9 /Session/Store.php(70): Illuminate\\Session\\Store->loadSession()
#10 /Session/Middleware/StartSession.php(102): Illuminate\\Session\\Store->start()
#11 /Support/helpers.php(1038): Illuminate\\Session\\Middleware\\StartSession->Illuminate\\Session\\Middleware\\{closure}(Object(Illuminate\\Session\\Store))
#12 /Session/Middleware/StartSession.php(103): tap(Object(Illuminate\\Session\\Store), Object(Closure))
#13 /Session/Middleware/StartSession.php(57): Illuminate\\Session\\Middleware\\StartSession->startSession(Object(Illuminate\\Http\\Request))
#14 /Pipeline/Pipeline.php(149): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#15 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#16 /Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#17 /Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#18 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#19 /Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#20 /Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 /Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#23 /Routing/Router.php(660): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#24 /Routing/Router.php(635): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#25 /Routing/Router.php(601): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#26 /Routing/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#27 /Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#28 /Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#29 /questionnaire/questionnaire/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#30 /Pipeline/Pipeline.php(149): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /questionnaire/questionnaire/vendor/fideloper/proxy/src/TrustProxies.php(56): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#33 /Pipeline/Pipeline.php(149): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#34 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#35 /Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#36 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#37 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#38 /Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#39 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#40 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#41 /Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#42 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#43 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#44 /Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#45 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#46 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#47 /Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#48 /Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#49 /Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#50 /questionnaire/questionnaire/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#51 {main}
"} 
[2019-05-13 11:08:31] local.ERROR: SQLSTATE[HY000] [2002] No such file or directory {"exception":"[object] (Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)
[stacktrace]
#0 /Database/Connectors/Connector.php(64): Doctrine\\DBAL\\Driver\\PDOConnection->__construct('mysql:host=loca...', 'root', 'root', Array)
#1 /Database/Connectors/Connector.php(43): Illuminate\\Database\\Connectors\\Connector->createPdoConnection('mysql:host=loca...', 'root', 'root', Array)
#2 /Database/Connectors/MySqlConnector.php(24): Illuminate\\Database\\Connectors\\Connector->createConnection('mysql:host=loca...', Array, Array)
#3 /Database/Connectors/ConnectionFactory.php(183): Illuminate\\Database\\Connectors\\MySqlConnector->connect(Array)
#4 [internal function]: Illuminate\\Database\\Connectors\\ConnectionFactory->Illuminate\\Database\\Connectors\\{closure}()
#5 /Database/Connection.php(915): call_user_func(Object(Closure))
#6 /Database/Connection.php(940): Illuminate\\Database\\Connection->getPdo()
#7 /Database/Connection.php(399): Illuminate\\Database\\Connection->getReadPdo()
#8 /Database/Connection.php(325): Illuminate\\Database\\Connection->getPdoForSelect(true)
#9 /Database/Connection.php(657): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select * from `...', Array)
#10 /Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#11 /Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from `...', Array, Object(Closure))
#12 /Database/Query/Builder.php(1719): Illuminate\\Database\\Connection->select('select * from `...', Array, true)
#13 /Database/Query/Builder.php(1704): Illuminate\\Database\\Query\\Builder->runSelect()
#14 /Database/Concerns/BuildsQueries.php(77): Illuminate\\Database\\Query\\Builder->get(Array)
#15 /Database/Query/Builder.php(1674): Illuminate\\Database\\Query\\Builder->first(Array)
#16 /Session/DatabaseSessionHandler.php(91): Illuminate\\Database\\Query\\Builder->find('dgbEmZ9AufF9UD9...')
#17 /Session/Store.php(96): Illuminate\\Session\\DatabaseSessionHandler->read('dgbEmZ9AufF9UD9...')
#18 /Session/Store.php(86): Illuminate\\Session\\Store->readFromHandler()
#19 /Session/Store.php(70): Illuminate\\Session\\Store->loadSession()
#20 /Support/Manager.php(138): Illuminate\\Session\\Store->start()
#21 /questionnaire/questionnaire/vendor/barryvdh/laravel-debugbar/src/SymfonyHttpDriver.php(42): Illuminate\\Support\\Manager->__call('start', Array)
#22 /questionnaire/questionnaire/vendor/maximebf/debugbar/src/DebugBar/DebugBar.php(446): Barryvdh\\Debugbar\\SymfonyHttpDriver->isSessionStarted()
#23 /questionnaire/questionnaire/vendor/maximebf/debugbar/src/DebugBar/DebugBar.php(359): DebugBar\\DebugBar->initStackSession()
#24 /questionnaire/questionnaire/vendor/maximebf/debugbar/src/DebugBar/JavascriptRenderer.php(984): DebugBar\\DebugBar->hasStackedData()
#25 /questionnaire/questionnaire/vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(850): DebugBar\\JavascriptRenderer->render()
#26 /questionnaire/questionnaire/vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(735): Barryvdh\\Debugbar\\LaravelDebugbar->injectDebugbar(Object(Illuminate\\Http\\Response))
#27 /questionnaire/questionnaire/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(74): Barryvdh\\Debugbar\\LaravelDebugbar->modifyResponse(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#28 /Pipeline/Pipeline.php(149): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /questionnaire/questionnaire/vendor/fideloper/proxy/src/TrustProxies.php(56): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#31 /Pipeline/Pipeline.php(149): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 /Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#34 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#37 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#38 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 /Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#40 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#41 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#42 /Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#43 /Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 /Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#45 /Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#46 /Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#47 /Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#48 /questionnaire/questionnaire/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#49 {main}
"} 
[2019-05-13 11:08:31] local.ERROR: Debugbar exception: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `sessions` where `id` = dgbEmZ9AufF9UD9GG8X7kkeUxLlppZ1Z37UHQbHd limit 1)  
[2019-05-13 11:08:31] local.ERROR: SQLSTATE[HY000] [2002] No such file or directory {"exception":"[object] (Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)
[stacktrace]
#0 /Database/Connectors/Connector.php(64): Doctrine\\DBAL\\Driver\\PDOConnection->__construct('mysql:host=loca...', 'root', 'root', Array)
#1 /Database/Connectors/Connector.php(43): Illuminate\\Database\\Connectors\\Connector->createPdoConnection('mysql:host=loca...', 'root', 'root', Array)
#2 /Database/Connectors/MySqlConnector.php(24): Illuminate\\Database\\Connectors\\Connector->createConnection('mysql:host=loca...', Array, Array)
#3 /Database/Connectors/ConnectionFactory.php(183): Illuminate\\Database\\Connectors\\MySqlConnector->connect(Array)
#4 [internal function]: Illuminate\\Database\\Connectors\\ConnectionFactory->Illuminate\\Database\\Connectors\\{closure}()
#5 /Database/Connection.php(915): call_user_func(Object(Closure))
#6 /Database/Connection.php(940): Illuminate\\Database\\Connection->getPdo()
#7 /Database/Connection.php(399): Illuminate\\Database\\Connection->getReadPdo()
#8 /Database/Connection.php(325): Illuminate\\Database\\Connection->getPdoForSelect(true)
#9 /Database/Connection.php(657): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select * from `...', Array)
#10 /Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#11 /Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from `...', Array, Object(Closure))
#12 /Database/Query/Builder.php(1719): Illuminate\\Database\\Connection->select('select * from `...', Array, true)
#13 /Database/Query/Builder.php(1704): Illuminate\\Database\\Query\\Builder->runSelect()
#14 /Database/Concerns/BuildsQueries.php(77): Illuminate\\Database\\Query\\Builder->get(Array)
#15 /Database/Query/Builder.php(1674): Illuminate\\Database\\Query\\Builder->first(Array)
#16 /Session/DatabaseSessionHandler.php(91): Illuminate\\Database\\Query\\Builder->find('dgbEmZ9AufF9UD9...')
#17 /Session/DatabaseSessionHandler.php(128): Illuminate\\Session\\DatabaseSessionHandler->read('dgbEmZ9AufF9UD9...')
#18 /Session/Store.php(128): Illuminate\\Session\\DatabaseSessionHandler->write('dgbEmZ9AufF9UD9...', 'a:1:{s:6:\"_flas...')
#19 /Session/Middleware/StartSession.php(87): Illuminate\\Session\\Store->save()
#20 /Foundation/Http/Kernel.php(218): Illuminate\\Session\\Middleware\\StartSession->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#21 /Foundation/Http/Kernel.php(189): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#22 /questionnaire/questionnaire/public/index.php(58): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#23 {main}
"} 
[2019-05-13 11:08:31] local.ERROR: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `sessions` where `id` = dgbEmZ9AufF9UD9GG8X7kkeUxLlppZ1Z37UHQbHd limit 1) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `sessions` where `id` = dgbEmZ9AufF9UD9GG8X7kkeUxLlppZ1Z37UHQbHd limit 1) at /Database/Connection.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /questionnaire/questionnaire/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)
[stacktrace]
#0 /Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#1 /Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from `...', Array, Object(Closure))
#2 /Database/Query/Builder.php(1719): Illuminate\\Database\\Connection->select('select * from `...', Array, true)
#3 /Database/Query/Builder.php(1704): Illuminate\\Database\\Query\\Builder->runSelect()
#4 /Database/Concerns/BuildsQueries.php(77): Illuminate\\Database\\Query\\Builder->get(Array)
#5 /Database/Query/Builder.php(1674): Illuminate\\Database\\Query\\Builder->first(Array)
#6 /Session/DatabaseSessionHandler.php(91): Illuminate\\Database\\Query\\Builder->find('dgbEmZ9AufF9UD9...')
#7 /Session/DatabaseSessionHandler.php(128): Illuminate\\Session\\DatabaseSessionHandler->read('dgbEmZ9AufF9UD9...')
#8 /Session/Store.php(128): Illuminate\\Session\\DatabaseSessionHandler->write('dgbEmZ9AufF9UD9...', 'a:1:{s:6:\"_flas...')
#9 /Session/Middleware/StartSession.php(87): Illuminate\\Session\\Store->save()
#10 /Foundation/Http/Kernel.php(218): Illuminate\\Session\\Middleware\\StartSession->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#11 /Foundation/Http/Kernel.php(189): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#12 /questionnaire/questionnaire/public/index.php(58): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#13 {main}
"} 



via Chebli Mohamed

I have some issue with my code when getting data dynamically using ajax script laravel

I'm working on a project i need a load more button i tried the following code but i think something is wrong.

there is a load more button on click see all some more results should display. on click see all it calls the controller method but i think i am not able to post data to controller method what wil i get from ajax response.

here following is my code which i tried.

View

<div class="form-group border-bottom pb-3">
                <label for="usr" class="f-14 bold black">Manufacturers</label>

                <div class="pl-md-4 pl-2">
                    
                    <label class=" my-checkbox gry2">Show All Manufacturers
                        <input type="checkbox">
                        <span class="checkmark"></span>
                    </label>
                    @if(count($leedManufacturers) > 0 )
                    @foreach($leedManufacturers as $leedsManufacturer)
                    

                    <label class=" my-checkbox gry2" id="manufacturer">
                            <input type="checkbox">
                            <span class="checkmark"></span>
                        </label>
                        
                    

                    "> --}}
                    @endforeach
                    @endif

                    <a class="load-more" id="load" href="#" class="f-14 bold">See All</a>

                    <input type="hidden" id="row" value="0">
                    <input type="hidden" id="all" value="">


                </div>
            </div>

Script

 <script type="text/javascript">
        $(document).ready(function(){

        // Load more data
        $('.load-more').click(function(){
            var row = Number($('#row').val());
            var allcount = Number($('#all').val());
            var rowperpage = 3;
            row = row + rowperpage;

            if(row <= allcount){
                $("#row").val(row);

                $.ajax({
                    url: "",
                    type: 'post',
                    data: {row:row},

                    success: function(data){

                        alert(data);

                    }


                });

            }else{

                console.log('if is not working');



            }

        });

        });
</script>

Controller:

public function colabrativetwo(Request $request, $slug = 0, $division_id = 0, $section_id = 0, $manufacturer_id = 0, $list=""){

$row = $request->row;
      $manufacturersFeatured = Product::select('manufacturers.id AS id', 'manufacturers.name AS name', DB::raw('COUNT(DISTINCT products.id) as products_count'))
                ->whereIn('products.status', ['active'])
                ->where(function ($query) {
                    $query->where('products.low_emitting_material_prerequisite_file', '!=', '');
                })
                ->where('users.user_type', 'manufacturer_paid')
                ->leftJoin('products_selected_leeds', 'products.id', '=', 'products_selected_leeds.product_id')
                ->leftJoin('sections', 'products.section_id', '=', 'sections.id')
                ->leftJoin('divisions', 'products.division_id', '=', 'divisions.id')
                ->join('manufacturers', 'products.manufacturer_id', '=', 'manufacturers.id')
                ->join('users', 'manufacturers.user_id', '=', 'users.id')
                ->orderBy('name', 'asc')
                ->groupBy('manufacturers.id')
                ->limit($row)
                ->get();


 return view('guest::new_design_frontend.product-library', $manufacturersFeatured);}



via Chebli Mohamed

mercredi 8 mai 2019

Queued jobs occasionally repeating themselves Laravel Beanstalkd

Occasionally, if one job is stuck on the queue behind a long-running job, it seems to be picked up/attempted multiple times which is leading to repeat emails going out. I've reduced the size of each job and added multiple queues in order to speed jobs being dispatched up. I believe that I should add $job->delete() somewhere, but not sure where it should be.

I've created multiple queues and chunked up jobs being passed along in order to make sure that no processes are running too long or holding other processes up.

Here is what my *.conf file looks like (supervisord)

[program:lorem]
process_name=%(program_name)s_%(process_num)02d
command=php artisan queue:listen --queue=high,medium,low --sleep=30 --tries=1 --timeout=3600
directory=/var/www/html/lorem
autostart=true
autorestart=true
numprocs=6
redirect_stderr=true
stdout_logfile=/var/www/html/lorem/storage/logs/ipsum.log

and here is an example of where I dispatch a job to the queue:

    foreach ($users->chunk(100) as $chunkUser)
    {
        $job = (new InviteVendors($request, $chunkUser))->onQueue('high');
        app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($job);
    }


    $emailAgent = (new EmailAgentPostInvite($request))->onQueue('invitequeue');
    app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($emailAgent);

If I call $job->delete() after it is dispatched will it make sure that the job is not picked up multiple times? If not, where should I attempt to delete the job?



via Chebli Mohamed

lundi 6 mai 2019

Unable to send a notification in Laravel

I'm not able to send a notification in Laravel. How should i do to resolve this error ?

Call to undefined method Illuminate\Database\Query\Builder::routeNotificationFor()

in Builder.php line 2123
at Builder->__call('routeNotificationFor', array('WebPush'))
at call_user_func_array(array(object(Builder), 'routeNotificationFor'), array('WebPush')) in Builder.php line 1015
at Builder->__call('routeNotificationFor', array('WebPush')) in WebPushChannel.php line 31
at WebPushChannel->send(object(Builder), object(PushDemo)) in ChannelManager.php line 77
at ChannelManager->sendNow(array(object(Builder)), object(PushDemo)) in ChannelManager.php line 43
at ChannelManager->send(array(object(Builder)), object(PushDemo)) in Facade.php line 217
at Facade::__callStatic('send', array(object(Builder), object(PushDemo))) in PushController.php line 36

My environment is a bit special : I'm building a PWA on Laravel 5.1

Notification backport with : laravel-notification-channels/backport

Webpush : laravel-notification-channels/webpush

I tried Notification facade and also user->notify()

My service worker works, manifest json is ok.

PushController :

    public function store(Request $request){
        $this->validate($request,[
            'endpoint'    => 'required',
            'keys.auth'   => 'required',
            'keys.p256dh' => 'required'
        ]);
        $endpoint = $request->endpoint;
        $token = $request->keys['auth'];
        $key = $request->keys['p256dh'];
        $user = Auth::user();
        $user->updatePushSubscription($endpoint, $key, $token);

        return response()->json(['success' => true],200);
    }

    public function push2(){
        Notification::send(User::all(),new PushDemo);
        return redirect()->back();
    }
    /**
     * Send Push Notification
     *
     * @return \Illuminate\Http\Response
     */
    public function push($id, Request $request){
//        Notification::send(User::all(),new PushDemo);
//        return redirect()->back();
        $user = User::findOrFail($id);
        $user->notify(new PushDemo());
        return redirect()->back();
    }

PushDemo extends Notification :

 public function via($notifiable)
    {
        return [WebPushChannel::class];
    }

public function toWebPush($notifiable, $notification)
    {
        return (new WebPushMessage)
            ->title('Hi dude')
            ->icon('images/icons/izzy-icon-192x192.png')
            ->body('Great, Push Notifications work!')
            ->action('View App', 'notification_action');

    }

User :

use Notifiable;
use HasPushSubscriptions;

Not able to send a notification, everytime getting 5xx errors. Did i miss anything ?



via Chebli Mohamed

samedi 4 mai 2019

login with one paremeter in laravel

I want to make a login in a laravel that receives only one parameter, ie has a simple form that receives one input, and based on that input, user is authenticated.(if user is admin got to /adminpage if user is regular user go to /homepage)

So I want to use custom table, model and controller.

I searched the internet but could not find a solution.



via Chebli Mohamed