lilo

Member Since 6 Months Ago

Experience Points
4,870
Total
Experience

130 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
1
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
4,870 XP
Jan
21
4 days ago
Activity icon

Started a new Conversation Setting The Blade To Run On Another Url

Hi,

I have a blade at http://127.0.0.1:8000/service-request-form. But I want to run this url in an external url that is not in project.

Does Laravel have a feature that will allow me to do this? Thanks in advance

Jan
19
6 days ago
Activity icon

Replied to Laravel Pagination Problem

Hi @nimrod thanks for answering. I use Laravel 8. And what do you mean saying this:

Remember, the HTML generated by the links method is compatible with the Tailwind CSS framework.

Activity icon

Started a new Conversation Laravel Pagination Problem

Hi,

I want to paginate my blade.

My route:

Route::get('/publicatons', function () {
$publications = Publications::orderBy('date','DESC')->paginate(5);
return view('our_publications',['publications'=>$publications]);});

My blade:

<section>
    <div class="container">
        <div class="row">
            <div class="masonry masonry-blog">
                <div class="masonry__container masonry--animate">
                    @foreach($publications as $publication)
                    <div class="col-md-6 col-sm-6 masonry__item">
                            <div class="card card-4">
                                <div class="card__image">
                                    <img alt="Pic" src="{{ $publication->photo->first()->url }}" height="350px" width="600px"/>
                                </div>
                                <div class="card__body boxed boxed--sm bg--white">
                                    <div class="card__title">
                                        <h5>{!! $publication->text !!}</h5>
                                    </div>
                                    <hr>
                                    <div class="card__lower">
                                        <span class="h6">{{ $publication->date }}</span>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </div>
                    @endforeach
                </div>
                <!--end masonry container-->
            </div>
            <!--end masonry-->
        </div>
        //Here is my links
        <div class="d-flex justify-content-center">
            {{ $publications->links() }}
        </div>
    </div>
    <!--end of container-->
</section>

Links work fine but instead of page numbers, it writes "gghgh hjhjhjh»". And When I do pagination, I get [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. error on console. How can I change them into numbers and fix this?

Jan
18
1 week ago
Activity icon

Replied to Pop Up Close Button Problem

Thanks a lot!

Activity icon

Replied to Pop Up Close Button Problem

Thanks @automica I took it. But I need the button on my pop up box, in the upper right corner. But when I do it it looks out of the box. You have any idea?

Activity icon

Replied to Pop Up Close Button Problem

Thanks for your response. @nimrod But I only have one data now. And when I remove the button part outside the foreach, the problem still continues.

Activity icon

Replied to Pop Up Close Button Problem

@nimrod edited the code

Activity icon

Started a new Conversation Pop Up Close Button Problem

Hi,

I have a pop up on my index page. The close button is at the top of the popup. Clicking somewhere in the pop up box goes to a specific link. I want the close button to appear in the top right inside the pop up box. But when I put it in the pop up box and click on it, it goes to link and doesn't close.

Here is my code and script:

<div id="popup" class="popup panel panel-primary rounded">
@foreach($popup as $pop)
        <!-- Now this is the button which closes the popup-->
            <div class="panel-footer">
                <div style="float: right;margin-right: 5px;margin-bottom: -10px">
                    <button id="close" class="btn btn-default btn-xs" style="margin-top:10px;color: black;">x</button>
                </div>
            </div>
            <center><a  href="{{ $pop->link }}"target="_blank"><img src="{{ $pop->photo->url }}" alt="popup"></a></center>
    @endforeach
<script>

    $(document).ready(function () {
        //select the POPUP FRAME and show it
        $("#popup").hide().fadeIn(1000);

        //close the POPUP if the button with id="close" is clicked
        $("#close").on("click", function (e) {
            e.preventDefault();
            $("#popup").fadeOut(1000);
        });
    });
</script>

How can I make the pop up close when the button is clicked? Thanks in advance

Jan
14
1 week ago
Activity icon

Started a new Conversation Failed To Load Resource: Net::ERR_NAME_NOT_RESOLVED

Hi,

I'm trying to insert image inside ck editor text area in my panel. But it gives this error:

Failed to load resource: net::ERR_NAME_NOT_RESOLVED

But when I put image in photo field in my panel, that works well and displays them without error. When I try to insert image in my text area it works well on my localhost too. But on live, I'm getting error.

What could cause this? Thanks in advance.

Jan
12
1 week ago
Activity icon

Replied to Remove Header And Footer From The Last Page Of Pdf Using Css

Anyone have any other ideas about this?

Activity icon

Replied to Remove Header And Footer From The Last Page Of Pdf Using Css

@michaloravec Is there any tutorial you suggest to do it using a blade?

Activity icon

Replied to Remove Header And Footer From The Last Page Of Pdf Using Css

Would it be better? And is it impossible to remove header and footer in this state? @michaloravec

Activity icon

Started a new Conversation Remove Header And Footer From The Last Page Of Pdf Using Css

Hi, I'm using laravel dompdf and I have a cover page that is generated at the end of my pdf. But I don't want header and footer to appear on the last page.

Here is my code:

$output='<html><body>
		     <div class="firstpage">
                            <img src="...">
                         </div>
                         <div id="header">
                            <img src="..." width="700px" height="104px">
                          </div>                          
             	      <div id="content">';
            $output .= '
                <html>
                    <head>
                      <style>
                        @page { margin: 180px 60px;}
                        #header { position: fixed; left: 0px; top: -150px; right: 0px; height: 100px;  text-align: center; }
                        #footer{ position: fixed; left: -20px; bottom: -150px; right: 0px; height: 100px; }
                        .firstpage {
                            page-break-after: always;
                        }
                        .lastpage{
			//Which css attribute can I have here to remove header and footer?
                         }
                      </style>
                    </head>
                    <body>
                   		<div id="content">

                      	 ......
                    	</div>  
                  
                    </body>   
                </html>

        $output .= '<div id="footer">       
                        		<img src="...." width="700px" height="104px">        
                   		</div>';

    $output .= '       
                 <div class="lastpage">
		// I want to remove the header and footer from this page
                    <img src="..." height="740px" width="521px">
                 </div>
                </body>
                
                </html>';
    return $output;

All the pages except the first page has header and footer in it. But I want to remove them from the div which has "lastpage" as class. How can I do it using css? Thanks in advance

Activity icon

Replied to How To Detect The Last Page Of Pdf

@forrestedw While doing this, I used a tutorial on the internet.( https://github.com/barryvdh/laravel-dompdf/issues/452 ) I firstly set this option:

$pdf->getDomPDF()->set_option("enable_php", true);

Then put the script inside body tag

$output .= '
		....
		<script type="text/php">
                    if (isset($pdf)) {
                        $text = "page {PAGE_NUM} / {PAGE_COUNT}";
                        $size = 10;
                        $font = $fontMetrics->getFont("Verdana");
                        $width = $fontMetrics->get_text_width($text, $font, $size) / 2;
                        $x = ($pdf->get_width() - $width) / 2;
                        $y = $pdf->get_height() - 35;
                        $pdf->page_text($x, $y, $text, $font, $size);
                    }
                </script>';

With the help of this I displayed page number at the end of each page.And I tried to use these page numbers in if condition. I don't know if this is a good option but I tried

Activity icon

Replied to How To Detect The Last Page Of Pdf

@forrestedw nope :( I don't understand why I cannot access PAGE_NUM and PAGE_COUNT variables

Jan
11
2 weeks ago
Activity icon

Started a new Conversation How To Detect The Last Page Of Pdf

Hi,

I generate a pdf file in my controller. And for each page(except the first page), a header a footer is displaying. At the bottom of the page, I print the page number. I want to remove footer from the last page of pdf so I tried something like this:

            $output .= '
                <html>
                    <head>
                      <style>
                         .pagenum:before { content: "Page " counter(page); }
                      </style>
                    </head>
                    <body>
            
                    <div id="content">

                       ... my content here...

                    </div>  
		//Using this script I print my page number at the end of each page
                    <script type="text/php">
                        if (isset($pdf)) {
                            $text = "page {PAGE_NUM} / {PAGE_COUNT}";
                            $size = 10;
                            $font = $fontMetrics->getFont("Verdana");
                            $width = $fontMetrics->get_text_width($text, $font, $size) / 2;
                            $x = ($pdf->get_width() - $width) / 2;
                            $y = $pdf->get_height() - 35;
                            $pdf->page_text($x, $y, $text, $font, $size);
                        }
                    </script>
                    </body>   
                </html>
            ';
            $first=false;
        }

    }

//Doing this, I want to display the footer on the pages except the last one
if(PAGE_NUM == PAGE_COUNT){
    $output .= '<div id="footer">       
                       
                      </div>';
}
    return $output;

But When I do like this I get this error:

ErrorException Use of undefined constant PAGE_NUM - assumed 'PAGE_NUM' (this will throw an Error in a future version of PHP)

How can I fix this? Hope it is clear. Thanks in advance.

Jan
09
2 weeks ago
Activity icon

Replied to How To Create Column In Table Using Foreach

Thanks for your help @forrestedw but I get this error: ErrorException Undefined variable: loop

And I wrote the foreach loop like this : foreach(){ }, because I get a syntax error when I write otherwise

Activity icon

Started a new Conversation How To Create Column In Table Using Foreach

Hi,

I want to create a dynamic table according to the number of arrays that are returned. To be more specific, I get some data from database using a query and put the data in table. But if there is more than one array, I want a td tag created for each array and its data printed there.

Here is my code:

$analysisReports = $this->get_customer_data($id);
    //In $analysisReports, I get the data from database.
    $output='<html><body><div id="content">';

    foreach($analysisReports as $analysisReport) //When I put foreach like this, for each array a table is created. But what I want to do is create only one table.
    {
        $output .= '
            <html>
                <body>
                  <div id="content">
                      
                            <table width="100%">
                            
			//I want <td> to create as many columns as the returned array in analysisReports.
                            <tr><th>Row 1</th><td colspan="6">'.$analysisReport->row1.'</td><td colspan="1">Unit</td></tr>
                            <tr><th>Row2</th><td colspan="6">'.$analysisReport->row2.'</td><td colspan="1">Unit</td></tr>
                            </table>  
                             
                  </div>                              
                </body> 
            </html>

        ';
    }
    $output .= '</div></body></html>';
    return $output;

I hope I could explain it properly. Thanks in advance.

Jan
08
2 weeks ago
Activity icon

Replied to How To Display More Than One Array For A Pdf

@forrestedw hey! thanks for your answer it's really helpfull. How about printing the same columns of the arrays in one table?

For example:

<table width="100%" style="border-collapse: collapse;">
                            <tr><th style="border: 1px solid; padding:3px;text-align:lef" width="35%">Name:</th><td colspan="7" style="border: 1px solid; padding:3px;">'.$analysisReport->name.'</td></tr>
</table>

How can I print the names of the reports on the same tag?

Jan
07
2 weeks ago
Activity icon

Started a new Conversation How To Display More Than One Array For A Pdf

Hi,

I retrieve data from my database and make a pdf using these data. But when there is more than one report that are created at the same date, I need to get all of them and print the colums of these reports on the pdf.

I get the reports that are created at the same date in the $analysisReports. When I do dd($analysisReports), the output is:

Illuminate\Database\Eloquent\Collection {#1544 ▼

#items: array:2 [▼ 0 => App\Models\AnalysisReport {#1582 ▶} 1 => App\Models\AnalysisReport {#1545 ▶} ] }

How can I display the data of both arrays? Here is my code:

$analysisReports = $this->get_customer_data($id);
    //dd($analysisReports); Here I get the arrays

    foreach($analysisReports as $analysisReport)
    {
        $output = '
            <html>
               
                <body>
                 
                  <div id="content">
                        <div>
			//I need to show the firm name and the report nos of both arrays
                            <p>Costumer: '.$analysisReport->costumer->firm_name.'<span style="float:right;display: block;">Report No: '.$analysisReport->report_no.'</span></p>
                           
                        </div>
                             
                  </div>  
                 
                </body> 
                          
            </html>

        ';
    }
    return $output;
Jan
06
2 weeks ago
Activity icon

Replied to Error While Comparing Two Dates In Query

Hi @nakov , yes in my model, date_received is in the dates array like this:

protected $dates = [
    'date_received',
    'created_at',
    'updated_at',
    'deleted_at',
];
Activity icon

Started a new Conversation Error While Comparing Two Dates In Query

Hi,

I want to get the data where receive dates are equal. But I get this error:

Illuminate\Database\QueryException SQLSTATE[HY000]: General error: 1525 Incorrect DATE value: '05/12/2020' (SQL: select * from analysis_reports where date(date_received) = 05/12/2020 and analysis_reports.deleted_at is null)

Here is my code:

$analysisReports = AnalysisReport::where('id',$id)->get();
    foreach ($analysisReports as $analysisReport){
        $reports = AnalysisReport::all();
        foreach ($reports as $report){
            $analysisReps = AnalysisReport::where('costumer_id',$analysisReport->costumer_id)->get();
	//The problem starts here. I need to compare the dates of each reports in $analysisReps with all date in AnalysisReport model.
            foreach ($analysisReps as $analysisRep){
                $date = $analysisRep->date_received;
                $ar = AnalysisReport::whereDate('date_received',$date)->get();
            }
        }
    }

What's wrong here and how can I fix it? Thanks in advance

Activity icon

Started a new Conversation Count Results On Specific Date

Hi,

I want to take the data created in the last 7 days and make a chart from them.

I get the dates but could not count the number of data generated per day.

Here is my query:

$date = \Carbon\Carbon::today()->subDays(7);
            $record = Report::where('created_at', '>=', $date)->get();
            $numofrecord = $record->count();

How can I group these data day per day? Thanks a lot

Activity icon

Replied to ErrorException Undefined Variable

thank you SO much for all your help, it's working now @tray2

Activity icon

Replied to ErrorException Undefined Variable

@tray2 , I get this:

array:3 [▼ "label" => array:1 [▼ 0 => "2021-01-05" ] "data" => array:1 [▼ 0 => 1 ] "chart_data" => "{"label":["2021-01-05"],"data":[1]}" ]

Activity icon

Replied to ErrorException Undefined Variable

@tray2 I'm trying to make charts and it gives the error here, in the script tag:

$(function(){

    var cData = JSON.parse(`<?php echo $weekly; ?>`);
    var ctx = $("#bar-chart");


    var data = {
        labels: cData.label,
        datasets: [
            {
                label: "",
                data: cData.data,
                fill: false,
                borderColor: [
                    "#3B4B64",
                ],
                borderWidth: [1, 1, 1, 1, 1,1,1],

            }
        ]
    };

    //options
    var options = {
        responsive: true,
        title: {
            display: true,
            position: "top",
            text: "Weekly Report Number",
        },
        legend: {
            display: false,
            position: "bottom",
        },
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero: true
                }
            }]
        }
    };

    //create Bar Chart class object
    var chart1 = new Chart(ctx, {
        type: 'bar',
        data: data,
        options: options
    });

});
Activity icon

Replied to ErrorException Undefined Variable

Thanks a lot @tray2 ! By the way it start to give ErrorException Array to string conversion error How can I get rid of this?

Activity icon

Started a new Conversation ErrorException Undefined Variable

Hi,

I'm trying to pass variable to my view blade. There are many functions for one route so I made a class called Dashboard.php then pass the variables of the functions which are in that class, using a controller. But it gives:

ErrorException Undefined variable: weekly

Here is the functions in my Dashboard.php

public function WeeklyReportNumber()
{

            $date = \Carbon\Carbon::today()->subDays(7);
            $record = Report::where('created_at', '>=', $date)->get();
            $numofrecord = $record->count();
            $data = [];
            foreach ($record as $row) {
                $data['label'][] = $row->created_at->toDateString();
                $data['data'][] = (int)$numofrecord;
            }
            $data['chart_data'] = json_encode($data);
            return $data;
       
}

public function Name()
{
            $record = Report::all();
            $data = [];
            foreach ($record as $row) {
                $data['label'][] = $row->report_no;
                $data['data'][] = (float)$row->name;
            }
            $data['chart_data'] = json_encode($data);
            return $data;
}

Here is the DashboardController.php

public function index(){
        $dashboard = new Dashboard();
        $weekly = $dashboard->WeeklyReportNumber();
        $name = $dashboard->Name();
        return view('home')->with($weekly, $name);

}

And my route

Route::get('/home', [DashboardController::class,'index']);

I'm really stuck and I cannot see where I'm doing the error. Thanks in advance

Dec
28
4 weeks ago
Activity icon

Replied to How To Call Multiple Controller For One Route

Thanks again @nakov ! It was really revealing. I did all the things you said but I get Undefined variable: chart_data

Here is my function where this variable is located (App/Dashboard.php):

public function WeeklyReportNumber()
{
    $user = Auth::user();
    foreach ($user->roles as $role){

            $date = \Carbon\Carbon::today()->subDays(7);
            $record = AnalysisReport::where('created_at', '>=', $date)->get();
            $numofrecord = $record->count();
           
            $data = [];
            foreach ($record as $row) {
                $data['label'][] = $row->created_at->toDateString();
                $data['data'][] = (int)$numofrecord;
            }
            $data['chart_data'] = json_encode($data);

            return view('home', $data);
        
    }
}

And my controller:

public function index(){
    $dashboard = new Dashboard();
    $weekly = $dashboard->WeeklyReportNumber();
    $ph = $dashboard->Ph();
    $repNo = $dashboard->ReportNumber();
    return view('home')->with([ $weekly, $ph , $repNo]);

}

And here is the route:

Route::get('/home', [DashboardController::class,'index']);

What should I do more? Again thanks for all your help

Activity icon

Replied to How To Call Multiple Controller For One Route

Thanks for your reply @nakov ! I know it's an easy question but how should I create that one class? Because I pull my data on the controller. So the class should be created in index function?

Activity icon

Started a new Conversation How To Call Multiple Controller For One Route

Hello,

I want to display multiple charts in my dashboard. I made the charts in controllers but all need to call the same route.

Here is my web.php

Route::get('/home', [WeeklyReportController::class,'index']);
Route::get('/home', [DashboardPhController::class,'index']);
Route::get('/home', [ReportNumberController::class,'index']);

As above, they all overwrite each other. How can I get it?

Dec
23
1 month ago
Activity icon

Replied to How To Remove Header And Footer From Last Page Of Pdf

But when I remove these two, it disappears from all the pages. I want to remove from only the last page. @redroseamit

Activity icon

Started a new Conversation How To Remove Header And Footer From Last Page Of Pdf

Hello,

I generate a pdf using laravel dompdf and I have cover and end page.

I was able to remove the header and footer on the cover page, but I could not remove those on the end page.

How can I do it?

Dec
22
1 month ago
Activity icon

Replied to How To Check If Two Data Are Equal

Thanks a lot!

Activity icon

Replied to How To Check If Two Data Are Equal

@ftiersch Hi, I want to check customer_id colum in analysis reports table but not in all analysis reports.

I want to check through the analysis reports that I get with $userReports.

Activity icon

Started a new Conversation How To Check If Two Data Are Equal

Hello,

I know it's a newbie style silly question but here it is.

I have 2 data that I get from database. How can I check if they are equal?

$analysisReps = AnalysisReport::where('id',$id)->get();

            foreach ($analysisReps as $analysisRep) {
                
                $firms = Customer::where('id',$analysisRep->costumer_id)->get();
                
                foreach ($firms as $firm){
                    
                    $userReports = AnalysisReport::where('related_person_id',$user->id)->get();

                    foreach ($userReports as $userReport){

                        $record = AnalysisReport::where($firm->id,$userReport->costumer_id)->get();
                        
                    }
                }
            }

I want to check if $firm->id and $userReport-> costumer_id are equal and then, I want to get the analysis reports where they are equal. But it gives this error: SQLSTATE[42S22]: Column not found Because $ifrm->id is not in table. How to do it?

Thanks in advance.

Dec
17
1 month ago
Activity icon

Replied to Deployment Was Failed For Web Application While Deploying Master Branch

@martinbean In my local, I had installed the Laravel Charts package using these commands:

composer require consoletvs/charts:6.*
php artisan vendor:publish --tag=charts_config

Then the composer.lock file was pushed while pushing. Could this be what caused the problem? If so, how should I solve this?

Activity icon

Started a new Conversation Deployment Was Failed For Web Application While Deploying Master Branch

Hi,

When I push my code, it said "push successful" but gives this error :

Deployment was failed for Web Application while deploying master branch❌
Stdout

86ec2fc..6c62df9 Stderr bitbucket.org:portal.frontend 86ec2fc..6c62df9 master -> origin/master error: Your local changes to the following files would be overwritten by merge: composer.lock Please commit your changes or stash them before you merge. Aborting

What could have caused this? Thanks in advance.

Dec
13
1 month ago
Activity icon

Started a new Conversation ErrorException Class 'ConsoleTVs\Charts\Facades\Charts' Not Found

Hi,

I want to use charts package in a laravel project.

I firstly uploaded the package using:

composer require consoletvs/charts

Then created a controller like this:

public function index()
{
    $chart = Charts::create('pie', 'highcharts')
        ->title('My nice chart')
        ->labels(['First', 'Second', 'Third'])
        ->values([5,10,20])
        ->dimensions(1000,500)
        ->responsive(false);
    return view('charts',compact('chart')); }

And added these on the top of the controller:

namespace App\Http\Controllers;

use Illuminate\Http\Request; use App\Models\User; use DB; use Charts;

I also added these in config/app.php:

'providers' => [ .... .... ConsoleTVs\Charts\ChartsServiceProvider::class, ],

'aliases' => [ .... .... 'Charts' => ConsoleTVs\Charts\Facades\Charts::class, ],

But I'm getting this error constantly:

ErrorException Class 'ConsoleTVs\Charts\Facades\Charts' not found

Illuminate\Foundation\Bootstrap\HandleExceptions::handleError C:\Users...l\vendor\laravel\framework\src\Illuminate\Foundation\AliasLoader.php:80

How can I handle it?

Dec
11
1 month ago
Activity icon

Started a new Conversation Sending Form With An Attachment As Email

Hi,

I want to send the contact form as email. I'm using mailgun. But there is a file dropzone in the form and I want to add the pdf file into email. How to add it?

my route:

Route::get('send_career_email', function(){

if(!empty(request('first_name'))){
    
    return redirect()->back()->with('message','success');
}

Mail::to('[email protected]')
    ->send(new \App\Mail\ContactForm());

return redirect()->back()->with('message','Thanks.');

// Mail::raw('Sending emails with Mailgun and Laravel is easy!', function($message) // { // $message->to(); // }); });

career_form.blade.php;

@component('mail::message')

@component('mail::table')
    |                |                       |
    | -----------------       |          ----------------- |
    | Name                 | {{$data['name']}} |
    | Telephone         | {{$data['phone']}}|
    | Email                  | {{$data['email']}}|
    | Subject               | {{$data['subject']}}|
    | CV                        | {{$data['fileInput']}}|
    | Message             | {{$data['message']}}|

@endcomponent

@endcomponent

CareerForm.php

class CareerForm extends Mailable

{ use Queueable, SerializesModels; public $data; /** * Create a new message instance. * * @return void */ public function __construct() { // $this->data = request()->toArray(); }

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    //return $this->view('view.name');
    return $this->markdown('emails.career_form');
}

}

contact.blade.php

 <form class="contact-form" action="/send_career_email" method="get">
                {{--<div class="contact-form-success alert alert-success d-none mt-4">
                    <strong>Tebrikler!</strong> Mesajınız başarı ile ulaştı.
                </div>

                <div class="contact-form-error alert alert-danger d-none mt-4">
                    <strong>Hata!</strong> Bir hata oluştu, lütfen daha sonra tekrar deneyin.
                    <span class="mail-error-message text-1 d-block"></span>
                </div>--}}
                @if(Session::has('message'))
                    <p class="alert alert-success">{{ Session::get('message') }}</p>
                @endif
                @csrf
                <div class="form-row">
                    <div class="form-group col">
                        <label class="required font-weight-bold text-dark text-2">Ad Soyad</label>
                        <input type="text" value="" data-msg-required="Lütfen boş bırakmayınız." maxlength="100" class="form-control" name="name" required>
                    </div>
                </div>
                <div class="form-row">
                    <div class="form-group col-lg-6">
                        <label class="required font-weight-bold text-dark text-2">Telefon</label>
                        <input type="text" value="" data-msg-required="Lütfen boş bırakmayınız." maxlength="100" class="form-control" name="phone" required>
                    </div>
                    <div class="form-group col-lg-6">
                        <label class="required font-weight-bold text-dark text-2">Email</label>
                        <input type="email" value="" data-msg-required="Lütfen boş bırakmayınız." data-msg-email="Please enter a valid email address." maxlength="100" class="form-control" name="email" required>
                    </div>
                </div>
                <div class="form-row">
                    <div class="form-group col">
                        <label class="required font-weight-bold text-dark text-2">Konu</label>
                        <input type="text" value="İş Başvurusu" data-msg-required="Lütfen boş bırakmayınız." maxlength="100" class="form-control" name="subject" required>
                    </div>
                </div>
                <div class="form-row">
                    <div class="form-group col">
                        <label class="font-weight-bold text-dark text-2">Özgeçmiş (.pdf formatında)</label>
                        <div id="dropContainer">
                            <input type="file" id="fileInput" accept="application/pdf"/>
                        </div>
                    </div>
                </div>
                <div class="form-row">
                    <div class="form-group col">
                        <label class="required font-weight-bold text-dark text-2">Mesaj</label>
                        <textarea maxlength="5000" data-msg-required="Lütfen boş bırakmayınız." rows="8" class="form-control" name="message" required></textarea>
                    </div>
                </div>
                <div class="form-row">
                    <br><br>
                </div>
                <div class="form-row">
                    <div class="form-group col">
                        <input type="submit" value="Gönder" class="btn btn-primary btn-modern" data-loading-text="Lütfen Bekleyin...">
                    </div>
                </div>
            </form>
Dec
08
1 month ago
Activity icon

Started a new Conversation Adding Cover Page With Dompdf

Hello,

I transform my view blade to pdf. I want to add a cover page as first page and an end page as last page. The content of these pages will be photo. How can I add first and last page in my pdf?

Here is my controller:

$analysisReports = $this->get_customer_data($id);
    foreach($analysisReports as $analysisReport)
    {
        $output = '
            
            <html>
                <head>
                  <style>
                    @page { margin: 180px 50px; }
                    #header { position: fixed; left: 0px; top: -150px; right: 0px; height: 100px;  text-align: center; }
                    #footer { position: fixed; left: 0px; bottom: -150px; right: 0px; height: 100px; }
                   
                  </style>
                </head>  
                <body>
                  
                  <div id="header">
                    <img src="./pdf-header.jpg" width="700px" height="100px">
                  </div>
                  <div id="footer">
                    <img src="./pdf-footer.jpg" width="700px" height="100px">                        
                  </div>
                  <div id="content">
                       
                            <p style="text-align:left;font-family: DejaVu Serif;font-size: 12px"><strong>Costumer:</strong> '.$analysisReport->costumer->firm_name.'<span style="float:right;"><strong>Report No:</strong> '.$analysisReport->report_no.'</span></p>
                            <p style="text-align:left;font-family: DejaVu Serif;font-size: 12px"><strong>Related Person:</strong> '.$analysisReport->related_person->name.'<span style="float:right;"><strong>Report Date:</strong> '.$analysisReport->report_date.'</span></p>
                            <p style="text-align:right;font-family: DejaVu Serif;font-size: 12px"><strong>Sample Date Received:</strong> '.$analysisReport->date_received.'</span></p>
                            <h3 align="center" style="font-size: 20px;font-family: DejaVu Serif;">Analysis Report<br></h3>
                            <p style="text-align:left;font-family: DejaVu Serif;font-size: 12px"><strong>Sample Name</strong><br>'.$analysisReport->sample_name->sample_name.'</p>
                        </div>
                            <table width="100%" style="border-collapse: collapse; border: 0px;font-family: DejaVu Serif;font-size: 9px">
                            <tr><th style="border: 1px solid; padding:10px;font-size: 12px" width="70%">Cations-Metals </th><td colspan="6" style="border: 1px solid; padding:10px;text-align:right;font-size: 12px">Result / Sonuç</td><td colspan="1" style="border: 1px solid; padding:10px;text-align:right;font-size: 12px">Unit/Birim</td></tr>
                            <tr bgcolor="lightblue"><th style="border: 1px solid; padding:5px;" width="35%">Aluminum (Al)</th><td colspan="6" style="border: 1px solid; padding:5px;text-align:right">'.$analysisReport->aluminum.'</td><td colspan="1" style="border: 1px solid; padding:5px;text-align:right;font-size: 10px">mg/L</td></tr>
                           ...
                            </tr>
		</div>
                </body>
            </html>

        ';
    }
    $output .= '</table>';
    return $output;
Dec
03
1 month ago
Activity icon

Started a new Conversation How To Edit Ajax Request Query

Hi,

I got the required information with eloquent but I don't know how to display it in datatable.

My controller:

public function index(Request $request)
{
    abort_if(Gate::denies('analysis_report_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $user = Auth::user();
    foreach ($user->roles as $role){
        if ($role->title == 'Costumer'){
            $analysisReports = AnalysisReport::where('related_person_id',$user->id)->get();
            if ($request->ajax()) {
                $query = AnalysisReport::with(['costumer', 'related_person', 'sample_name', 'approved_by', 'created_by'])->select(sprintf('%s.*', (new AnalysisReport)->table));
                $table = Datatables::of($query);

                $table->addColumn('placeholder', '&nbsp;');
                $table->addColumn('actions', '&nbsp;');

                $table->editColumn('actions', function ($row) {
                    $viewGate      = 'analysis_report_show';
                    $editGate      = 'analysis_report_edit';
                    $deleteGate    = 'analysis_report_delete';
                    $crudRoutePart = 'analysis-reports';

                    return view('partials.datatablesActions', compact(
                        'viewGate',
                        'editGate',
                        'deleteGate',
                        'crudRoutePart',
                        'row'
                    ));
                });

                $table->editColumn('id', function ($row) {
                    return $row->id ? $row->id : "";
                });
                $table->addColumn('costumer_firm_name', function ($row) {
                    return $row->costumer ? $row->costumer->firm_name : '';
                });

                $table->addColumn('related_person_name', function ($row) {
                    return $row->related_person ? $row->related_person->name : '';
                });

                $table->editColumn('report_no', function ($row) {
                    return $row->report_no ? $row->report_no : "";
                });

                $table->addColumn('sample_name_sample_name', function ($row) {
                    return $row->sample_name ? $row->sample_name->sample_name : '';
                });

                $table->editColumn('aluminum', function ($row) {
                    return $row->aluminum ? $row->aluminum : "";
                });
                $table->editColumn('antimony', function ($row) {
                    return $row->antimony ? $row->antimony : "";
                });
                $table->editColumn('barium', function ($row) {
                    return $row->barium ? $row->barium : "";
                });
                $table->editColumn('cadmium', function ($row) {
                    return $row->cadmium ? $row->cadmium : "";
                });
                $table->editColumn('calcium', function ($row) {
                    return $row->calcium ? $row->calcium : "";
                });
                $table->editColumn('chromium', function ($row) {
                    return $row->chromium ? $row->chromium : "";
                });
                $table->editColumn('copper', function ($row) {
                    return $row->copper ? $row->copper : "";
                });
                $table->editColumn('iron', function ($row) {
                    return $row->iron ? $row->iron : "";
                });
                $table->editColumn('lead', function ($row) {
                    return $row->lead ? $row->lead : "";
                });
                $table->editColumn('magnesium', function ($row) {
                    return $row->magnesium ? $row->magnesium : "";
                });
                $table->editColumn('manganese', function ($row) {
                    return $row->manganese ? $row->manganese : "";
                });
                $table->editColumn('molbydenum', function ($row) {
                    return $row->molbydenum ? $row->molbydenum : "";
                });
                $table->editColumn('nickel', function ($row) {
                    return $row->nickel ? $row->nickel : "";
                });
                $table->editColumn('potassium', function ($row) {
                    return $row->potassium ? $row->potassium : "";
                });
                $table->editColumn('silicon', function ($row) {
                    return $row->silicon ? $row->silicon : "";
                });
                $table->editColumn('sodium', function ($row) {
                    return $row->sodium ? $row->sodium : "";
                });
                $table->editColumn('strontium', function ($row) {
                    return $row->strontium ? $row->strontium : "";
                });
                $table->editColumn('zinc', function ($row) {
                    return $row->zinc ? $row->zinc : "";
                });
                $table->editColumn('bromide', function ($row) {
                    return $row->bromide ? $row->bromide : "";
                });
                $table->editColumn('chloride', function ($row) {
                    return $row->chloride ? $row->chloride : "";
                });
                $table->editColumn('nitrite', function ($row) {
                    return $row->nitrite ? $row->nitrite : "";
                });
                $table->editColumn('nitrate', function ($row) {
                    return $row->nitrate ? $row->nitrate : "";
                });
                $table->editColumn('sulfate', function ($row) {
                    return $row->sulfate ? $row->sulfate : "";
                });
                $table->editColumn('inorganic_phosphate', function ($row) {
                    return $row->inorganic_phosphate ? $row->inorganic_phosphate : "";
                });
                $table->editColumn('organic_phosphate', function ($row) {
                    return $row->organic_phosphate ? $row->organic_phosphate : "";
                });
                $table->editColumn('total_phosphate', function ($row) {
                    return $row->total_phosphate ? $row->total_phosphate : "";
                });
                $table->editColumn('m_alkalinity', function ($row) {
                    return $row->m_alkalinity ? $row->m_alkalinity : "";
                });
                $table->editColumn('p_alkalinity', function ($row) {
                    return $row->p_alkalinity ? $row->p_alkalinity : "";
                });
                $table->editColumn('ph', function ($row) {
                    return $row->ph ? $row->ph : "";
                });
                $table->editColumn('calcium_hardness', function ($row) {
                    return $row->calcium_hardness ? $row->calcium_hardness : "";
                });
                $table->editColumn('magnesium_hardness', function ($row) {
                    return $row->magnesium_hardness ? $row->magnesium_hardness : "";
                });
                $table->editColumn('total_hardness', function ($row) {
                    return $row->total_hardness ? $row->total_hardness : "";
                });
                $table->editColumn('conductivity', function ($row) {
                    return $row->conductivity ? $row->conductivity : "";
                });
                $table->editColumn('dissolved_solid', function ($row) {
                    return $row->dissolved_solid ? $row->dissolved_solid : "";
                });
                $table->editColumn('suspended_solid', function ($row) {
                    return $row->suspended_solid ? $row->suspended_solid : "";
                });
                $table->editColumn('polyamine', function ($row) {
                    return $row->polyamine ? $row->polyamine : "";
                });
                $table->editColumn('free_chlorine', function ($row) {
                    return $row->free_chlorine ? $row->free_chlorine : "";
                });
                $table->editColumn('bond_chlorine', function ($row) {
                    return $row->bond_chlorine ? $row->bond_chlorine : "";
                });
                $table->addColumn('approved_by_name', function ($row) {
                    return $row->approved_by ? $row->approved_by->name : '';
                });

                $table->rawColumns(['actions', 'placeholder', 'costumer', 'related_person', 'sample_name', 'approved_by']);

                return $table->make(true);
            }
        }

In $analysisReports variable, I have the reports but How can I Display only these data on the datatable? Now I see all the data.

Thanks in advance

Dec
01
1 month ago
Activity icon

Started a new Conversation Viewing Data Linked To The Logged In User

Hi,

I have a panel and three different types of users. In the panel, there is a analysis report crud. Employee can create a new analysis report and while filling the report, he ust choose a client. And then when the client logs in to the panel, he must only see the analysis reports which are linked to him.

Here is my index function in my controller, I guess I should make the change in this query:

public function index(Request $request)
{
    abort_if(Gate::denies('analysis_report_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    if ($request->ajax()) {
        $query = AnalysisReport::with(['costumer', 'related_person', 'created_by'])->select(sprintf('%s.*', (new AnalysisReport)->table));
       //the query is above
        $table = Datatables::of($query);

        $table->addColumn('placeholder', '&nbsp;');
        $table->addColumn('actions', '&nbsp;');

        $table->editColumn('actions', function ($row) {
            $viewGate      = 'analysis_report_show';
            $editGate      = 'analysis_report_edit';
            $deleteGate    = 'analysis_report_delete';
            $crudRoutePart = 'analysis-reports';

            return view('partials.datatablesActions', compact(
                'viewGate',
                'editGate',
                'deleteGate',
                'crudRoutePart',
                'row'
            ));
        });

        $table->editColumn('id', function ($row) {
            return $row->id ? $row->id : "";
        });
        $table->addColumn('costumer_firm_name', function ($row) {
            return $row->costumer ? $row->costumer->firm_name : '';
        });

        $table->addColumn('related_person_name', function ($row) {
            return $row->related_person ? $row->related_person->name : '';
        });

        $table->editColumn('report_no', function ($row) {
            return $row->report_no ? $row->report_no : "";
        });

       

        $table->rawColumns(['actions', 'placeholder', 'costumer', 'related_person']);

        return $table->make(true);
    }

    $customers    = Customer::get();
    $users        = User::get();
    $sample_names = SampleName::get();
    $users        = User::get();
    $users        = User::get();

    return view('admin.analysisReports.index', compact('customers', 'users', 'sample_names', 'users', 'users'));
}

How can I write the proper query for my problem?

Thanks in advance.

Nov
10
2 months ago
Activity icon

Started a new Conversation How To Slip Pop Up Box As The Page Is Scrolled

Hello,

I made a pop up box which is opening when the page is loading. How can I slip pop up box too as the page is scrolled? Thanks in advance!

Here is my css:

#popup {

display:none;

background-color: #1b551e;

position: absolute;

margin:0 auto;

top: 93%;

left:80%;

transform: translate(-5%, -90%);

box-shadow: 0px 0px 50px 2px #000;

}

My index page:

<div id="popup" class="popup panel panel-primary">
		
		<p style="color: white">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

		<div class="panel-footer">
			<button id="close" class="btn btn-lg btn-primary">Close</button>
		</div>
	</div>

My js:

<script>
	$(document).ready(function () {
		$("#popup").hide().fadeIn(1000);

		$("#close").on("click", function (e) {
			e.preventDefault();
			$("#popup").fadeOut(1000);
		});
	});
</script>
Activity icon

Started a new Conversation Popup On Bottom Of Page

Hi,

I want to display a pop up at the bottom of my index page. But when I go down, the pop up box doesn't appear. What's wrong here?

Thanks a lot. PS: I take the code from here : https://codepen.io/JKDEV/pen/yjLLNj but in my code it doesn't work well.

I take only the pop up part of the css

And here is my index page:

		<!-- Popup START-->
	<div class="popup">
		<div class="close ns-close"></div>
	</div>
	<div class="arrow animated bounce"></div>
	<!--  Popup END -->

	<script>
	$(function() {
		var wrap = $(".wrap.fixed");
		$(window).scroll(function() {
			var scroll = $(window).scrollTop();
			if (scroll >= 50) wrap.addClass("sticky");
			else wrap.removeClass("sticky");
		});
	});

	$(document).ready(function() {

		$(window).scroll(function() {
			if ($(window).scrollTop() >= ($(document).height() - $(window).height())) {
				$('.popup').css( "right", "20px" )
				$('.arrow').hide();
			}else{
				$('.popup').css( "right", "-380px" );
				$('.arrow').show();
			}
		});

		$('.close').click(function(){
			$('.popup').hide();
		});


	});
	$('.arrow').click(function(){
		$("html").animate({ scrollTop: $('html').prop("scrollHeight")}, 1200);
		$('.popup').show();
	});
</script>