Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

konrms

konrms

Member Since 1 Year Ago

Experience Points
3,190
Total
Experience

1,810 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
9
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 1
3,190 XP
Oct
02
1 month ago
Activity icon

Replied to Passing Variable From Controller To Blade With Loop (@for Inside @foreach)

@michaloravec The table column number is changing upon user input so I have to somehow pass relevant data to blade...

Activity icon

Replied to Passing Variable From Controller To Blade With Loop (@for Inside @foreach)

@raheelkhan Thank you very much for your help. It works fine.

Activity icon

Started a new Conversation Passing Variable From Controller To Blade With Loop (@for Inside @foreach)

Hello Everyone!

I have created a database table inside my controller and populated it. Variable $i is initialized ($i=1). $n is inserted by the user and represents year values. Score is the year sum for each year per individual. The following code is the controller excerpt with the table creation which works right (using the while loop the table columns year(i) are automatically created depending on n value).

$n  = $p -> input('n');
$i = 1;  //initialization

if (Schema::hasTable('abc'))     
	{
		Schema::drop('abc');				
	}
						
Schema::create('abc', function (Blueprint $table) use ($n, $i)  
	{
		$table->increments('aa');	
		$table->string('last_name') -> nullable();		
		$table->string('first_name') -> nullable(); 
								
			while($i <= $n) 
				{
					$table->integer('year'.$i.'') -> nullable();
					$i++;
				}

		$table->decimal('score', 5, 4) -> nullable();
	});

//code bla bla bla

$data = DB::table('abc') ->get();   // We collect everything and store into $data
				
return view('result', ['data'=>$data, 'n'=>$n]);

My question has to do with the result blade where I fail to produce the results for the value of year(i) for i values in 1<= i <=n. Below is my result.blade.php excerpt. I want to pass year1, year2,... to the respective headings. I have tried many different combinations but always with an error (I want to produce something like {{ $v2 -> year }}.{{ i }}).

<table border="1">
    <tr>
        <th>aa</th>
        <th>LAST NAME</th>
        <th>FIRST NAME</th>
       		@for($i = 1; $i <= $n; $i++)
		<th>YEAR{{ $i }}</option></th>      // --> THIS WORKS (we get year1, year2,... table headings right)!!
		@endfor
	<th>Total Score</th>
    </tr>
	

@foreach($data as $v2)
   	 <tr>
        	<th>{{ $v2->aa }}</th>
       		 <td>{{ $v2->last_name }}</td>
		<td>{{ $v2->first_name }}</td>
        
			@for($i = 1; $i <= $n; $i++)
				<td>{{ $v2 -> year  }}.{{ i }}</td>   // --> HERE IS MY PROBLEM!! <--
			@endfor
		<td>{{ $v2->score }}</td>    	
</tr>

@endforeach

</table>

Thank you a lot!!

Jul
16
4 months ago
Activity icon

Replied to Requesting User Where To Save Exported File

@snapey , yes the file is created inside public folder...

Activity icon

Replied to Requesting User Where To Save Exported File

Hello @snapey

Upon LAN users request execution on server, the code runs and saves zip file inside laravel's public folder on server, but users are not prompted to download it.

I added that line to the excerpt above

return response()->download(public_path('zipped_gr_'.$we.'.zip'));

but I get error

"C:\xampp\htdocs\laravel\public\zipped_gr_16072020100113.zip" does not exist.

But zipped_gr_16072020100113.zip exists in public folder.

Activity icon

Started a new Conversation Requesting User Where To Save Exported File

Hello everyone.

I use phpWord library for creating MS-Word forms in laravel. The forms are named after several id numbers (e.g. 1021052.doc, 1021053.doc etc). After the forms are created, they are zipped using the Zip library. The zip file is saved inside \laravel\public\ folder as zipped_gr_[current date and time].zip file.

I want each time the code is run and the zip file is created, the user to be asked where to save that zip file (eg desktop). And how can this be done when the laravel project is running on the server over the network?

What I have done:

This is my controller code performing the specific operation:

foreach($regs as $i) 

{

....  //code

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
	try 
		{
			$objWriter->save(storage_path('zipped_gr\.'.$i->id.'_gr.docx'));  

//this saves files inside laravel\storage\zipped_gr folder for each id
			
			continue;
		}  
		catch (Exception $e) 
			{
			}
			
			return response()->download(storage_path('zipped_gr\.'.$i->id.'_gr.docx')); 
			continue;
			
}   //foreach ends here
				
$we = Carbon::now();  
$we = Carbon::createFromFormat('Y-m-d H:i:s', $we)->format('dmYHis');

$zip = Zip::create('zipped_gr_'.$we.'.zip');   
$zip->add('c:\xampp\htdocs\laravel\storage\zipped_gr'); //this saves inside public as 
//	zipped_gr_16072020075926

Thank you a lot!

Jun
26
4 months ago
Activity icon

Replied to Shibboleth Authentication

Hi @prasadchinwal5 !

Well, it seems the time to put server into production environment has come. The laravel project is installed on our server (I haven't added shibboleth package yet on it).

However, as mentioned in previous post, I have installed shibboleth with Shibalike emulation on my windows laptop laravel project, following https://github.com/uabookstores/laravel-shibboleth guide and secured (with success) a desired route by applying the following excerpt inside the corresponding blade

@if (Auth::guest())
    <a href="/shibboleth-login">Login</a>
@else
    <a href="/shibboleth-logout">
        Logout {{ Auth::user()->name }}
    </a>
@endif

Now, regarding the server, I guess I should add shibboleth package omitting the steps for shibalike emulation. How should I edit config/shibboleth.php for existing organization users? Is just this needed for users to be prompted for their individual authentication credentials when trying to open the specific link?

Thank you a lot!

May
28
5 months ago
Activity icon

Replied to Formatting Exported Excel File

Hi @deepu07

I have declared my border style as below:

//border style
		$styleArray = [
				'borders' => [
					'outline' => [
						'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
					//'color' => ['argb' => 'FFFF0000'],
						],
					],
				];	

This is later used like this:

 return [
            AfterSheet::class => function(AfterSheet $event) use ($styleArray, $styleArray1, $styleArray2, 
            $styleArray3, $styleArray4 , $styleArray5)

To help you more, I have attached the solution I applied on the whole, rearding the styling I have used. I have formatted headings, added borders and fixed width. Each type of format I have used ($styleArray1, $styleArray2, ...) is well declared.

I hope I have helped!

<?php

namespace App\Exports;

use App\Member;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings; 
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;

class MembersExport implements FromCollection, WithHeadings, WithEvents//, ShouldAutoSize  
{
    public function collection()
    {
        return Member::all();
    }
	
	public function headings(): array
    {
        return 
		[
            'HEAD1',
            'HEAD2',
            'HEAD3',
            'HEAD4',
            'HEAD5',
	    'HEAD6',
	    'HEAD7',
        ];
    }
	
	 public function registerEvents(): array
    {

		//border style
		$styleArray = [
				'borders' => [
					'outline' => [
						'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
					//'color' => ['argb' => 'FFFF0000'],
						],
					],
				];	
		
		//font style	
		$styleArray1 = [
						'font' => [
							'bold' => true,
							]
						];
		
		//column  text alignment
		$styleArray2 = array(
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				 )
		);				
		
		//$styleArray3 used for vertical alignment 
		$styleArray3 = array(
			'alignment' => array(
				'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
				 )
		);
		

		$styleArray4 = array(
						'fill' => [
        'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
        'startColor' => [
        'argb' => 'FFA0A0A0',
        ],
        'endColor' => [
            'argb' => 'FFFFFFFF',
        ]]
					);
		
		$styleArray5 = array(
						'fill' => [
        'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
        
        'startColor' => [
            'argb' => 'E0E0E0',
        ]]);
		
		
			
				
        return [
            AfterSheet::class => function(AfterSheet $event) use ($styleArray, $styleArray1, $styleArray2, 
            $styleArray3, $styleArray4 , $styleArray5)
			{
                		$cellRange = 'A1:G1'; // All headers
                		$event->sheet->getDelegate()->getStyle($cellRange)->getFont()->setSize(13);
				$event->sheet->getStyle($cellRange)->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A9:G9')->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A12:G12')->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A19:G19')->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A27:G27')->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A31:G31')->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A35:G35')->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A36:G36')->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A42:G42')->ApplyFromArray($styleArray);
				$event->sheet->getStyle('A43:G43')->ApplyFromArray($styleArray);
				
							
//Heading formatting...
			 	$event->getSheet()->getDelegate()->getStyle('A1:G1')->applyFromArray($styleArray);						
				$event->getSheet()->getDelegate()->getStyle('A1:G1')->applyFromArray($styleArray1);
							
							
							//used for making bold
				$event->getSheet()->getDelegate()->getStyle('A9:G9')->applyFromArray($styleArray1);
				$event->getSheet()->getDelegate()->getStyle('A12:G12')->applyFromArray($styleArray1);
				$event->getSheet()->getDelegate()->getStyle('A19:G19')->applyFromArray($styleArray1);
				$event->getSheet()->getDelegate()->getStyle('A27:G27')->applyFromArray($styleArray1);
				$event->getSheet()->getDelegate()->getStyle('A31:G31')->applyFromArray($styleArray1);
				$event->getSheet()->getDelegate()->getStyle('A35:G35')->applyFromArray($styleArray1);
				$event->getSheet()->getDelegate()->getStyle('A36:G36')->applyFromArray($styleArray1);
				$event->getSheet()->getDelegate()->getStyle('A42:G42')->applyFromArray($styleArray1);
				$event->getSheet()->getDelegate()->getStyle('A43:G43')->applyFromArray($styleArray1);
							
							
							//column width set							
				$event ->sheet-> getDelegate()->getColumnDimension('A')->setWidth(65);
				$event ->sheet-> getDelegate()->getColumnDimension('B')->setWidth(64);
				$event ->sheet-> getDelegate()->getColumnDimension('C')->setWidth(13);
				$event ->sheet-> getDelegate()->getColumnDimension('F')->setWidth(12);
				$event ->sheet-> getDelegate()->getColumnDimension('G')->setWidth(11);
							
							
							//D & E column width set to 17
				$columns = ['D', 'E'];
					foreach ($columns as $column) {
						$event ->sheet-> getDelegate()->getColumnDimension($column)->setWidth(17);	
							}
							
							//D1 & E1 text wrapping...
				$event ->sheet->getStyle('D1')->getAlignment()->setWrapText(true);	
				$event ->sheet->getStyle('E1')->getAlignment()->setWrapText(true);	
							
							//text center columns...
				$event ->sheet->getStyle('C1:C43')->applyFromArray($styleArray2);
				$event ->sheet->getStyle('D1:D43')->applyFromArray($styleArray2);
				$event ->sheet->getStyle('E1:E43')->applyFromArray($styleArray2);
				$event ->sheet->getStyle('F1:F43')->applyFromArray($styleArray2);
				$event ->sheet->getStyle('G1:G43')->applyFromArray($styleArray2);
							
							
			$event ->sheet->getStyle('A1:G1')->applyFromArray($styleArray3);  //headings vertical alignment 
							
							
							
							//sums color formatting...
				$event ->sheet->getStyle('A1:G1')->applyFromArray($styleArray4);
				$event ->sheet->getStyle('A9:G9')->applyFromArray($styleArray5);
				$event ->sheet->getStyle('A12:G12')->applyFromArray($styleArray5);
			        $event ->sheet->getStyle('A19:G19')->applyFromArray($styleArray5);
				$event ->sheet->getStyle('A27:G27')->applyFromArray($styleArray5);
				$event ->sheet->getStyle('A31:G31')->applyFromArray($styleArray5);
				$event ->sheet->getStyle('A35:G35')->applyFromArray($styleArray5);
				$event ->sheet->getStyle('A36:G36')->applyFromArray($styleArray5);
				$event ->sheet->getStyle('A42:G42')->applyFromArray($styleArray5);
				$event ->sheet->getStyle('A43:G43')->applyFromArray($styleArray5);
					//$row->setBackground('#CCCCCC'); 
							

		    },
        ];
    }
	
	
	
}