<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Laravel &#8211; MeghRaj TechnoSoft &#8211; Web, App, E-commerce Development  Agency In India.</title>
	<atom:link href="https://www.meghrajtechnosoft.com/laravel/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.meghrajtechnosoft.com</link>
	<description></description>
	<lastBuildDate>Thu, 18 May 2023 12:02:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.15</generator>

<image>
	<url>https://www.meghrajtechnosoft.com/wp-content/uploads/2020/10/fevecon.png</url>
	<title>Laravel &#8211; MeghRaj TechnoSoft &#8211; Web, App, E-commerce Development  Agency In India.</title>
	<link>https://www.meghrajtechnosoft.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to delete a user in custom Artisan Command line in Laravel?</title>
		<link>https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 18 May 2023 11:39:08 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=18200</guid>

					<description><![CDATA[<p>Laravel&#160;is a full-stack framework that offers a lot of artisan commands to automate various actions, like creating a controller, seeding the database, and starting the server. However, when you build custom solutions, you have your own special needs, which could [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/">How to delete a user in custom Artisan Command line in Laravel?</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong><u>Laravel</u></strong>&nbsp;is a full-stack framework that offers a lot of artisan commands to automate various actions, like creating a controller, seeding the database, and starting the server. However, when you build custom solutions, you have your own special needs, which could include a new command. Laravel doesn’t limit you to only its commands; you can create your own in a few steps.</p>



<p>Here are the steps for how to create a new artisan command.</p>



<p><strong>Step 1: Create a new Laravel application</strong></p>



<pre class="wp-block-code"><code>Laravel new custom</code></pre>



<p><strong>Step 2: Create a command</strong></p>



<p>Use the&nbsp;<code><strong>make:command</strong></code><strong>&nbsp;command</strong>&nbsp;to create a new command. Simply pass in the command name, like so:</p>



<pre class="wp-block-code"><code>php artisan make:command RemoveUser</code></pre>



<p>The command creates a file named&nbsp;<code><strong>RemoveUser.php</strong></code>, named after the command name, in a newly created&nbsp;<code><strong>Commands</strong></code>&nbsp;directory in the&nbsp;<code><strong>Console</strong></code>&nbsp;folder.</p>



<p>The generated file contains the configurations of the newly created command that are easy to understand and edit.</p>



<p><strong>Step 3: Customize command</strong></p>



<p>First, set the command signature. This is what would be put after&nbsp;<code><strong>php artisan</strong></code>&nbsp;to run the command. In this example, we will use&nbsp;<code><strong>remove:user</strong></code>, so the command will be accessible by running:</p>



<pre class="wp-block-code"><code>php artisan make:command RemoveUser</code></pre>



<p>To do this, update the&nbsp;<code>＄<strong>signature</strong></code>&nbsp;property of the command, like this:</p>



<pre class="wp-block-code"><code>Protected $signature = ‘remove:user’ {id};</code></pre>



<p>Next, set up a suitable description that would show up when&nbsp;<code><strong>php artisan list</strong></code>&nbsp;displays the command with other commands.</p>



<p>To do this, update the&nbsp;<code><strong>＄description</strong></code>&nbsp;property to match this:</p>



<pre class="wp-block-code"><code>Protected $description = ‘Remove user all Data’;</code></pre>



<p>Finally, in the&nbsp;<code><strong>handle()</strong></code>&nbsp;method, perform whatever action you intend it to perform. In this example, the number of users on the platform is echoed.</p>



<code><pre>public function handle(){
        $userId = $this->argument('id');
	  $delete[]=explode($usereId);	
        foreach($delete as $id){
        DB::table('users')->whereIn(id, $id)->delete();

        $this->info('Delete users successfully!');
        }</pre></code>



<p><strong>Step 4: Test command</strong></p>



<p>In the terminal, run the command to see the number of users in your database.</p>



<pre class="wp-block-code"><code>php artisan remove:user</code></pre>



<p>Now, when&nbsp;<code><strong>php artisan remove:user 1</strong></code>&nbsp;is run, you should see something like this:</p>



<div class="wp-block-image"><figure class="alignleft size-large is-resized"><img loading="lazy" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-2.png" alt="" class="wp-image-18202" width="867" height="522" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-2.png 869w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-2-300x181.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-2-768x462.png 768w" sizes="(max-width: 867px) 100vw, 867px" /></figure></div>



<div class="wp-block-image"><figure class="alignleft size-large"><img loading="lazy" width="867" height="526" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-3.png" alt="" class="wp-image-18203" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-3.png 867w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-3-300x182.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-3-768x466.png 768w" sizes="(max-width: 867px) 100vw, 867px" /></figure></div>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/">How to delete a user in custom Artisan Command line in Laravel?</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Send Email with Attachment in Laravel</title>
		<link>https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/</link>
					<comments>https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 04 Jan 2021 08:03:29 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17703</guid>

					<description><![CDATA[<p>This post will give you example of how to send email with attachment in laravel.In this article, we will implement sending attachment in mail in laravel. Alright, let’s dive into the steps.This tutorial of sending mail with attachment can be [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/">Send Email with Attachment in Laravel</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This post will give you example of how to send email with attachment in laravel.In this article, we will implement sending attachment in mail in laravel. Alright, let’s dive into the steps.<br>This tutorial of sending mail with attachment can be implemented in following versions of laravel:- laravel 6,7,8.</p>



<p><strong>Step 1: Install Laravel</strong></p>



<p>I am going to explain step by step from scratch so, we need to get fresh Laravel application using bellow command, So open your terminal OR command prompt and run below command:</p>



<pre><code>composer create-project --prefer-dist laravel/laravel blog</code></pre>



<p><strong>Step 2: Make Configuration</strong></p>



<p>In first step, you have to add send mail configuration with mail driver, mail host, mail port, mail username, mail password so laravel will use those sender details on email. So you can simply add as like following.</p>



<p><strong>.env</strong></p>



<pre><code>MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MAIL_ADDRESS
MAIL_PASSWORD=PASSWORD
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=MAIL_ADDRESS
MAIL_FROM_NAME="${APP_NAME}"</code></pre>



<p><strong>Step 3: Add Route</strong></p>



<p>In this is step we need to create routes for items listing. so open your &#8220;routes/web.php&#8221; file and add following route.</p>



<p><strong>routes/web.php</strong></p>



<pre><code><?php
  
    use Illuminate\Support\Facades\Route;
      
    use App\Http\Controllers\PDFController;
      
    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!
    |
    */
      
    Route::get('send-email-pdf', [PDFController::class, 'index']);</code></pre>



<p><strong>Step 4: Add Controller</strong></p>



<p>Here,we require to create new controller PDFController that will manage generatePDF method of route.</p>



<p>make sure you have "files" folder in public with following files.</p>



<p>So let's put below code.</p>



<p><strong>app/Http/Controllers/PDFController.php</strong></p>



<pre><code><?php
  
    namespace App\Http\Controllers;
      
    use PDF;
    use Mail;
      
    class PDFController extends Controller
    {
        /**
         * Write code on Method
         *
         * @return response()
         */
        public function index()
        {
            $data["email"] = "MAIL_ADDRESS";
            $data["title"] = "Sending Attachment in mail";
            $data["body"] = "This is Demo";
     
            $files = [
                public_path('files/160031367318.pdf'),
                public_path('files/1599882252.png'),
            ];
      
            Mail::send('emails.myTestMail', $data, function($message)use($data, $files) {
                $message->to($data["email"], $data["email"])
                        ->subject($data["title"]);
     
                foreach ($files as $file){
                    $message->attach($file);
                }
                
            });
     
            dd('Mail sent successfully');
        }
    }</code></pre>



<p><strong>Step 5: Create View File</strong></p>



<p>In Last step, let's create myTestMail.blade.php(resources/views/emails/myTestMail.blade.php) for layout of pdf file and put following code:</p>



<p><strong>resources/views/emails/myTestMail.blade.php</strong></p>



<pre><code><!DOCTYPE html>
<html>
<head>
    <title>meghrajtechnosoft.com</title>
</head>
<body>
    <h1>{{ $title }}</h1>
    <p>{{ $body }}</p>
     
    <p>Thank you</p>
</body>
</html></code></pre>



<p>Now you can run and check example.</p>



<p>It will send you email, let' see.</p>



<p><strong>Run Project:</strong></p>



<pre><code>php artisan serve</code></pre>



<p>Now hit URL as given below or you can run according to your routes:</p>



<pre><code>localhost:8000/send-email-pdf</code></pre>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/">Send Email with Attachment in Laravel</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Sending Mail with Dynamic SMTP configuration</title>
		<link>https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/</link>
					<comments>https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 04 Jan 2021 08:00:37 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17700</guid>

					<description><![CDATA[<p>Firstly, create a table in database and create all fields according to SMTP settings(.env file). Step:1 Create a Custom Mail Provider php artisan make:provider MailConfigServiceProvider Step:2 Fetch data from database in app/Providers/MailConfigServiceProvider</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/">Sending Mail with Dynamic SMTP configuration</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Firstly, create a table in database and create all fields according to SMTP settings(.env file).</p>



<p>Step:1  Create a Custom Mail Provider</p>



<pre><code>php artisan make:provider MailConfigServiceProvider</code></pre>



<p>Step:2 Fetch data from database in app/Providers/MailConfigServiceProvider</p>



<pre><code><?php

    namespace App\Providers;
    
    use Illuminate\Support\ServiceProvider;
    use DB;
    use Config;
    
    class MailConfigServiceProvider extends ServiceProvider
    {
        public function register()
        {
            $mail = DB::table('mail')->first();
            if ($mail) {
                $config = array(
                    'driver'     => $mail->driver,
                    'host'       => $mail->host,
                    'port'       => $mail->port,
                    'from'       => array('address' => $mail->from_address, 'name' => $mail->from_name),
                    'encryption' => $mail->encryption,
                    'username'   => $mail->username,
                    'password'   => $mail->password,
                    'sendmail'   => '/usr/sbin/sendmail -bs',
                    'pretend'    => false,
                );
                Config::set('mail', $config);
            }
        }
    
        public function boot()
        {
            //
        }
    }</code></pre>



<p>Step:3&nbsp; Make routes in web.php</p>



<pre><code>Route::get('change-email-settings','MailController@viewForm');

Route::post('email-settings','MailController@create')-&gt;name('createConfiguration');

Route::get('send-mail','MailController@sendMail');</code></pre>



<p>Step:4 Now create a controller</p>



<pre><code>php artisan make:controller MailController</code></pre>



<p>Step:5 Write your code in app/http/Controller/MailController.php</p>



<pre><code><?php

    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use DB;
    use Config;
    use Mail;
    
    class MailController extends Controller
    {
        public function viewForm()
        {
            return view('mail.add');
        }
    
        public function create(Request $request)
        {
            $insert = $request->all();
            unset($insert['_token']);
            unset($insert['btn']);
            DB::table('mail')->insert($insert);
            return view('mail.add');
        }
    
        public function sendMail()
        {
            $content = "<html>";
    
            $content .= "<head>";
            $content .= 	"<title>Test Template</title>";
            $content .= "</head>";
    
            $content .= "<body>";
            $content .= 	"<p>This is Test Template</p>";
            $content .= "</body>";
    
            $content .= "</html>";
    
            $mailTo = "FROM_MAIL_ADDRESS";
            Mail::send(array(),array(), function($message) use ($content,$mailTo)
            {
                $message->to($mailTo)
                        ->subject('Test Dynamic SMTP Config')
                        ->from(Config::get('mail.from.address'),Config::get('mail.from.name'))
                        ->setBody($content, 'text/html');
                echo 'Mail Sent Successfully';
            });
        }
    }</code></pre>



<p>Step: 6 Now create a blade file,name it according to your convenience</p>



<pre><code><!DOCTYPE html>
    <html>
    <head>
        <title>Change Email Configuration</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    </head>
    <body>
        <div class="container">
            <div class="row">
                <div class="col-lg-6 m-auto">
                    <h2 class="ml-5">Change Email Configurations</h2>
                    <form method="POST" action="{{ route('createConfiguration') }}">
                        @csrf
                        <label>Driver:</label>
                        <input type="text" name="driver" class="form-control"><br>
                        <label>Host:</label>
                        <input type="text" name="host" class="form-control"><br>
                        <label>Port:</label>
                        <input type="text" name="port" class="form-control"><br>
                        <label>From Address:</label>
                        <input type="text" name="from_address" class="form-control"><br>
                        <label>From Name:</label>
                        <input type="text" name="from_name" class="form-control"><br>
                        <label>Encryption:</label>
                        <input type="text" name="encryption" class="form-control"><br>
                        <label>Username:</label>
                        <input type="text" name="username" class="form-control"><br>
                        <label>Password:</label>
                        <input type="password" name="password" class="form-control"><br>
                        <input type="submit" name="btn" class="btn btn-primary"><br><br>
                    </form>
                </div>
            </div>
        </div>
    </body>
    </html></code></pre>



<p>Hit a url as shown below to fill form and add new SMTP details</p>



<pre><code>localhost:8000/change-email-settings</code></pre>



<p>Hit a url as shown below to send mail</p>



<pre><code>localhost:8000/send-mail</code></pre>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/">Sending Mail with Dynamic SMTP configuration</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Export CSV file in Laravel Example</title>
		<link>https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 22 Dec 2020 12:22:38 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17558</guid>

					<description><![CDATA[<p>In Laravel projects export csv and excel file from database more required. If you optate to exporting your data utilizing csv file in your projects version 5, 6 or 7 then here we make a simple step by step facile [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/">How to Export CSV file in Laravel Example</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In Laravel projects export csv and excel file from database more required. If you optate to exporting your data utilizing csv file in your projects version 5, 6 or 7 then here we make a simple step by step facile steps for export csv file utilizing php function not utilizing any library. In recent project we require to export the rows from the database in laravel but I checked in google more then sites utilizing library but if we engender csv utilizing php function then why we utilize any package. So guys lets start to export CSV Data in laravel example utilizing facile steps.</p>



<p>In first step you require to integrate a route in your web.php file.</p>



<h5 id="h-step-1-add-route">Step 1: Add Route</h5>



<pre><code>Route::get('/tasks', 'TaskController@exportCsv');
</code></pre>



<h5 id="h-step-2-in-blade-file">Step 2: In Blade File</h5>



<p>In this step add a export function in you js file to exporting data.</p>



<pre><code><script>
   function exportTasks(_this) {
      let _url = $(_this).data('href');
      window.location.href = _url;
   }
</script></code></pre>



<h5 id="h-step-4-in-your-controller">Step 4: In your Controller</h5>



<p>In last step you need to add a function to export rows in csv in laravel 5, 6 or 7 application. Here we get all projects but you can modify your code which you want to export you can add in column and tasks.</p>



<pre><code>public function exportCsv(Request $request)
{
   $fileName = 'tasks.csv';
   $tasks = Task::all();

        $headers = array(
            "Content-type"        =&gt; "text/csv",
            "Content-Disposition" =&gt; "attachment; filename=$fileName",
            "Pragma"              =&gt; "no-cache",
            "Cache-Control"       =&gt; "must-revalidate, post-check=0, pre-check=0",
            "Expires"             =&gt; "0"
        );

        $columns = array('Title', 'Assign', 'Description', 'Start Date', 'Due Date');

        $callback = function() use($tasks, $columns) {
            $file = fopen('php://output', 'w');
            fputcsv($file, $columns);

            foreach ($tasks as $task) {
                $row['Title']  = $task-&gt;title;
                $row['Assign']    = $task-&gt;assign-&gt;name;
                $row['Description']    = $task-&gt;description;
                $row['Start Date']  = $task-&gt;start_at;
                $row['Due Date']  = $task-&gt;end_at;

                fputcsv($file, array($row['Title'], $row['Assign'], $row['Description'], $row['Start Date'], $row['Due Date']));
            }

            fclose($file);
        };

        return response()-&gt;stream($callback, 200, $headers);
    }</code></pre>



<p>i hope you like this article.</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/">How to Export CSV file in Laravel Example</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
