deepu07

deepu07

Member Since 2 Years Ago

Experience Points
32,380
Total
Experience

2,620 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
241
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 7
32,380 XP
Jun
01
19 hours ago
Activity icon

Replied to Update Variable Value In Constructor After Running A Function

@michaloravec somehow registerEvents() is calling before the view() function. that is even I'm not able to set up the value into session too.

Activity icon

Replied to Update Variable Value In Constructor After Running A Function

@michaloravec Here is my code I'm using Laravel-Excel Plugin. I wanna access count(departments) in registerEvents() function


namespace App\Exports;

use App\Models\Department;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Session;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use Maatwebsite\Excel\Sheet;
use Maatwebsite\Excel\Writer;

Sheet::macro('styleCells', function (Sheet $sheet, string $cellRange, array $style) {
    $sheet->getDelegate()->getStyle($cellRange)->applyFromArray($style);
});

Sheet::macro('setOrientation', function (Sheet $sheet, $orientation) {
    $sheet->getDelegate()->getPageSetup()->setOrientation($orientation);
});

class DepartmentExport implements FromView, ShouldAutoSize, WithEvents
{

    public function __construct($subjectId, $key, $college)
    {
        $this->subjectId = $subjectId;
        $this->key = $key;
        $this->college = $college;
    }

    public function view(): View
    {
        $departments = Department::select([
            'id',
            'name',
            'type',
            'subjectId'
        ])
            ->where('subject_id', $this->subjectId)
            ->with(['students'])
            ->orderBy('id')
            ->get();
    
        if ($this->college == 'abc') {
            return view('student-export', ['departments' => $departments, 'college' => $this->college]);
        } else {
            return view('student-other-export', ['departments' => $departments]);
        }
    }

    public function registerEvents(): array
    {
        return [
            AfterSheet::class    => function(AfterSheet $event) {
                $event->sheet->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
        ];
    }
}
Activity icon

Replied to Update Variable Value In Constructor After Running A Function

@michaloravec thanks if not how to access the value of one function variable into another function. I don't wanna use the return statement. is there any other way?

Activity icon

Started a new Conversation Update Variable Value In Constructor After Running A Function

Hi Mates, in my file I wanna set variable value is null at the initial stage in the constructor, after running a function I wanna update the variable value (Getting from the custom query) in the constructor. is it possible? I know I can set it up into session and pull but looking some other way. Any help that would be great. Thanks!

Activity icon

Replied to Suggestion For Laravel Project Management System

@laravel_newbie for role management better to use a passport plugin. for relationships created a model relationship. FYI https://laravel.com/docs/7.x/eloquent-relationships#introduction

Activity icon

Replied to "php Artisan Migrate" Gives Error

@monstajamss Looks like DB connection is failed. double-check it.

Activity icon

Replied to AdminLTE Integration, Starter.html Is Not Found

@esaeng Here you go https://adminlte.io/themes/dev/AdminLTE/starter.html include this page manually if you want. also, follow this youtube tutorial pretty much this covers everything https://www.youtube.com/watch?v=CowsopJhX3M

Activity icon

Replied to Laradock Mysql Port 3310 Unable To Connect To Table-plus/sequel Pro

@bobbybouwmann Yeah, it is working from code and able to create a user and perform all operations. but when I try to connect to Database GUI's it is not working with port 3310. Anyways thanks for your reply.

May
31
1 day ago
Activity icon

Started a new Conversation Laradock Mysql Port 3310 Unable To Connect To Table-plus/sequel Pro

Hi Mates, I have a quick question I created a Laravel project with Laradock container. I changed the MySQL port number from 3306 to 3310. able to run migrations and everything but somehow I'm not able to connect to the table plus/sequel pro with a port number 3310. is anyone ran into this issue before. Any help that would be great. thanks!

May
29
3 days ago
Activity icon

Awarded Best Reply on Multiple Query Is Giving Empty Data

It worked i did like this

$query1 = $departments;
$query2 = clone $query1;
$query3 = clone $query2;

$musicDepartment = $query1->where('type', 'music')->with('students')->get();

$artDepartment = $query2->where('type', 'art')->with('students')->get();

$languageDepartment = $query3->where('type', 'language')->with('students')->get();

Learned New stuff. Thanks, @michaloravec @joefusco

Activity icon

Replied to Multiple Query Is Giving Empty Data

It worked i did like this

$query1 = $departments;
$query2 = clone $query1;
$query3 = clone $query2;

$musicDepartment = $query1->where('type', 'music')->with('students')->get();

$artDepartment = $query2->where('type', 'art')->with('students')->get();

$languageDepartment = $query3->where('type', 'language')->with('students')->get();

Learned New stuff. Thanks, @michaloravec @joefusco

Activity icon

Replied to Multiple Query Is Giving Empty Data

@michaloravec I'll get data for dd($languageDepartment); if I comment this line

$musicDepartment = Department::with('students')->where('type', 'music')->get();
Activity icon

Replied to Multiple Query Is Giving Empty Data

@michaloravec I tried like what you suggest dd($languageDepartment) is getting null but it is not null.

@joefusco Tried with Clone still getting empty for last two variables except $musicDepartment

Activity icon

Started a new Conversation Multiple Query Is Giving Empty Data

if (true) {
           $musicDepartment = $departments->where(function($query) {
                $query->where('type', 'music');
            })->with(['students'])->get();

            $artDepartment = $departments->where(function($query) {
                $query->where('type', 'art');
            })->with(['students'])->get();

            $languageDepartment = $departments->where(function($query) {
                $query->where('type', 'language');
            })->with(['students'])->get();
        }

after If dd($languageDepartment) is giving null but data is not empty. how can I achieve all the there query data? TIA

Activity icon

Started a new Conversation Storing The 'Where' Clause In A Variable

Hi Mates, Here I wanna Store the 'Where' clause in a variable based on department type. like how can I achieve in this scenario? TIA

$Departaments ->where('computers as computer_department' => function ($query) {
                $query->where('type', 'computers);
            })->with(['students']);
May
28
4 days ago
Activity icon

Replied to Formatting Exported Excel File

@konrms I got the same problem. can you help me how to fix this problem? I just wanna add borders to the table. I'm trying like this but no luck

    return [
            AfterSheet::class    => function(AfterSheet $event)
            {
                $event->getSheet()->getDelegate()->getStyle('A1:G1')->applyFromArray(
                    array(
                        'borders' => array(
                            'allborders' => array(
                                'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
                                'color' => array('rgb' => '000000')
                            )
                        )
                    )
                );
            }
        ];

any help that would be great. Thanks!

Activity icon

Started a new Conversation Somehow Table Borders Are Not Displaying In Excel Document.

Here is my blade file (Excel). I'm generating the excel file by using Laravel-Excel package. Somehow Table Borders are not displaying in the Excel document.

<!DOCTYPE html>
<html>
<head>
    <style>
        body {
            font-size: 12pt;
            font-family: Calibri, sans-serif;
            padding : 10px;
        }
        table {
            border: 1px solid black;
        }
        th {
            border: 1px solid black;
            padding: 5px;
            background-color:grey;
            color: white;
        }
        td {
            border: 1px solid black;
            padding: 5px;
        }
    </style>
</head>

<body>

<table style="width:100%;">
    <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Age</th>
    </tr>
    <tr>
        <td>Priya</td>
        <td>Sharma</td>
        <td>24</td>
    </tr>
    <tr>
        <td>Arun</td>
        <td>Singh</td>
        <td>32</td>
    </tr>
    <tr>
        <td>Sam</td>
        <td>Watson</td>
        <td>41</td>
    </tr>
</table>

<br />
<br />

<table id="t01">
    <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Age</th>
    </tr>
    <tr>
        <td>Priya</td>
        <td>Sharma</td>
        <td>24</td>
    </tr>
    <tr>
        <td>Arun</td>
        <td>Singh</td>
        <td>32</td>
    </tr>
    <tr>
        <td>Sam</td>
        <td>Watson</td>
        <td>41</td>

    </tr>
</table>
</body>

</html>
May
27
5 days ago
Activity icon

Replied to How To Send Email To All Users

@alodon run CRON jobs

May
22
1 week ago
Activity icon

Started a new Conversation Generate Multiple Excel Files By Using Laravel Excel Package

Is it possible to create a multiple .csv files and save into Zip format by using the Laravel Excel package? TIA

Activity icon

Replied to What Is The Best Practice To Return In A Controller?

@mcltano second case is best practice you're redirecting after logic exec.

Activity icon

Replied to Laravel Validation Custom Message Upon Error?

@nickywan123 why don't you write validation requests so that controller will have only logic FYI https://laravel.com/docs/7.x/validation#form-request-validation if you want something custom msg you have to write custom rules in this case

May
20
1 week ago
Activity icon

Started a new Conversation Pluck Values Without Index

Hello, this is my session custom array I would like to get only values like [26, 27, 31] without index values how can I achieve here. thanks!

"studentIds" => array:3 [▼
      0 => "26"
      1 => "27"
      2 => "31"
    ]
May
18
2 weeks ago
Activity icon

Replied to How To Delete Old Picture After New One Uploaded

@monstajamss save image name with user_name or id and when you're uploading new pic jus replace the old image.

May
17
2 weeks ago
May
13
2 weeks ago
Activity icon

Replied to Errors Are Not Displaying In Browser Laravel 7

@drewdan let's have an undefined variable in my script. it throws this error. In browser, it'll display like this

This page isn’t working 
localhost is currently unable to handle this request.
HTTP ERROR 500

also no matter what, for any error (include validation errors too). pretty much this will be the output. also, I'm not seeing any Laravel logs as well.

Activity icon

Started a new Conversation Errors Are Not Displaying In Browser Laravel 7

Hi Mates, I'm running into a weird issue after upgrading PHP (7.4.5) & Laravel (7.0) Version. errors are not showing in the browser also in my local I'm getting like this also logs are not getting created as well under storage/logs direc. any help that would be great. thanks!

[Wed May 13 10:28:05 2020] 127.0.0.1:52634 Accepted
[Wed May 13 10:29:07 2020] PHP Fatal error:  Maximum execution time of 60 seconds exceeded in /Users/kkk/Development/repo/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 37

[Wed May 13 10:29:09 2020] PHP Fatal error:  Maximum execution time of 60 seconds exceeded in /Users/kkk/Development/repo/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 772
[Wed May 13 11:29:09 2020] 127.0.0.1:52634 Closing
May
11
3 weeks ago
Activity icon

Awarded Best Reply on How To Attach Excel File To Mail From The Storage Directory.

fixed! Need to pass the absolute path. I,e, Storage::disk('public')->path($filename);

Activity icon

Replied to How To Attach Excel File To Mail From The Storage Directory.

fixed! Need to pass the absolute path. I,e, Storage::disk('public')->path($filename);

Activity icon

Started a new Conversation How To Attach Excel File To Mail From The Storage Directory.

How to attach excel file to mail from the storage directory. here is my code snippet

$period = Carbon::now()->format('m-Y');
    $path = 'export/'.$period.'.xlsx';
    Mail::send('emails.billing-report', ['period' => $period], function($message) use ($path) {
        $message->to('[email protected]', 'user1245')->subject
        ('Report '. Carbon::now()->format('m-Y'));
        $message->attachFromStorage($path, Carbon::now()->format('m-Y').'.xlsx', [
            'mime' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        ]);
        $message->from('[email protected]','test');
    });
    echo "Email Sent with attachment. Check your inbox.";
Activity icon

Replied to Missing Required Parameters For Editprofile Page

@rubenochoa do dd() before saving and see what are values you're getting...

Activity icon

Started a new Conversation Laravel Excel Export To Storage Direc

Hi Mates, I'm trying to save generated excel documents into storage exports directory. somehow it is not working as expected.

return Excel::store(new BillingReport($userIds), Carbon::now().'.xlsx', '/exports', true);

any help that would be great. Thanks!

Activity icon

Started a new Conversation Laravel WhereIn Inside WithCount()

How to pass $departementIds into the below query.

$departementIds = Department::where('name', 'ARTS')->pluck('id')->toArray();

$users = User::select([
            'id',
            'first_name',
            'last_name',
            'email',
            'graduate_year'
        ])
        ->where('graduate_year', 2015)
        ->withCount('classes', function ($query) {
                     $query->whereIn('classes.department_id', $departementIds);
                })->get();

any idea how to achieve this? TIA

Activity icon

Replied to Laravel Count With Relationship Fields

Thanks! @ramjithap that works!

$users = User::select([
            'id',
            'first_name',
            'last_name',
            'email',
            'graduate_year'
        ])
        ->where('graduate_year', 2015)
        ->withCount('classes', function ($query) {
                     $query->join('departments', 'departments.id', '=', 'classes.department_id')->where('departments.name', '=', 'MUSIC');
                })->get();

I'm trying to do like this somehow getting an err. do you have any idea how to achieve this? TIA

May
10
3 weeks ago
Activity icon

Replied to Guzzle: Float Changes To String

Save as string and when use convert string to float by using Laravel typecasting?

Activity icon

Replied to Whoops Something Went Wrong With Nothing In Logs

@kimg do dd() in the file? are you able to do that?

Activity icon

Replied to Laravel Count With Relationship Fields

@ramjithap i tried like this no luck

$users = User::select([
            'id',
            'first_name',
            'last_name',
            'email',
            'graduate_year'
        ])
        ->where('graduate_year', 2015)
        ->withCount('classes', function ($query) {
                     $query->groupBy('department_id');
                })->get();

cause relationship is like this class hasOne Department. i.e class table has the department_id.

Activity icon

Started a new Conversation Laravel Count With Relationship Fields

Hi mates, I'm trying to get the count of classes groupBy department type. how can I achieve this? Thanks!

$users = User::select([
            'id',
            'first_name',
            'last_name',
            'email',
            'graduate_year'
        ])
        ->where('graduate_year', 2015)
        ->with(['classes', 'classes.department'])->get();
Activity icon

Replied to @if Shorter? (Blade)

@david19 use shorthand conditional statements like

{{ if (!empty($variable1)) ?  some action : NO RECORD!!! }}
Activity icon

Replied to Laravel: HasMany Doesn't Return Everything From The Specified Model

@pemesteves try this

public function posts() {
   return $this->hasMany('App\Post')->get('attribute_name');
}
Activity icon

Replied to Laravel Count With Relationship Fields

@oli_d111 @michaloravec sorry for the late reply. Here is my controller logic

$users = User::select([
            'id',
            'first_name',
            'last_name',
            'email',
            'graduate_year'
        ])
        ->where('graduate_year', 2015)
        ->with(['classes', 'classes. department'])->get();

now I wanna display a count of classes groupBy departmentType in a blade file.

May
08
3 weeks ago
Activity icon

Replied to Laravel Count With Relationship Fields

@oli_d111 i was doing with custom queries and nested relationships. not on the model

Activity icon

Replied to Laravel Count With Relationship Fields

@michaloravec sorry for the confusion. I wanna count how many classes by department type...

Activity icon

Started a new Conversation Laravel Count With Relationship Fields

Hi mates, I'm trying to get the count of classes based on the department type. how can I achieve in this case. Thanks!

dd(collect($user->classes)->pluck('department.type', 'department.type'));

result is

Illuminate\Support\Collection {#842 ▼
  #items: array:1 [▼
    "Arts" => "Arts",
  ]
}
May
05
3 weeks ago
Activity icon

Replied to Laravel Select Relationship Table Field By Using With()

Yes. I have data in my DB. I'm using Postgresql with Laravel7

Activity icon

Replied to Laravel Select Relationship Table Field By Using With()

@michaloravec It's weird relations value is still empty. if I use with().

Activity icon

Replied to Laravel Select Relationship Table Field By Using With()

@judev I have a relationship in User model

//User Model
public function department()
    {
        return $this->belongsTo(Department::class, 'department_id', 'id');
    }
Activity icon

Replied to Laravel Select Relationship Table Field By Using With()

@michaloravec No luck, still getting empty department value.

#relations: array:1 [▼
        "department" => null
      ]
Activity icon

Started a new Conversation Laravel Select Relationship Table Field By Using With()

Here I'm trying to get student details along with department name but somehow it is now working as expected. any thoughts why it is not working? TIA

User::where('teacher_id', $teacherId)->with('department')
                ->select([
                    'first_name',
                    'last_name',
                    'department.name',
                ])->get());