Categories
Downloads & Free

Download Free Bharat (India) Chandigarh Territory Map SVG format

Hello,

Download Bharat (India) Chandigarh Territory Map (SVG format) for Laser Cut or to Print for your school or college projects.

Chandigarh
Categories
Downloads & Free

Download Free Bharat (India) Andaman and Nicobar Islands Territory Map SVG format

Hello,

Download Bharat (India) Andaman and Nicobar Islands Territory Map (SVG format) for Laser Cut or to Print for your school or college projects.

T2-Andaman-Nicobar-Islands-T2
Categories
Downloads & Free Uncategorized

Download Free Bharat (India) Puducherry Territory Map SVG format

Hello,

Download Bharat (India) Puducherry (Pondicherry) Territory Map (SVG format) for Laser Cut or to Print for your school or college projects.

pudducherry
Categories
Downloads & Free Uncategorized

Download Free Bharat (India) Daman and Diu (Gujarat) Territory Map SVG format

Hello,

Download Bharat (India) only Daman and Diu(Gujarat) India Territory Map (SVG format) for Laser Cut or to Print for your school or college projects.

Daman-and-Diu
Categories
Downloads & Free Uncategorized

Download Free Bharat (India) Dadra Nagar Haveli (Gujarat) Territory Map SVG format

Hello,

Download Bharat (India) only Dadra Nagar Haveli (Gujarat) Territory Map (SVG format) for Laser Cut or to Print for your school or college projects.

dadra-nagar-haveli-gujarat-territory-india
Categories
Downloads & Free Uncategorized

Download Free Bharat (India) Jammu & Kashmir & Ladakh Map SVG format

Hello,

Download Bharat (India) only Jammu & Kashmir Map (SVG format) for Laser Cut or to Print for your school or college projects.

india-territory-jammu-kashmir-map
Categories
Downloads & Free Learning Uncategorized

Download Free Bharat (India) Map SVG format

Hello,

Download Bharat (India) Map (SVG format) for Laser Cut or to Print for your school or college projects.

india-bharat-map-for-laser-cut-svg-map
India Full Map SVG Download Free
Categories
Uncategorized

laravel 8 tips and tricks and how i did it

In day of my learning today on PHP Laravel 8 building application from scratch with google search help!

I am not a good write I am just posting random solutions of my finding in building Laravel application from scratch!. (I don’t claim anybody solutions to mine, this is suggest as a side support. Thanks!)

How to create mailable class in Laravel using version 8?

php artisan make:mail OrderStatusUpdate --markdown=emails.orders.statusupdated 

I have used –markdown option to automatically general email template file for me under resources/views/emails/orders/statusupdated.blade.php file to have template ready on fly to start working!

It will create OrderStatusUpdate class file under Mail folder under app/Mail folder automatically!

How to create custom route to view the email template in browser before sending any emails for test?

Route::get('/mailable', function () {
     $msg = 'Order ID TEST! updated successfully!';
    return new App\Mail\OrderStatusUpdated($msg);
});

This lines of code you can add to web.php under /routes folder which you can easily test out the template by directly visiting to your website or Laravel deployed path for example: youwebsite.com/mailable or yourwebsite.com/somefoldername/mailable like so!

How to pass data as array to mailable class file from Laravel Controller file?

public function handlUpdateOrderStatus(Request $request) {
        
        try {
            $query = Order::where('orderId',$request->orderId)->update(['status' => $request->value, 'updatedAt' => now()]);
            
            // create response result
            if($query) {
                
                $msg = 'Order # '.$request->orderNumber.' (OrderID:'.$request->orderId. ') updated to '. $this->orderStatusList[$request->value] .' successfully!';
                
                // Shoot email
                Mail::to( env('MAIL_REPLY_TO_ADDRESS'), env('MAIL_FROM_NAME_ADMIN') )->send(new OrderStatusUpdated(['msg'=> $msg, 'orderNumber' => $request->orderNumber]));
                
                return ["success" => true, 'message'=> $msg];
                
            } else {
                
                return [
                    "error" => true,
                    'message'=> "Error in updating status, please try again/later."];
            }
        }
        catch(\Exception $e){
            // Get error here
            echo "Email test exception or query exception OrderController!";
        }
        
    }

This function in my OrderController.php file is actually to update the DB record and then shoot email, so here also wanted to pass data to mailable class instance as an array, this is how above, I have passed as array data and will retrieve in the mailable class file (in following next question or block below this one Queue1)

While I was testing this code I came up to another error of issue (Swift_TransportException Connection to mail.xxxxx.com:465 Timed Out), I thought error was to parameter to Mail:: facade function or line, but, syntactically what I followed was correct so no change there.

Then I searched over this and came to find, in .env file MAIL_ENCRYPTION set to null, before setting anything there, I was looking under config/mail.php for default settings where I have tried to add ssl value to encryption and then testes found to be working. Then I have changed the same under .env file MAIL_ENCRYPTION=ssl which was set to null by default of installation of Laravel application and commented or reverted back config/mail.php code and then voila, it worked like charm! (continue to complete Queue1)

How to retrieve data as array passed to mailable instance from Laravel controller and pass down to Laravel email template?


namespace App\Mail;

use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class OrderStatusUpdated extends Mailable implements ShouldQueue {
public $details;
    /**
     * Create a new message instance.
     *
     * @param  \App\Models\Order  $order
     * @return void
     */
    public function __construct($details)
    {
        $this->details = $details;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Order # '. $this->details['orderNumber'] .' Status Updated')
                ->markdown('emails.orders.statusupdated');
    }
}

Here is the block of code fetching/retrieving data in public variable which is pass down to this mailable class file instance in controller as we discussed above in last question and accessing the same under build function of this mailable class file.

I have also implemented this class file with ShouldQueue following Laravel guide on mail.

I have also added following public property: $afterCommit : true, but got below error:

App\Mail\OrderStatusUpdated and Illuminate\Bus\Queueable define the same property ($afterCommit) in the composition of App\Mail\OrderStatusUpdated. However, the definition differs and is considered incompatible. Class was composed

I have remove it as it was not troubling me even if I don’t have it, I guess this be might the case for lower version of Laravel’s than 8.

How to finally consume the data passed in Laravel email template passed down via its mailable class?

@component('mail::message')

# Order Status

Order # {{ $details['orderNumber'] }} 
{{ $details['msg'] }}

@component('mail::button', ['url' => ''])
View Order
@endcomponent

Thanks,<br>
{{ config('app.name') }}
@endcomponent

Finally this is how the template rendered and worked for me! Hope it will work for you too!

Beside this I have also added Laravel Customize components which I will be implementing/using further in the application development. Keep you posted in case I can up with issues in its implementations.

Thanks for visiting & reading the post. Hope it help you in your way of building applications.

Categories
Learning Tech Uncategorized

Tips & Tricks how they do it in laravel, now we can too do it

In day of my learning on PHP Laravel building application from scratch with googling help and docs.

How to foreach or for loop on html select input or dropdown field in laravel blade file

<select class="custom-select jsUpdateOrderStatus"   id="ddlTodayOrdersStatus{{$loop->index}}"          name="ddlTodayOrdersStatus{{$loop->index}}"
data-orderid="{{$order->orderId}}" >
     @foreach ($orderStatus as $status)
         <option value="{{$loop->index}}" 
         {{$order->status === $loop->index ? "selected" : "" }}"  
         data-loopIndex=" {{$loop->index}}">{{$status}}</option>
     @endforeach
</select>

To Note : $order is passed as dynamic object to the blade file in which this code will be implemented, its for just example to explain. (hint: make sure your laravel directive/code are intended properly in blade files, otherwise it might throw error to the view)

How to add format date to html in laravel blade file

<p>Example code 1: </p>
<p>{{ Carbon\Carbon::parse($order->createdAt)->format('d-M-Y H:i:s') }}</p>

<p>Example code 2:</p>
<p>{{ Carbon\Carbon::parse($order->createdAt)->diffForhumans() }}</p>

Using ajax script code in laravel blade file (just for ajax javascript syntax example):

<script type="text/javascript">
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
    </script>
    <script>
        // alert('javascripts section loaded test!');
        $(function() {
            // alert("jQuery works test!") ;
            
           $('.jsUpdateOrderStatus').change(function(e) {
              
            //   console.log('change fired! ');
              
              const curTargetEle = $(e.target);
              const value = curTargetEle.val();
              const orderId = curTargetEle.data('orderid');
              const curDDLUpdatedText = curTargetEle.find('option:selected').text();
              const curDDLUpdatedTextInital = curDDLUpdatedText.substring(0,1);
              const curSiblingLabelEle = curTargetEle.siblings('.input-group-prepend').find('label');
              
              if(!value || value === "") {
                  console.error('value not passed'); 
                  return;
              }
              
              
            //perform AJAX call
            // console.log('jsUpdateOrderStatus fired ', value, orderId);
            
            const payload = { 
                _token:  $('meta[name="csrf-token"]').attr('content'),
                orderId,
                value
            };
            
            if(confirm("Are you sure, you want to change order status?")) {
                $.ajax({
                    url: "{{route('update-order-status')}}",
        			type: "post",
        			cache: false,
                    data: payload,
                    // dataType: 'json',
                    // data:"{id:$(this).data('fid')}"
                }).done(function(resp) {
                  
                  //success
                  console.log("Order status success response: ", {resp});
                  
                  if(resp && resp.success) {
                      
                      curSiblingLabelEle.text(curDDLUpdatedTextInital);
                      
                      const msg = `Order ${orderId} set to ${curDDLUpdatedText} succesfully`;
                      toastr["success"](msg || resp.message);
                      
                      location.reload();
                  }
                  
                   }).fail(function(err){
                  //failure
                   toastr["error"](err.responseText || err.status);
                  console.error("Order status error response: ", {err});
                });
            }
           });
               
        });
    </script>


To note: here some ccode you won't find relevant to your need, you may remove them, this is to show a general idea of ajax JavaScript side of implementation on some html input/select field change event to dynamically handle request. 

Conditionality showing html code in Laravel blade file using Laravel @if directive

<ul class="nav nav-tabs" id="myTab" role="tablist
    @if (count($todayOrders))
      <li class="nav-item" role="presentation">
        <a class="nav-link active" id="todayorder-tab" data-toggle="tab" href="#todayorder" role="tab" aria-controls="todayorder" aria-selected="true">Today's Order <sup class="badge badge-pill badge-dark">{{count($todayOrders)}}</sup></a>
      </li>
    @endif
  <li class="nav-item" role="presentation">
    <a class="nav-link  @if (!count($todayOrders)) active @endif " id="allorder-tab" 
        data-toggle="tab" href="#allorder" role="tab" aria-controls="allorder" aria-selected="false">All Orders <sup class="badge badge-pill badge-dark">{{count($orders)}}</sup></a>
  </li>
</ul>

To note: this is just example you can do the same with any other kind of html codes.

Conditionality setting class to html tag using Laravel @if directive

class="nav-link  @if (!count($todayOrders)) active @endif " 

HTML code example:
<a class="nav-link active" id="todayorder-tab" data-toggle="tab" href="#todayorder" role="tab" aria-controls="todayorder" aria-selected="true">Today's Order <sup class="badge badge-pill badge-dark">{{count($todayOrders)}}</sup></a>

Thanks for visiting & reading this post. Hope it help you in your way of building applications.

Categories
Uncategorized

PHP sql returns space in email address while query with json post data using post method

I have faced a scenario where I was getting space error in the email address before @ symbol in email address, as I were making simple post request to verify the login.
Json post object sample:

{
	"email": "test@example.com",
  	"password" : "test123"
}

Was returning error in response of like test @example.com so the email address was not getting verified in the database.

Upon google came to following stack overflow result for solution but not satisfy with the approach of replacing single quote again and forcing self to post the email address with single quote in post request, which is obviously not a good solution. (later I have commented on the result page with my solution 😉 )
Simply I did this at query level and it resolve the space issue in the email address while query in database.

$query = "SELECT * FROM 
            " . $this->table_name . " 
            WHERE email =  '".$this->email."'  LIMIT 0,1";

Finally, wrapped the email address variable with the single quotes, and resolved the issue of space before @ symbol.

Hope this solution and result page will save your day!