sin2san

Software Engineer at Natc Institute - Singapore

Member Since 1 Year Ago

Sri Lanka

Experience Points
430
Total
Experience

4,570 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 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.

  • Community Pillar

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

Level 1
430 XP
May
14
4 weeks ago
Activity icon

Awarded Best Reply on All Of A Sudden External Links Not Working In Barryvdh/laravel-dompdf

I've managed to solve this issue.

Posting here incase it can help someone.

Replaced barryvdh/laravel-dompdf with barryvdh/laravel-snappy

Package Link : https://github.com/barryvdh/laravel-snappy

My external styles, images & fonts are not loaded. For styles i have created a blade file, updated it with css codes and included it in the pdf template blade. For images i have created an absolute path

<img src="{{ public_path('images/img1.jpg')}}" alt="No Image" />

For font i have installed the font on the server, I am using ubuntu 16.04, I have installed open sans and SimHei (Chinese font) and updated the font-family to open sans & simhei in my application.

Activity icon

Replied to All Of A Sudden External Links Not Working In Barryvdh/laravel-dompdf

I've managed to solve this issue.

Posting here incase it can help someone.

Replaced barryvdh/laravel-dompdf with barryvdh/laravel-snappy

Package Link : https://github.com/barryvdh/laravel-snappy

My external styles, images & fonts are not loaded. For styles i have created a blade file, updated it with css codes and included it in the pdf template blade. For images i have created an absolute path

<img src="{{ public_path('images/img1.jpg')}}" alt="No Image" />

For font i have installed the font on the server, I am using ubuntu 16.04, I have installed open sans and SimHei (Chinese font) and updated the font-family to open sans & simhei in my application.

May
07
1 month ago
Activity icon

Started a new Conversation All Of A Sudden External Links Not Working In Barryvdh/laravel-dompdf

I am using barryvdh/laravel-dompdf for quite long. Using external CSS (From local) and font (From CDN), It was working fine and suddenly the design collapsed, also the font not working so I've checked in the view and came to know the view is not loading the CSS & fonts. I am using Laravel 5.5 and barryvdh/laravel-dompdf version is 0.8.6. Tried in Laravel 8 with barryvdh/laravel-dompdf version 0.9.0 also not working.

Code:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Receipt | {{ Auth::user()->name }} - {{ $setting->name }}</title>
    <link href="{{ asset('css/bootstrap.css') }}" rel="stylesheet" type="text/css" media="all" />
    <link href="{{ asset('css/main.css') }}" rel="stylesheet" type="text/css" media="all" />
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" />

    <style type="text/css">
        /* Another font (Chinese) loaded from local folder for particular tags */
	@font-face {
            font-family: SimHei;
            src: url('{{asset('fonts/simhei.ttf')}}') format('truetype');
        }
        body{
           font-family: Open Sans, Sans-serif; line-height: 1;
        }
        p {
            font-size: 18px;
            margin-bottom: 0 !important;
        }
    </style>
</head>

For CSS, I have tried to update

<link href="{{ asset('css/main.css') }}" rel="stylesheet" type="text/css" media="all" /> 

to

On Local:

<link href="{{ public_path('css/main.css') }}" rel="stylesheet" type="text/css" media="all" /> 
<link href="{{ base_path().'/css/maincss' }}"  rel="stylesheet" type="text/css" media="all" /> 
<link href="http://127.0.0.1:8000/css/main.css' }}"  rel="stylesheet" type="text/css" media="all" />

On server:

<link href="var/www/html/project/public/css/main.css"  rel="stylesheet" type="text/css" media="all" /> 

For the font, I have tried to have it in a local folder as a .ttf file, and importing in style still doesn't work.

Apr
18
1 month ago
Activity icon

Replied to How To Get Value Based On Hasmany Table First Value?

select * from batches join (
    select * from (
        select *, row_number() over (
            partition by batch_id  
            order by date ASC
        ) as row_num
        from batch_schedule where display = 'Yes'
    ) as d_batch_schedule
    where d_batch_schedule.row_num = 1
) as f_batch_schedule
on batches.id = f_batch_schedule.batch_id
WHERE (f_batch_schedule.date BETWEEN '2021/01/01' AND '2021/04/30')

This query works but how to write in laravel?

Apr
16
1 month ago
Activity icon

Replied to How To Get Value Based On Hasmany Table First Value?

It's returning based on all data values from the schedule table not based on first row value.

Apr
13
1 month ago
Activity icon

Replied to How To Load View Part By Part In Laravel?

No I don't have million students.

Yes. I am trying to do filtering in view rather than fetching data after filtering. Because most of the data are need to be conditionally used in view.

So I am fetching the data and filtering it in view. All the tables involved having relation with each other.

so I am having only one function in controller and fetching the data and filtering in the view based on conditions.

Activity icon

Replied to How To Load View Part By Part In Laravel?

It's a report part so the user need to see all at once to compare whether the student have attended, completed something like that.

I will try different end points.

Activity icon

Replied to How To Load View Part By Part In Laravel?

There is no difference in Query parameters. 1st datatable is fetching student history of courses 2nd datatable is fetching student attendances 3rd datatable is fetching their assessment results.

1st datatable loads data from one table (student_course_table). 2nd datatable loads data from two tables (student_course_table) and (attendance table) 3nd datatable loads data from two tables (student_course_table) and (assessments table).

1st datatable is ok as it loads from student_course_table the data fetched directly and there's no filtering so it loads fast.

for 2nd and 3rd datatables I am having more conditions inside like if else, foreach, for so it take long to load. What I am trying to achieve is 1st I need to load 1st datatable after that 2nd & 3rd.

All the three is for report purposes with comparison so everything should be in the same page.

Activity icon

Started a new Conversation How To Load View Part By Part In Laravel?

I am fetching data from database to view. I am having 3 different datatables with some filters. Loading all together taking about 16 seconds. I need to first load the 1st datatable and after that I need to load the other 2 one by one.

I have tried ajax to fetch data after page load but I don't know how to write function in controller to load 1st datatable and load other two after sometime / some conditions, because for these 3 datatables I am fetching data from same tables comparing with some other tables but in the view I am doing some filtering so it takes a longer time to load fully.

Is there any way I can achieve this?

Apr
09
2 months ago
Activity icon

Replied to How To Get Value Based On Hasmany Table First Value?

On trying first()

Illuminate \ Database \ QueryException (42S22)
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'batches.id' in 'where clause' (SQL: select * from `batch_schedule` where `batches`.`id` = `batch_schedule`.`batch_id` and `date` between 2021/04/12 and 2021/04/30 and `batch_schedule`.`deleted_at` is null limit 1)

On trying limit(1) it still returns based on all schedule dates.

Activity icon

Replied to How To Get Value Based On Hasmany Table First Value?

On trying this it's returning based on all schedule dates not the first date.

Apr
08
2 months ago
Activity icon

Replied to How To Get Value Based On Hasmany Table First Value?

$allData = Batch::whereHas(['schedule' => function($query) use ($aStartDate, $aEndDate){
	$query->whereBetween('date', [$aStartDate, $aEndDate])->orderBy('date', 'desc');
}])->paginate(10);

dd($allData);
ErrorException (E_WARNING)
strpos() expects parameter 1 to be string, array given

I am getting this error.

Activity icon

Replied to How To Get Value Based On Hasmany Table First Value?

@neilstee

This is what I am doing exactly but my concern is I need to return batches based on batch schedule first row value.

Activity icon

Started a new Conversation How To Get Value Based On Hasmany Table First Value?

I am having two tables batches and batch_schedules. Batches is having hasmany relationship with batch_schedules. Batches table consists of batch details and batch_schedules consists of dates & times of the schedules.

I am trying to filter batches based on batch_schedules dates. How to filter based on first date of each batches?

For Eg: Consider Batches Table having 1 row

id | Name
3	| AA1

Conside Batch_schedules having 3 rows

id | Batch_id | Date | Time
2   |  3 | 2021/04/09 | 10:00 AM
3    | 3  | 2021/04/10 | 10:00 AM
4   | 3   | 2021/04/11 | 10:00 AM

id 2 in batch_Schedules is the starting date. So I need to filter based on starting date. If my filter start date is 2021/04/08 and end date is 2021/04/11 it should display batches (id: 3).

If my filter start date is 2021/04/10 and end date is 2021/04/11 it should not display anything as there is no start date in between the filtered dates.

Mar
31
2 months ago
Activity icon

Replied to Laravel Validation Misreading File Extension?

You can check using an if condition in the controller if this issue still persists.

$extension = $request->video->getClientOriginalExtension();
            if($extension !== 'mp4'){
                return redirect()->back()->with('error', 'You can only upload mp4 files');
            }