Categories
Learning

Looking for fulltime Sr Frontend Developer position

Hello, welcome here to this post.

Jatinder Singh is looking fulltime Sr Frontend Developer position remotely or at worldwide locaiton.

He have 8+ years of frontend development experience, his core expertise is into ReactJS, NextJs, Angular, NodeJs(30-40%), Javascript, ES6, HTML5, CSS3, Bootstrap, jQuery, GraphQL, ApolloClient and ApolloServer.

His recent work of https://sabziyaan.doableyo.com or https://sz.doableyo.com using NextJS, ReactJS, he have also worked on Ecommerce Project which will be soon launched.

He currently lives in Mumbai with his family.

He actively looking out for fulltime job, in open culture, no politics environment and always seek an opportunity to learn and grow.

He loves the quote of Richard Branson:

To reach out him, you may quickly drop a note at hello@tortoisefeel.com. The message will share instantly with them.

Thank your for reading and visiting the post.

Categories
Learning

What is the syntax or how to add AND with where clause in PHP MYSQL?

Hello, welcome to this short post or an answer for this question.

Here is example do use AND with WHERE clause in MYSQL statement in PHP or general writing of SQL Statement.

SELECT *
FROM orders
WHERE (userId = 111 AND orderId = 185)

This how we can use AND in where clause., similarly if we need OR in WHERE clause, we can use as below:

SELECT *
FROM orders
WHERE (userId = 111 AND orderId = 185)
OR (userId > 100);

Just if we are looking for complex query with multiple OR and AND in OR

SELECT orderId, orderNumber, orderStatus
FROM orders
WHERE (orderId = 185)
OR (orderNumber = 101 AND orderStatus = 'Cancelled')
OR (orderNumber = 102 AND orderStatus = 'InProgress' AND total >=500);

Purpose of this post to give you just syntax you might be looking for, but you know the logic how to implement it and use it!

Thanks for visiting and happy learning!

Categories
Learning

How to update in Laravel 8 all columns in database for form fields required and non required?

Hello, welcome to this question post.

I was looking for quick and succint turn around for this question and after searching lot on this one of post gave me any idea to update my rest of non-validate fields of form and also which don’t have validate rules at laravel model or controller level.

So here if my modified update() function from laravel Controller to update non required form fields or rules set in laravel controller or model, with in easy simple PHP style.

public function update(Request $request, $id)
    {
        
        $validatedData = $request->validate([
            'name' => 'required|max:255',
            'price' => 'required',
        ]);
        
        $nonRequiredFields = [
            'discount' => $request->discount,
            'qty' => $request->qty,
            'tax'=> $request->tax,
            'shipping' => $request->shipping,
            'handling' => $request->handling,
        ];
        
        Food::where('foodId', '=', $id)->update(array_merge($validatedData, $nonRequiredFields));
        
        return redirect()->route('food.index')->with('success', 'Food successfully updated');

}

In the code above I have given readable name to variable ($nonRequiredFields) which can be easily understand and I found this way the solution is working!

If you know more better approach kindly send me a not or if comments are open to this post please do comment.

Thanks for visiting and reading the post.

Categories
Learning

What to do when get nextjs server error when loading image from scss/sass variable in nextjs Image component?

Server Error
Error: Failed to parse src ""https://yourdomain.com/develop-app/assets/images/body-bg5.png"" on `next/image`, if using relative image it must start with a leading slash "/" or be an absolute URL (http:// or https://)

I was facing this error recently on my nextjs project, I wanted to load the background Image path from SCSS variable into the NextJs Image components.

Before this error occurred, I was hunting on google for the answer and found it that how to import scss variables into react component, and I found we can import scss variable by declaring in scss file itself using :export directive of scss

//Example of exporting variable from scss file

$BODY_BG: "https://yourdomain.com/develop-app/assets/images/ka-body-bg.png";
$BODY_BG_OPT1: "https://yourdomain.com/develop-app/assets/images/ka-body-bg1.png";

:export {
    BODY_BG: $BODY_BG;
    BODY_BG_OPT1: $BODY_BG_OPT1;
}

and then can import easily into react component by installing node-sass npm package and then import the file of scss variable into react component like :


import backgroundVar from "../styles/background.module.scss";

//(note: I have used backgroundVar as my variable import name for all the scss variables exported from background.module.scss file)

and use it like this in your react state hook or directly in react component

const homeBodyBg = trimOutThis(backgroundVar.BODY_BG_OPT5 && backgroundVar.BODY_BG_OPT5, /"/g, '');

const [bgImage, setBgImage] = useState(homeBodyBg || '');

To fix the error of nextjs error of:

Error: Failed to parse src ""https://yourdomain.com/develop-app/assets/images/body-bg5.png"" on `next/image`, if using relative image it must start with a leading slash "/" or be an absolute URL (http:// or https://)

I wrote small function to trim off the double quotes “” which we get from scss variable declaration for path, here is that function below and you may notice in above code, I am already trimming the double quotes with empty string and then it works like charm!

//Function to replace any string pass to an empty string or to be replaceable by something else

export const trimOutThis = (str, regx, replaceValue = "") => {
  if (!str.length || !regx) return '';


  return str.replace(regx, replaceValue);
}
//Function invoking example


const homeBodyBg = trimOutThis(backgroundVar.BODY_BG_OPT5 && backgroundVar.BODY_BG_OPT5, /"/g, '');


output without double quotes ” for NextJS image src

Hope this will help you in your search and solving issues.


Have nice day & Happy Learnings.

Thanks for visiting.

Categories
Javascript Learning Learning Tech

How I have resolve, Module not found, Can’t resolve ‘optimism’

Hello welcome to this post.

Straight to the answer, here it goes:

Tried running first nextjs app

λ npm run dev

> developfe-dev@1.0.0 dev
> next

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from F:\windows\developapp\code\.env
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
error - ./node_modules/@apollo/client/cache/core/cache.js:1:0
Module not found: Can't resolve 'optimism'

Import trace for requested module:
./node_modules\@apollo\client\cache\index.js
./node_modules\@apollo\client\core\index.js
./node_modules\@apollo\client\index.js
./pages\_app.js

https://nextjs.org/docs/messages/module-not-found
Terminate batch job (Y/N)?
^C

Next reinstalled package



F:\windows\developapp\code (main -> origin) (developfe-dev@1.0.0)
λ npm i @apollo/client@latest --save

added 9 packages, changed 1 package, and audited 1119 packages in 13s

90 packages are looking for funding
  run `npm fund` for details

6 vulnerabilities (4 low, 2 high)

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

Then run again! boom!

F:\windows\developapp\code (main -> origin) (developfe-dev@1.0.0)
λ npm run dev

> developfe-dev@1.0.0 dev
> next

ready – started server on 0.0.0.0:3000, url: http://localhost:3000
info – Loaded env from F:\windows\developapp\code\.env
info – Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
event – compiled successfully

So, here is the simple answer to the question.

Thanks for reading and Happy Learning!

Categories
Learning

How to add multiple email address to sendgrid nodejs code?

Hello there, welcome to my random question post.

I was facing small issue to add multiple address to bcc to the sendgrid nodejs example :

What I was tried to do ( which was wrong in accepting as sendgrid bcc parameters value)

let testAccount = {
        emailSubject: subjectMsg,
        emailFrom: `Application <${process.env.CESEmailFrom}>`,
        emailTo: email || process.env.OWNER_TO_EMAIL_ADDRESS,
        emailBcc: process.env.OWNER_EMAIL_ADDRESS //note here
 };

(this is just a payload I am preparing to pass to seng-grid function), process.env.OWNER_EMAIL_ADDRESS was holding values like : email1@testdomain.com, email2@testdomain.com so which is incorrect to pass a comma separated string value.

Instead, we just need to tweak a little at the same bcc, line to pass it as Javascript Array value. Here is the example of working code (note the bcc line in the code below):

let testAccount = {
        //user: process.env.CESUsername,
        //pass: process.env.CESPassword,
        emailSubject: subjectMsg,
        emailFrom: `Kitchen Anak <${process.env.CESEmailFrom}>`,
        emailTo: email || process.env.OWNER_TO_EMAIL_ADDRESS,
        emailBcc: process.env.OWNER_EMAIL_ADDRESS && process.env.OWNER_EMAIL_ADDRESS.split(',') || '',
    };

Using javascript split function, I was able pass it as a array, isn’t that simple? 🙂

Facing other error related to sendgrid bcc option

Along this, I have also then faced error after fixing above, still on my Vercel deployment code, then which was related to sendGrid bcc parameter for multiple email address.

According to sendGrid documentation we should have unique email address for ‘to’, ‘cc’ and ‘bcc’ options while sending email, in my case I was having ‘bcc’ email address set in at ‘to’ option.

Hence, so creating a duplicate error log at API level of code. (attaching screenshot of error occurred) and then fixed it by removing or keeping all the ‘to’ and ‘bcc’ parameters unique! Volia, that simple 🙂

Log error due to sendgrid bcc email address should be unique.

Result after correcting email address successful.

Successful email send log!

Thanks for visiting & Happy Learning!

Categories
Learning

How to pass multiple data to Laravel compact method from Controller to view blade?

Hello there, welcome to the random post.

Ok, I was looking to add multiple data with compact method in Laravel from controller, here is quick example solution how I did it.

My initial code was like below in one of the controller method I was working on, skipping writing whole function code, posting down what was inside the function and how I turned it out to after on my question search on Google.

Example 1:

(returning single category data to the category.edit.blade.php)

$category = Category::findOrFail($id);
return view('category.edit', compact('category','gvd', 'parentCategories'));
Example 2:

(passing multiple data)

$category = Category::findOrFail($id);
$gvd = $this->generalViewData; //this controller property returning array data to $gvd variable, then passing to compact below

$allParentCategoryIds = Category::select('parentId')->pluck('parentId');
            
// Looping on data
foreach ($allParentCategoryIds as $pid) {
      $parentCategories = Category::select('name', 'categoryId')->where('categoryId', '=', $pid)->get();
 }

return view('category.edit', compact('category','gvd', 'parentCategories')); 

Here you could also note in case if come down here by searching about how to loop controller side in laravel? so from code example you could get the answer.

I am using Laravel 8 for current development.

Hope you find it easy and handful.

Thanks for reading & Happy Learning!

Categories
Blog Learning Tech

How to use if else conditions in laravel blade view or for html code?

Hello, thanks for checking out here!

Here is the quick and short answer with the examples:

Example 1
<img src="@if($category->image) {{ ($category->image) }} @else {{'https://via.placeholder.com/50'}} @endif" alt="{{ $category->name}}" width="50" height="50" />

This is what I was looking for my part of development laravel! same you can achieve for the html blocks: here is the example:

Example 2
@if ($message = Session::get('success'))
    <script>
      if(window.toastr)
          toastr["success"]("{{ session()->get('success') }}"); 
    </script> 
@endif
Example 3
@if ($message = Session::get('success'))
  <div class="alert alert-success">
     session()->get('success')
  </div>
@endif

To use elseif just use following syntax @elseif(condition) along your code or between.

Thanks & Happy learning Laravel!

Categories
Learning Tech

If Laravel created_at or updated_at SQL error, what to do?

Hello, welcome to my random post.

Quick to elaborate, what I was doing what I found it right to fix.

I am building an application with Laravel and I was facing with this below error:

// Illuminate\Database\QueryException
// SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘created_at’ in ‘order clause’ (SQL: select * from food order by created_at desc limit 10 offset 0)

The cause of such error is when we don’t have column name in our database table, as to be created_at and updated_at.

In my case I was following camel case styles column names in database table: createdAt and upatedAt, so it was cause of this error and further to it, as I were looking for the solution and found that I am using latest() method to fetch the code (which is not allowed when don’t have laravel style column names of our database table), example like below

$food = Food::latest()->paginate(10);

so we have to have a columns names with created_at and updated_at in our database table, if want to use latest() method

Otherwise we need to change the method to orderBy() or first() method to fetch the result from database, also remember to add arguments to orderBy method/function like below, otherwise you would face again error of arguments need to be passed.

$food = Food::orderBy('createdAt', 'desc')->paginate(10);

Thanks for reading and happy coding. Have a nice day 🙂

Categories
Blog Javascript Learning Tech

Taking Random Angular Quiz, Got Results – Jat

Hello, welcome and thanks to visit here to read my this short random post.

I was looking to take a random angular quiz to test my ability on Angular after a year around how much I remember about it, as because currently I mostly working with React and GraphQl, ApolloServer and Client and loving NextJS.

So after searching on Google, I landed up over this blog (here) (not an intention to use the link wrongly here), I took the Quiz and here is my result below with the image.

I too read some articles in the morning and look for tips and tricks on Angular so I can heads up well for the next interview on Angular 🙂

So I tried Quiz from the above blog link and here it is:

Question ah? How it could prove its my result, you can check on the full screenshot from my computer currently and tiny image up on the top corner and below on the Task bar with Chrome Active.

JAT-angular-quiz-result-with-rest-of-the-WORLD!

That’s all I would like to share with you all.

Thanks for reading and visiting. Have a great time and year’s ahead!

P.S. yes I forgot to mention, I am next going to take up more quiz and sharp my Angular blade more finer as possible as to be! Happy Learnings!