Categories
Learning

Looking for 3D print in Miraroad, Mumbai, Thane?

Hello,

If you are looking for 3D print service and if you got the file and need a print, you can reach out here 3dprint@doableyo.com.

They respond usually on weekends for the delivery of print but you can write them anytime for any queries, they are new in 3D printing 👣🐾 but they can solve and helpful for the problem you might have.

3dprint.doableyo.com (the page will getting ready soon or might got ready)

Thanks for visiting!

Categories
Learning

How to call Laravel one Controller method into another?

Hello welcome to this post!

As of part of learning and development of laravel project I was simply looking syntax how to call laravel controller method in another controller.

Here is some tips and example:

Make sure you declared function as with public keyword while defining any method/function in controller.

Method updateMethod defined in controller called DoctorController.php as follow:

public function updateMethod($request, $id) {
// echo $id;
. . . // more lines of your code here
}

Secondly calling updateMethod in controller called DoctorApiController.php

public function updateDoctor(Request $request, $id) {
      if (Doctor::where('id', $id)->exists()) {
        $result = (new DoctorController)->updateMethod($request, $id);
        
        return response()->json([
            "message" => "Doctor updated successfully"
        ], 200);
        } else {
        return response()->json([
            "message" => "Doctor not found"
        ], 404);
        
    }
   }

If you got any error with DoctorController or your Controller class name not found or any such please add: use App\Http\Controllers\DoctorController; on top of the file.

This was the one way to simply call method of laravel one controller to other.

Hope it helpful. Thanks for visiting and reading.

Categories
Learning

WhatsApp, Facebook, Instagram go down

Hello Hi,

Lot of us facing currently down issue from Whatsapp, Facebook and Instagram:

Here are there tweets on issues:

Instagram

Facebook

Whatsapp

So we don’t need to worry much and relax our nerves and mind and let the giants work on the issue until than we can take some good good nap for living life’s.

Thanks for reading and visiting.

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!