Wednesday, 26 April 2017

How to create helper in laravel?

Basically there are there steps.

Step 1:    Within your app/Libraries directory, create a Helpers.php file and add your functions.
Step 2:    Within composer.json, in the autoload block, add "files": ["app/Libraries/helpers.php"].
Step 3:    Run composer update.
Step 4:    Showing the content. 
Helpers.php
<?php
    function notification_count()
    {
        $user_loggedin = Auth::user();
        $id = $user_loggedin->id;  
        $sql =  DB::table('notification')
                ->where('read_status', 0)
                ->where('user_id',$id)
                ->count('read_status');
    echo $sql;                            
    } 
?>

composer.json

"files": [
        "app/Libraries/Helpers.php"
        ],   
       
Showing the content
 <span class="badge" style="color:#FFFFFF !important;">{{ notification_count() }}</span> <i class="fa fa-caret-down"></i></a>

No comments:

Post a Comment

Machine Learning - Potato Leaf Disease Prediction

Step 1: import numpy as np import pandas as pd import splitfolders import matplotlib.pyplot as plt import tensorflow as tf from tensorflow i...