kshitizmittal

kshitizmittal

Member Since 9 Months Ago

Experience Points 3,670
Experience Level 1

1,330 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

24 Jun
1 day ago

kshitizmittal started a new conversation CRON Job On Production Server

Our application is deployed on a server based in UTC timezone, but the application's native timezone is 'Asia/Kolkata' and in kernel.php i have written a cron job ->cron(0,0,*,*,*) , and on production server a command php artisan schedule:run is scheduled at 5:30 UTC.

Which always shows no scheduled tasks to run.

How can I solve this issue.

30 May
3 weeks ago

kshitizmittal left a reply on Chart Js Change Axes Type

@JOHNBRAUN - How do I apply these change in controller ?

28 May
4 weeks ago

kshitizmittal started a new conversation Chart Js Change Axes Type

I need to change the y-axis as time in format of hh:mm:ss Below is the controller code in which $avg_efficiency_data->values() is in time format.

$efficiencyChart = new SampleChart;
        $efficiencyChart->labels($avg_efficiency_data->keys());
        $efficiencyChart->dataset('Efficiency Avg', 'line', $avg_efficiency_data->values())->options(['backgroundColor' => '#A569BD', 'fill' => false, 'borderColor' => '#A569BD']);

Package used is :- https://charts.erik.cat/supported_libraries.html#chartjs-2-7-1

Please help.

21 May
1 month ago

kshitizmittal started a new conversation Memory Error Because Of Telescope Package

When I try to fetch large amount of data on my blade page. following error restricts me to do so.

Error :- "Allowed memory size of 268435456 bytes exhausted (tried to allocate 54530048 bytes)"```

I feel this is because of telescope package. 

How to remove telescope package?
16 May
1 month ago

kshitizmittal started a new conversation Fetch Model Attributes In Yajra Datatable

I need to fetch custom model attribute in Yajra datatable, also there are custom attributes in relationship also which I need to fetch in datatable.

I have one attendance_status custom attribute in AttendanceReport.

And one full_name custom attribute in Employeedetail model which I am fetching here in with() function.

This is controller code :-

public function serverSide(){
        $attendacereport = AttendanceReport::whereRaw("emp_id='710102'")->with('employeedetail.departments','employeedetail.designations')->->select(['emp_id','punch_in','punch_out','attendance_status'])get();

        return Datatables::of($attendacereport)->make();
    }

Datatble Script :-

<script>
    $(document).ready(function() {
        $('.datatable').DataTable({
            processing: true,
            serverSide: true,
            pageLength: 100,
            ajax: '{{ url('serverSide') }}',
            initComplete:function( settings, json){
                console.log(json.data);
                // call your function here
            },
            columns: [
                { data: 'emp_id', name: 'emp_id' },
                { data: 'employeedetail.full_name' , name: 'employeedetail.full_name' },
                { data: 'punch_in', name: 'punch_in' },
                { data: 'punch_out', name: 'punch_out' },
                { data: 'attendance_status', name: 'attendance_status' }
                
            ]
        });
    });
</script>
15 Apr
2 months ago

kshitizmittal started a new conversation Fetch Array From Import Source In Chunks

Excel::load(Input::file('import_file'), function ($reader) {
                foreach ($reader->toArray() as $row) {
                    Roster::updateOrCreate(['emp_id'=> $row['emp_id'],'month'=> $row['month'],'year'=> $row['year']],$row);
                    $month_name = $row['month'];
                    $wo_arr = explode(',',$row['week_off']);
                    $daily_roster_arr = [];
                    for($i=1;$i<=cal_days_in_month(CAL_GREGORIAN, date('m', strtotime($month_name)), $row['year']);$i++){
                        $date = date('Y-m-d', strtotime($i.' '.$row['month'].' '.$row['year']));
                        $day = date('l', strtotime($i.' '.$row['month'].' '.$row['year']));

                        $daily_roster_arr['emp_id'] = $row['emp_id'];
                        $daily_roster_arr['time_in'] = $row['roster_time_in'];
                        $daily_roster_arr['time_out'] = $row['roster_time_off'];
                        $daily_roster_arr['date'] = $date;
                        $daily_roster_arr['day'] = $day;
                        $daily_roster_arr['week_off'] = (in_array($day, $wo_arr) ? 'Yes' : NULL);
                        DailyRoster::updateOrCreate(['emp_id'=> $daily_roster_arr['emp_id'],'date'=> $daily_roster_arr['date']],$daily_roster_arr);
                    }
                }
            });

This is my import function, I am trying top import more than 50000 records so it is showing 500 server error in spite of increasing execution time in php.ini file.

How can I fetch $rows in chunks?

Using Maatwebsite import package.

12 Apr
2 months ago

kshitizmittal started a new conversation Scoping Of Variable

if(date('m')>=4){
            $start_year = date('Y');
            $end_year = date('Y')+1;
        } else {
            $start_year = date('Y')-1;
            $end_year = date('Y');
        }
        
        $taxsavings = Taxsaving::with([
            'assignTaxSaving' => function($query) {
                $query->where(['emp_id'=>Auth::user()->emp_id,'start_year'=>$start_year,'end_year'=>$end_year])->where();    
            },
        ])->get();

Facing Error :- "Undefined variable: start_year"

Please help to resolve this.

03 Apr
2 months ago

kshitizmittal started a new conversation Eloquent Select() Method

Controller Code :-

$attendanceReport = AttendanceReport::with('employeedetail')->select('date','emp_id','punch_in','punch_out');
        
return datatables($attendanceReport)->make(true);

Blade Code :-

<table id="datatables" class="display" style="width:100%">
                        <thead>
                            <tr>
                                <th>{{'Employee ID'}}</th>
                                <th>{{'Employee Name'}}</th>
                                <th>{{'Supervisor'}}</th>
                                <th>{{'Department Name'}}</th>
                                <th>{{'Date'}}</th>
                                <th>{{'In Time'}}</th>
                                <th>{{'Out Time'}}</th>
                                <th>{{'Status'}}</th>                          
                                <th>{{'Total Hours'}}</th>
                            </tr>
                        </thead>
                        <tbody>
                           
                        </tbody>
                    </table>
<script>
        $(document).ready( function () {
            $('#datatables').DataTable({
                "processing": true,
                "serverSide": true,
                "pageLength":100,
                "ajax": "{{ url('manish') }}",
                "ajax": { 
                    "url" : "{{ url('xyxxxxxxx') }}",
                    success : function ( json ) {
                        //Make your callback here.
                        alert("Done!");
                        console.log(json.data);
                    }  
                },
                "columns": [
                    { "data": "emp_id" },
                    { "data": "first_name" },
                    { "data": "date" },
                    { "data": "date" },
                    { "data": "date" },
                    { "data": "punch_in" },
                    { "data": "punch_out" },
                    { "data": "date" },
                    { "data": "date" }
                ]
            });
        });
    </script>

I want to fetch employee name in the table which comes from employee detail relation in model.

01 Apr
2 months ago

kshitizmittal started a new conversation Add Event By Day Name Of Particular Month And Year In Fullcalendar Using Controller

I want to add event on each Tuesday of April 2019 using controller.

How I am adding events on a particular date.

$events[] = Calendar::event(
                        $value,
                        true,
                        new \DateTime($key),
                        new \DateTime($key),
                        true,
                        [
                            'color' => '#ffbf80',
                            'textColor' => '#000000',
                        ]
                    );

Please help me out !!!

29 Mar
2 months ago

kshitizmittal left a reply on How Do I Fetch Activity Log Data With Model Instance

@BOBBYBOUWMANN - Okay,

I have used Spatie activity logging package,

This is how I log Activity in this model,

use LogsActivity;

    protected $fillable = ['emp_id','timecard_id','time_punch_in','time_punch_out','total_working_hours','date','correction_punch_in','correction_punch_out','correction_hours', 'reason','status','comments','action_by'];

    protected static $logAttributes = ['emp_id','timecard_id','time_punch_in','time_punch_out','total_working_hours','date','correction_punch_in','correction_punch_out','correction_hours', 'reason', 'status','comments','action_by'];
    protected static $recordEvents = ['updated','created'];

Fields in activity_log table,

"`log_name`" 
"`description`"
"`subject_id`"
"`subject_type`"
"`causer_id`"
"`causer_type`"
"`properties`"
"`created_at`"
"`updated_at`"
28 Mar
2 months ago

kshitizmittal started a new conversation How Do I Fetch Activity Log Data With Model Instance

$timecardrequestreport= Timecardcorrection::all();

Want to fetch all data from activity log with this model for a particular id in model.

15 Mar
3 months ago

kshitizmittal left a reply on Laravel Select Dropdown Dropdown

@MANELGAVALDA - I tried this but problem is there are duplicate entries in array

kshitizmittal started a new conversation Laravel Select Dropdown Dropdown

$arrattendances=array( 'Regular' => 3,'Occasional'=>2,'Irregular' =>0, 'On Notice'=>0,'Inactive'=>0 )

I have this array and want want to pass in such a way that array value comes in option value and array key comes in option content.

Using this :-

{!! Form::select('attendance',[null=>'Select Attendance']+$arrattendances,null,["class"=>"form-control attendance","id"=>"attendance[]"]) !!}
11 Mar
3 months ago

kshitizmittal started a new conversation Add One Day To Date

$events[] = Calendar::event(
                    (@$activity->leavetypes->type_name ? @$activity->leavetypes->type_name : 'N/A'),
                    true,
                    new \DateTime($activity->start_date),
                    new \DateTime($activity->end_date),
                    true,
                    [
                        'color' => '#85e085',
                        'textColor' => '#008000',
                    ]
                );

I have to add 1 Day to end date because I need to counter a bug in fullcalendar which shows -1 day event length please help me.

07 Mar
3 months ago

kshitizmittal started a new conversation Connect Model Through MySql ViEW

Need to connect Model to MySql VIEW

kshitizmittal started a new conversation Month() In Multiple Join Conditions

$punchData = Employeedetail::join('punchreports',function($join){
                                            
$punchData = Employeedetail::join('punchreports',function($join){
                              $join->on("punchreports.emp_id","=","employeedetails.emp_id")
                                    ->on("MONTH('punchreports.date')","=",date('m'));
                          })->get();

Month() not fount error . How can I resolve this?

05 Mar
3 months ago

kshitizmittal started a new conversation Scoping Of Variable

foreach ($designations as $key => $value) {
            $count = $users->filter(function ($item)
            {
                return (@$item->designations->degname == $value);
            })->count();            
        }

I want to access the $value variable in the function inside filter function like :- Error Message :-

foreach ($designations as $key => $value) {
            $count = $users->filter(function ($item)
            {
                return (@$item->designations->degname == $value);
            })->count();            
        }

"Undefined variable: value"
04 Mar
3 months ago

kshitizmittal started a new conversation Database Notification Laravel 5.6

Trying to send database notification,

Route::get('/notify',function(){
    // $when = Carbon::now()->addseconds(10); 
    $user = Employeedetail::where('emp_id','710101')->first(); 
    // dd($user);
    $user->notify(new LeaveNotification);

    dd('sent');
});

Error Message :-

"Call to undefined method App\Employeedetail::notify()"

This is working fine with User::notify();

But I want to send notifiable type as App\Employeedetail in database and notifiable id as 7101401 which is employee ID in Employeedetail model and primary key as well.

20 Feb
4 months ago

kshitizmittal started a new conversation Raw Query To Eloquent Query Builer

I want to convert this raw query to eloquent, but it seems to be complex, please help me out.

select one.emp_id,one.date,one.punch_in,one.punch_out,two.type_code,two.start_date,two.end_date,three.week_off,three.month,three.year,four.holidaydate
from punchreports as one
left join (SELECT applyleaves.emp_id,leavetypes.type_code,applyleaves.start_date,applyleaves.end_date FROM applyleaves INNER JOIN leavetypes on applyleaves.leave_type_id = leavetypes.type_id) as two
on (one.emp_id = two.emp_id and (one.date >= two.start_date AND one.date <= two.end_date ))
LEFT JOIN rosters as three
on (one.emp_id = three.emp_id AND (DATE_FORMAT(one.date, "%M") = three.month AND DATE_FORMAT(one.date, "%Y") = three.year ))
LEFT JOIN (select assigntandas.emp_id,holidays.holidaydate from assigntandas INNER JOIN holidays on assigntandas.holiday_calendar = holidays.parentid) as four
on (one.emp_id = four.emp_id AND one.date = four.holidaydate)
where one.emp_id = '710102'
18 Feb
4 months ago

kshitizmittal left a reply on Force Password Reset

@MANELGAVALDA - How to check this middleware after login or everytime when user tries to redirect without changing password??

kshitizmittal started a new conversation Force Password Reset

Want to restrict user to go further in application, if he doesn't submit the force password reset form.

How can I do this , I have added a column to check password has been changed by user or not in User.php model or users table.

13 Feb
4 months ago

kshitizmittal left a reply on Rendering Dynamic Content In Blade

@CHRISOSTOM - When I click on one of the below tabs, it doesn't route me anywhere.

<div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                <li><a href="{{ url('/bidashboard') }}" data-toggle="tab">Dashboard</a></li> 
                <li><a href="{{ url('/bidvw') }}" data-toggle="tab">Documented Verbal Warning</a></li> 
                <li><a href="#" data-toggle="tab">Warning Letter</a></li> 
                <li><a href="#" data-toggle="tab">CAP-1</a></li>
                <li><a href="#" data-toggle="tab">CAP-2</a></li> 
                <li><a href="#" data-toggle="tab">Observation</a></li> 
                <li><a href="#" data-toggle="tab">Status</a></li> 
            </ul>

kshitizmittal started a new conversation Convert This Query To Eloquent

I want to convert this query to eloquent

select result.degname,COUNT(result.emp_id) from (Select ed.emp_id,deg.degname from employeedetails as ed LEFT JOIN designations as deg on ed.designation = deg.degid) as result GROUP BY result.degname

kshitizmittal started a new conversation Rendering Dynamic Content In Blade

Routes :- web.php

Route::get('/bidvw',function () {
    return view('bilayout.bidvw');
});
Route::get('/bidashboard',function () {
    return view('bilayout.bidashboard');    
});

layout.blade.php :-

@include('project_layout.header')
<!-- ****************************** Table section  ******************************* -->
<section class="main_top_box_wrapper">
    <div class="col-md-12 headingArea ">
        <div id="breadcrumb" class="breadcrumbs">
            Admin<span class="symbol"> &gt; </span>
            <span class="currentLocation">Behaviouer Issue</span>
        </div>
        <div class="title pull-left">
            <h3>Behaviouer Issue</h3>
        </div>
    </div>
    
    <div class="main_box_wrapper">  
        <!-- Buttons -->
        @can('Add BI')
            <!-- Buttons -->
           <div class="button_box">
                <a href="{{ action('[email protected]') }}" class="blue_button"><i class="fa fa-sign-language"></i> Assign Behaviour Issue</a>              
            </div>
        @endcan

        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                <li><a href="{{ url('/bidashboard') }}" data-toggle="tab">Dashboard</a></li> 
                <li><a href="{{ url('/bidvw') }}" data-toggle="tab">Documented Verbal Warning</a></li> 
                <li><a href="#" data-toggle="tab">Warning Letter</a></li> 
                <li><a href="#" data-toggle="tab">CAP-1</a></li>
                <li><a href="#" data-toggle="tab">CAP-2</a></li> 
                <li><a href="#" data-toggle="tab">Observation</a></li> 
                <li><a href="#" data-toggle="tab">Status</a></li> 
            </ul>           

            <!-- ******** Tab section ******** -->

            <div class="tab-content">
                @yield('content')
            </div>
        </div>  
    </div>           
</section>

@include('project_layout.footer')

bidvw.blade.php :-

@extends('bilayout.bilayout')
@section('content')
    <p>Documented Verbal Warning</p>
@stop

bidashboard.blade.php :-

@extends('bilayout.bilayout')
@section('content')
    <p>This is my Dashboard content.</p>
@stop

Unable to route successfully. Please help!!!

11 Feb
4 months ago

kshitizmittal started a new conversation Reduce Time Complexity

Punchreport model :-

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
use Auth;

class Punchreport extends Model
{
    use LogsActivity;
    protected $fillable = ['emp_id','punch_in','punch_out','date'];

    protected static $logAttributes = ['emp_id','punch_in','punch_out','date'];
    protected static $recordEvents = ['updated','created'];

    public function rosterData(){
        $roster = Roster::where(['emp_id'=>$this->emp_id,'month'=>date('F',strtotime($this->date))])->first(); //query1
        if($roster){
            return $roster; 
        } else {
            return $default_roster = ['week_off'=>"Saturday,Sunday,Default","roster_time_in"=>"09:30","roster_time_off"=>"18:30"];
        }           
    }
    public function leaveData(){
        $leaves = Applyleave::where('emp_id','=',$this->emp_id)
                            ->where('start_date','<=',$this->date)
                            ->where('end_date','>=',$this->date)
                            ->where('final_approval','=','Approve')
                            ->with(['leavetypes'])
                            ->first(); //query 2
        if($leaves){
            return $leaves;
        } else {
            return null;
        }
    }
    public function holidayData(){
        $holidays = Assigntanda::where(['emp_id'=>$this->emp_id])->with(['holidayCalendar.holidays'])->first(); //query 3
        if($holidays){
            return $holidays->holidayCalendar->holidays->pluck('holidaydate')->toArray();
        } else {
            return null;
        }
    }
    public function getStatusAttribute(){
        $week_off = $this->rosterData()["week_off"];
        $leaves = $this->leaveData();
        $holidays = $this->holidayData();

        $is_week_off = false;
        $on_leave = false;
        $is_holiday = false;
        
        if(in_array($this->date,$holidays)){
            return "H";
        }
        if(in_array(date('l',strtotime($this->date)),explode(',',$week_off))){
            $is_week_off = true;
            return "WO";
        }
        if($leaves){
            $on_leave = true;
            return $leaves->leavetypes->type_code;  
        }
        
        if($this->punch_in && $this->punch_out) {
            $timediff = (strtotime($this->punch_out) - strtotime($this->punch_in))/3600;
            if($timediff < 0) {
                $timediff = 24+$timediff;
            }

            if($timediff >= 8.0){
                return "P";
            }
            elseif($timediff >= 4.0 && $timediff <= 8.0) {
                return "1/2P";
            }
            else {
                return "A";
            }
        } else {
            return "A";
        }       

    }

    /* === EmployeeDetail Relation === */
    public function employeedetails()
    {
        return $this->belongsTo('App\Employeedetail','emp_id', 'emp_id');
    }
}

I this Punch report table structure is

  1. emp_id - employee Id of the employee
  2. punch_in - punch in time
  3. punch_out - punchout time
  4. date - date of punch.

This table contains multiple record of employee, lets say in January there will be 31 records of a employee ID for ex:- "123456".

Now I want to add custom attribute "status" in which I want to validate the punch record as well as the week off, leaves and holiday on that day which are coming from different tables.

I am facing time Complexity issue here coz, the query is running 31 * 3 times and if the number of record are incresing it is taking more time.

08 Feb
4 months ago

kshitizmittal left a reply on Sort Collection

@BOZHKOS - Can you help me with sample code.

kshitizmittal started a new conversation Sort Collection

$requests = Applyleave::with(['employeedetails.departments','employeedetails.designations','employeedetails.officelocations'])->get();

Fetching All the leave requests using this.

Requirement is to show all the pending leave requests on top in a blade table.

Applyleave model has an attribute of status in which Pending, Rejected, Approved is there.

07 Feb
4 months ago

kshitizmittal left a reply on Fetching Full Name From Model

@BOZHKOS - I am getting full_name as null

kshitizmittal started a new conversation Fetching Full Name From Model

I want to fetch full name from Employeedetail model.

Model Code :-

public function getFullNameAttribute() {
        if($this->middle_name)
            return $this->first_name.' '.$this->middle_name.' '.$this->last_name;
        else 
            return $this->first_name.' '.$this->last_name;     
    }

Controller Code :-

$supervisors = Employeedetail::where(['status'=>'Active'])->pluck('full_name','emp_id')->all();

Error Message :-

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'full_name' in 'field list' (SQL: select `full_name`, `emp_id` from `employeedetails` where (`status` = Active)) ◀"

Ultimate Goal is to pluck full name.

kshitizmittal started a new conversation Using Select Blade

I am trying to implement dropdown in blade like this,

{!! Form::select('holiday_calender', [null=>'Please Select Calendar'] + $holidayCalenders ,$assignedtanda->holiday_calendar, array('class' => 'form-control')) !!}

Controller:-

$holidayCalenders = Holidaycalander::where(['status'=>'on'])->pluck('name','id');

Dump of Holiday Calendar :-

Collection {#2727 ▼
  #items: array:1 [▼
    1 => "India"
  ]
}

In DB $assignedtanda->holiday_calendar this returns 1

Desired result :-

<select class="form-control" name="holiday_calender" id="holidaycalender">
    <option value="">Select Holiday Calender </option>
    <option selected="true" value="1">India</option>
</select>
05 Feb
4 months ago

kshitizmittal started a new conversation Import/Export Package

I am trying to use a Laravel package for CSV based data import/export the name of the package is - maatwebsite This package runs well in my local host but give me the above error when I try to run it in Windows Server R2 2012. Can you please help me identify the solution for the above error

Getting this error.

Could not open for reading! File does not exist.
30 Jan
4 months ago

kshitizmittal started a new conversation ConsoleTV Chartjs Chart Type

I am using this below package for charts.

// CHARTS
ConsoleTVs\Charts\ChartsServiceProvider::class,

This is the class I made for charts,

<?php

namespace App\Charts;

use ConsoleTVs\Charts\Classes\Chartjs\Chart;

class UserChart extends Chart
{
    /**
     * Initializes the chart.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }
}

This is how I made object in controller,

    public function index()
    {
        $departments=Department::where(['deptstatus'=>'on'])->get();
        $designations=Designation::where(['degstatus'=>'on'])->get();
        $officelocations=Officelocation::where(['locstatus'=>'on'])->get();
        $users = Employeedetail::with(['officelocations','departments','designations','subdepartments'])->where(['status'=>'Active'])->get();

        $graphData = DB::select("SELECT result.childdepartment as label, count(result.id) as value from (select ed.id, ed.emp_id, dept.parentdepartment, dept.childdepartment from employeedetails as ed LEFT JOIN (select child_dept.deptid as id, child_dept.deptname as childdepartment, parent_dept.deptname as parentdepartment from departments as parent_dept INNER JOIN departments as child_dept on child_dept.deptparent = parent_dept.deptid) as dept on ed.department = dept.id) as result GROUP BY childdepartment");

        $chart = new UserChart;
        
        $chart->labels(['One', 'Two', 'Three', 'Four']);
        $chart->dataset('My dataset', 'line', [1, 2, 3, 4]);
        $chart->dataset('My dataset 2', 'doughnut', [4, 3, 2, 1]);
        $chart->options([
            'tooltip' => [
                'show' => true // or false, depending on what you want.
            ]
        ]);

        return view('eno.user',compact('users','departments','designations','officelocations','graphData','chart'));
    }

My concern is how I can change the chart type ??

28 Jan
4 months ago

kshitizmittal left a reply on Want To Block Multiple Logins

@SNAPEY - How can I refresh the previous logins, because I have to refresh it manually.

I got the result all the previous sessions are logging out, but need to refresh the windows manually.

Is there a way I can redirect them to /login route.

kshitizmittal started a new conversation Multiple Login Notification

I have to show message on login :-

if already logged in on other device then, :-

" Already logged in other session"

if logging first time only, :-

" No Message "

kshitizmittal left a reply on Want To Block Multiple Logins

@SNAPEY - I have to show message on login

if multiple login then, " Previous session has been logged out"

if logging first time only, " No Message "

kshitizmittal left a reply on Want To Block Multiple Logins

@SNAPEY - Where I have to put this code?

Auth::logoutOtherDevices($password);

kshitizmittal left a reply on Want To Block Multiple Logins

@AHSAN - Can you help me with a sample?

kshitizmittal left a reply on Want To Block Multiple Logins

@AHSAN - I need to implement a logic where I have to show a notification if any user tries to login multiple time from any other browser or system.

kshitizmittal started a new conversation Want To Block Multiple Logins

<?php

namespace Illuminate\Foundation\Auth;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;

trait AuthenticatesUsers
{
    use RedirectsUsers, ThrottlesLogins;

    /**
     * Show the application's login form.
     *
     * @return \Illuminate\Http\Response
     */
    public function showLoginForm()
    {
        return view('auth.login');
    }

    /**
     * Handle a login request to the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse
     *
     * @throws \Illuminate\Validation\ValidationException
     */
    public function login(Request $request)
    {
        $this->validateLogin($request);

        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the client making these requests into this application.
        if ($this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);

            return $this->sendLockoutResponse($request);
        }

        if ($this->attemptLogin($request)) {
            return $this->sendLoginResponse($request);
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
        $this->incrementLoginAttempts($request);

        return $this->sendFailedLoginResponse($request);
    }

    /**
     * Validate the user login request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return void
     *
     * @throws \Illuminate\Validation\ValidationException
     */
    protected function validateLogin(Request $request)
    {
        $request->validate([
            $this->username() => 'required|string',
            'password' => 'required|string',
        ]);
    }

    /**
     * Attempt to log the user into the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return bool
     */
    protected function attemptLogin(Request $request)
    {
        if($this->guard()->attempt($this->credentials($request), $request->filled('remember'))){
            if(!Auth::user()->is_logged_in){
                return true;
            } else {
                return false;
            }
        } else {
            return true;
        }

    }

    /**
     * Get the needed authorization credentials from the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    protected function credentials(Request $request)
    {
        return $request->only($this->username(), 'password');
    }

    /**
     * Send the response after the user was authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    protected function sendLoginResponse(Request $request)
    {
        $request->session()->regenerate();

        $this->clearLoginAttempts($request);

        return $this->authenticated($request, $this->guard()->user())
                ?: redirect()->intended($this->redirectPath());
    }

    /**
     * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {
        Auth::user()->update(['is_logged_in' => true]);
    }

    /**
     * Get the failed login response instance.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Symfony\Component\HttpFoundation\Response
     *
     * @throws \Illuminate\Validation\ValidationException
     */
    protected function sendFailedLoginResponse(Request $request)
    {
        throw ValidationException::withMessages([
            $this->username() => [trans('auth.failed')],
        ]);
    }

    /**
     * Get the login username to be used by the controller.
     *
     * @return string
     */
    public function username()
    {
        return 'email';
    }

    /**
     * Log the user out of the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function logout(Request $request)
    {
        Auth::user()->update(['is_logged_in' => false]);
        $this->guard()->logout();

        $request->session()->invalidate();

        return $this->loggedOut($request) ?: redirect('/');
    }

    /**
     * The user has logged out of the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return mixed
     */
    protected function loggedOut(Request $request)
    {
        //
    }

    /**
     * Get the guard to be used during authentication.
     *
     * @return \Illuminate\Contracts\Auth\StatefulGuard
     */
    protected function guard()
    {
        return Auth::guard();
    }
}

This is the above implemented code.

If I am trying to login 2nd time it is blocking but on 3rd time login is not blocked, please give a solution.

24 Jan
5 months ago

kshitizmittal started a new conversation Full Calendar SetOptions() Additional Parameters

How to implement additional parameters in setOptions() like, I want to disable sunday greyout etc.

I want full list of additional parameters.

Sample Code in Controller :-

public function index()
    {
        $activities = Engagementactivity::where(["activity_status"=>"on"])->get();
        $events = [];
        foreach ($activities as $key => $activity) {
            $events[] = Calendar::event(
                (@$activity->activity_name ? @$activity->activity_name : 'N/A'),
                true,
                new \DateTime($activity->activity_start_date),
                new \DateTime($activity->activity_start_date),
                // 1,
                [
                    // 'url' => url('/home'),
                ],
            );
        }
        $calendar = Calendar::addEvents($events, [ //set custom color fo this event
            'color' => '#61ABE1',
        ])->setOptions([ //set fullcalendar options
            'firstDay' => 1
        ]);
        return view('admin.calender',compact('calendar'));
    }

Like here I have used firstDay parameter in setOptions().

22 Jan
5 months ago

kshitizmittal started a new conversation How To Secure XSRF-Token And Laravel_session

I am using chrome browser, while inspecting cookies I am unable to get check on secure parameter for XSRF-Token and laravel_session.

Though I have implemented the below code in session.php and VerifyCsrfToken.php :-

  1. session.php
/*
    |--------------------------------------------------------------------------
    | HTTPS Only Cookies
    |--------------------------------------------------------------------------
    |
    | By setting this option to true, session cookies will only be sent back
    | to the server if the browser has a HTTPS connection. This will keep
    | the cookie from being sent to you if it can not be done securely.
    |
    */

    'secure' => env('SESSION_SECURE_COOKIE', true),
  1. VerifyCsrfToken.php
protected function addCookieToResponse($request, $response)
    {
        $config = config('session');
        $response->headers->setCookie(
            new Cookie(
                'XSRF-TOKEN', $request->session()->token(), $this->availableAt(60 * $config['lifetime']),
                $config['path'], $config['domain'], $config['secure']=true, true, true, $config['same_site']="strict" ?? null
            )
        );
        return $response;
    }

kshitizmittal started a new conversation Concurrent Session In Laravel

How restrict concurrent session.

When i am picking the URL and copying it in the another browser, application should logout ideally but it is not.

I want solution for this.

kshitizmittal left a reply on JSON With Date Object

@VILFAGO - ``` data: [ { color: "#393f63", markerSize: 0, type: "splineArea", yValueFormatString: "### Employee", dataPoints: [ { x: new Date("1 Jan 2015"), y: 11 }, { x: new Date("1 Feb 2015"), y: 12 }, { x: new Date("1 Mar 2015"), y: 15 }, { x: new Date("1 Apr 2015"), y: 20 }, { x: new Date("1 May 2015"), y: 8 }, { x: new Date("1 Jun 2015"), y: 58 }, { x: new Date("1 Jul 2015"), y: 6 }, { x: new Date("1 Aug 2015"), y: 14 }, { x: new Date("1 Sep 2015"), y: 12 }, { x: new Date("1 Oct 2015"), y: 13 }, { x: new Date("1 Nov 2015"), y: 28 }, { x: new Date("1 Dec 2015"), y: 27 } ] } ]


I am putting the above json to datapoints attribute.

kshitizmittal left a reply on How To Secure XSRF-Token In My Application

@VILFAGO - meta tag in header :-

<meta name="csrf-token" content="{{ csrf_token() }}">

session.php file :-

    'secure' => env('SESSION_SECURE_COOKIE', true),

    /*
    |--------------------------------------------------------------------------
    | HTTP Access Only
    |--------------------------------------------------------------------------
    |
    | Setting this value to true will prevent JavaScript from accessing the
    | value of the cookie and the cookie will only be accessible through
    | the HTTP protocol. You are free to modify this option if needed.
    |
    */

    'http_only' => true,

got this as a output in inspect(Q) under storage

HttpOnly:false

I want to know how can i make it true .

kshitizmittal started a new conversation JSON With Date Object

function onChartClick(e){
        jQuery.ajax({
            url: "./pipsubchart",
            type: "GET",
            data: {
                _token: '{{csrf_token()}}',
                pip_type: e.dataPoint.name,
                currMonth: jQuery("#chartMonth").val(),
                currYear: jQuery("#chartYear").val()
            },
            success: function(data) {
                data.forEach(function(value) {
                    value.x = new Date(value.x);
                });
                document.getElementById("result").innerHTML = JSON.stringify(data);
            }
        });
    }

I am passiing this above JSON in canvas JS charts datapoints but, it asks for date object as a input value,

My concern is i have already converted the date value into object but when i used JSON.stringify() It again changed the value to string.

kshitizmittal left a reply on How To Secure XSRF-Token In My Application

@VILFAGO - I am unable to find out a solution for this, evem though i have made the desired changes.

kshitizmittal left a reply on How To Secure XSRF-Token In My Application

@VILFAGO - I am trying to set HttpOnly parameter true in the application at run time, I have tried setting this parameter to true in config/session.php file.

And i have also put a csrf meta tag in header as well.

21 Jan
5 months ago

kshitizmittal started a new conversation How To Secure XSRF-Token In My Application

Please give a solution for it.