konrms

konrms

Member Since 1 Year Ago

Experience Points
3,010
Total
Experience

1,990 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,010 XP
Apr
02
1 month 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
2 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
2 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
2 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
4 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!