konrms

konrms

Member Since 1 Year Ago

Experience Points
3,030
Total
Experience

1,970 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,030 XP
Jun
26
2 weeks 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
29
1 month 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'); 
							

		    },
        ];
    }
	
	
	
}


Apr
02
3 months ago
Activity icon

Awarded Best Reply on How To Export Laravel Blade To Word Document

Hi @crisgarcis !

Thank you for replying! I haven't yet tested your suggestion, but I will try it on a smaller scale project soon.

Unfortunately about a year ago when I was seeking help on this, I didn't make it to print my blade to doc in the same way as I had done with the pdf export. So I did not pass data to any blade but built the doc file step by step by adding a big number of addText sections implementing the desired styling for paragraphs and tables as well. I was based on these resources that helped me a lot with the project: https://phpword.readthedocs.io/en/latest/ https://github.com/PHPOffice/PHPWord

Activity icon

Awarded Best Reply on Exporting Multiple Files As .zip/rar File Using Phpoffice/phpword Package

The solution is here:

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
	try 
		{
						
			$objWriter->save(storage_path('zipped_en\'.$i->id.'_en.docx'));  
			continue;
			
		} 
		catch (Exception $e) 
			{
			}
	
			return response()->download(storage_path('zipped_en\'.$i->id.'_en.docx'));   
			continue;
			
} //@forech ends here
				


$we = Carbon::now();   //  I want to add date and time creation attribute to filename created
$we = Carbon::createFromFormat('Y-m-d H:i:s', $we)->format('dmYHis');


$zip = Zip::create('zipped_en_'.$we.'.zip'); 
 


$zip->add('c:\xampp\htdocs\laravel\storage\zipped_en');
Activity icon

Replied to Exporting Multiple Files As .zip/rar File Using Phpoffice/phpword Package

The solution is here:

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
	try 
		{
						
			$objWriter->save(storage_path('zipped_en\'.$i->id.'_en.docx'));  
			continue;
			
		} 
		catch (Exception $e) 
			{
			}
	
			return response()->download(storage_path('zipped_en\'.$i->id.'_en.docx'));   
			continue;
			
} //@forech ends here
				


$we = Carbon::now();   //  I want to add date and time creation attribute to filename created
$we = Carbon::createFromFormat('Y-m-d H:i:s', $we)->format('dmYHis');


$zip = Zip::create('zipped_en_'.$we.'.zip'); 
 


$zip->add('c:\xampp\htdocs\laravel\storage\zipped_en');
Mar
15
3 months ago
Activity icon

Replied to Exporting Multiple Files As .zip/rar File Using Phpoffice/phpword Package

Hi @sinnbeck ! Thank you for your reply!

I installed zanysoft/laravel-zip package. I tried implementing your suggestions, but unfortunately I didn't produce any file.

After doing many modifications (please have a look below) and running my code I created a zip file inside laravel's public folder. This file was the compressed Storage folder of laravel (including storage default subfolders). At least, how could I only compress the files created via the foreach loop exluding storage subfolders?

//Controller excerpt 

foreach($regs as $i) //
{

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultFontName('Ariel');

//code

...

//code

//saving results:

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
try 
	{
	    $objWriter->save(storage_path(''.$i->id.'_en.docx'));
           continue;
		
	}  
catch (Exception $e) 
	{
	}

	return response()->download(storage_path(''.$i->id.'_en.docx'));
					
}  //@forech ends here

$zip = Zip::create('your_zipfile.zip');   
$zip->add('c:\xampp\htdocs\laravel\storage');

Thank you a lot!

Mar
13
3 months ago
Activity icon

Started a new Conversation Exporting Multiple Files As .zip/rar File Using Phpoffice/phpword Package

Hi guys,

I have managed to export multiple .doc files with phpoffice/phpword package, using a for loop and naming them according to id attribute (each file is named after by the according id number, eg. 15_en.doc, 16_en.doc etc):

//Controller excerpt 

foreach($regs as $i) //

{

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord->setDefaultFontName('Ariel');


//code


...


//code

//saving results:
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
	try 
		{
			$objWriter->save(storage_path(''.$i->id.'_en.docx'));
			continue;
			
		}  
		catch (Exception $e) 
			{
			}

					return response()->download(storage_path(''.$i->id.'_en.docx'));
					
}

The files are created and found inside the laravel\storage path.

  1. How can I automatically zip them as a single file?
  2. When the project runs on server, how can users download them on their own pc's over the network?

Thank you a lot!

Mar
08
4 months ago
Activity icon

Replied to How To Export Laravel Blade To Word Document

Hi @crisgarcis !

Thank you for replying! I haven't yet tested your suggestion, but I will try it on a smaller scale project soon.

Unfortunately about a year ago when I was seeking help on this, I didn't make it to print my blade to doc in the same way as I had done with the pdf export. So I did not pass data to any blade but built the doc file step by step by adding a big number of addText sections implementing the desired styling for paragraphs and tables as well. I was based on these resources that helped me a lot with the project: https://phpword.readthedocs.io/en/latest/ https://github.com/PHPOffice/PHPWord

Jan
20
5 months ago
Activity icon

Replied to Checking Variable Contents In Laravel

Hi @snapey

I think in my case it's fore suitable without eloquent. $my_var will be passed to a blade and will populate a table using @foreach. In case some specific object_id's are included there will be the corresponding heading. I don't know how complex that would be with eloquent.

Thank you a lot!

Activity icon

Replied to Checking Variable Contents In Laravel

Hello @sti3bas This is exactly what I wanted. I wasn't aware of the use of contain method. Thank you a lot for your help!

Activity icon

Started a new Conversation Checking Variable Contents In Laravel

Hello everyone.

I want to check the contents of a variable. If any of them gets a desired value, I want to print a message. The variable is derived from a query in oracle database.

For example I set $my_var as bellow:

$my_var = DB::select("select object_id from details");

then with:

dd($my_var);

I get the following results:

array:6 [▼
  0 => {#304 ▼
    +"object_id": "50165679"
  }
  1 => {#302 ▼
    +"object_id": "50165685"
  }
  2 => {#300 ▼
    +"object_id": "50165686"
  }
  3 => {#298 ▼
    +"object_id": "50165687"
  }
  4 => {#303 ▼
    +"object_id": "50165688"
  }
  5 => {#299 ▼
    +"object_id": "50165682"
  }
]

I want to check if (object_id = 50165685 and object_id = 50165686 ) is true. If yes then set $new_variable = "blablabla";

How can I do that? For example trying with

if ($my_var.object_id == 50165685 and $my_var.object_id == 50165686)
    {
        $new_variable = "blablabla";
    }

fails.

Thank you a lot!