teleren/devto huggingface dataset:
Laravel Model Create Example
Tags: laravel, php, tutorial, beginners
Published: 2022-05-16 07:31:20

Originally posted @ https://codeanddeploy.com visit and download the sample code:
https://codeanddeploy.com/blog/laravel/laravel-model-create-example

In this post, I will show you an example of the **Laravel model create** with different methods that can use in your application. When learning the Laravel model creating or inserting records in your database is one of the important learning.

 

## Example #1: Basic insert using Query Builder
In this example, we are using query builder to insert records into our database. We are using the DB facade for this method. See the example code below.

```php
$user = DB::table('users')->insert([
    'name' => 'Juan Dela Cruz',
    'email' => 'dcruz@gmail.com',
    'password' => bcrypt('password')
]);

//return to true
```

## Example #2: Basic Long-Hand Method
In this example, we are using Eloquent with a long-hand method using s`ave()` function: See below example code:

```php
$user = new \App\Models\User();
$user->name = "John Doe";
$user->email = "jdoe@gmail.com";
$user->password = bcrypt('password');
$user->save();
```

## Example #3: Basic with Laravel Model Create
In this example, we will use the Eloquent `create()` method which passes the array values.


```php
\App\Models\User::create([
    'name' => 'Jane Dane',
    'email' => 'jdane@gmail.com',
    'password' => bcrypt('password')
]);
```

## Example #4: Quicker Method
In this example, this will be a quicker way of saving records in Laravel Eloquent by creating a PHP instance but not yet recorded in our database. We need to call the `save()` method to do it.

```php
$user = new \App\Models\User([
    'name' => 'Jane Dane',
    'email' => 'jdane2@gmail.com',
    'password' => bcrypt('password')
]);

$user->save(); //returns true
```

Thank you for reading the Laravel model create. I hope this tutorial can help you. Kindly visit here https://codeanddeploy.com/blog/laravel/laravel-model-create-example if you want to download this code.

Happy coding :)
Laravel 9 Update an Existing Model
Tags: laravel, tutorial, javascript, php
Published: 2022-05-16 07:21:35

Originally posted @ https://codeanddeploy.com visit and download the sample code:
https://codeanddeploy.com/blog/laravel/laravel-9-update-an-existing-model

In this post, I will show you an example of how to implement using **Laravel 9 on Update an Existing Model. Laravel model update** is one of the most functionality we should learn when creating an application using Laravel. In this post, we have different methods and examples of how to do it. Just pick one that is suitable for your needs.

 

## Example #1:

```php
$employee = Employee::find(1);

$employee->name = "Juan Dela Cruz";

$employee->save();
```

## Example #2:
We can also update the model using an array with multiple values which don't need to use the `save()` method.

```php
$employee = Employee::find(1);

$employee->update(['name' => 'Juan Dela Cruz', 'address' => 'My address']);
```

## Example #3:
We can also update records with a conditional method using `where` function directly.

```php
Employee::where('salary', '>', '10000')
	->update([
		'address' => 'Juan Dela Cruz', 
		'address' => 'My address'
	]);
```

## Example #4:
If you don't need to change the `updated_at` column when updating the record you may use the `touch` option as `false` so that the model will exclude it.

```php
$employee = Employee::find(1);

$employee->update([
	'name' => 'Juan Dela Cruz', 
	'address' => 'My address'
], ['touch' => false]);
```

I hope this tutorial can help you. Kindly visit here https://codeanddeploy.com/blog/laravel/laravel-9-update-an-existing-model if you want to download this code.

Happy coding :)
I am a little shocked from the power of this community
Published: 2022-05-16 07:14:12

We have created a launch for Novu announcing our $6.5m in funding, and we got trending on Github - Typescript.
Now here is the thing, we have checked the traffic of all the sources, and dev.to was the biggest one.
Invest in dev.to, it worth it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0kuo13eabb0o3xdcyj1j.png)

A little background about Novu

> Novu is the first open-source notifications infrastructure for developers by developers. Novu relieves developers from building and maintaining their notifications infrastructure, enabling them to focus more on the product’s core features. That can be an in-app notification center or transactional messages sent over multiple delivery channels.

Come check us up
https://github.com/novuhq/novu
Spring Boot LDAP and Local Database
Published: 2022-05-16 07:05:02

I am getting this error:
```
java.lang.ClassCastException: org.springframework.security.ldap.userdetails.LdapUserDetailsImpl cannot be cast to com.rnd.geo.web.dto.CustomUser
```

I could login via my ldap username and password but after login i cant move to my home page due to the mentioned error.

Here, CustomUser is my user class that implements UserDetails.


Thanks
Loft Labs at KubeCon 2022 Valencia
Tags: kubernetes, vcluster, devspace, loft
Published: 2022-05-16 07:04:53

By [Rich Burroughs](https://twitter.com/richburroughs)

We’re excited to announce that most of the Loft Labs team will be attending KubeCon 2022 Europe in Valencia this week. Members of the team attending include Loft Labs CEO [Lukas Gentele](https://twitter.com/LukasGentele), CTO [Fabian Kramm](https://twitter.com/fabiankramm), VP of Marketing [Dan Finneran](https://twitter.com/thebsdbox), Developer Advocate [Lian Li](https://twitter.com/lianmakesthings), and [me](https://twitter.com/richburroughs).

We’d love to talk to you about Loft, vcluster, DevSpace, and our other projects. If you have questions about multi-tenancy, policies, developing on Kubernetes, or largely anything cloud native then please come over for a chat. We also have some fun things to hand out like t-shirts and stickers. If you’ll be attending, please swing by and see us in booth SU15. And enjoy KubeCon!
Stop Using Divs for Buttons!
Tags: javascript, html, webdev, programming
Published: 2022-05-16 06:56:26

![](https://miro.medium.com/max/1400/1*79vn1X7M3HgfdLYUjvYsmA.jpeg)

The correct use of semantic HTML elements for their particular purpose is the basis of an accessible design that can significantly improve your website’s accessibility. Web accessibility means that we should design websites, tools, and technologies so that people with disabilities can use them.

{% medium https://medium.com/@mariusbongarts11/stop-using-divs-for-buttons-87a0b3d7945e %}
Laravel 8 Collection with first() and firstWhere() Methods Example
Tags: laravel, php, tutorial, beginners
Published: 2022-05-16 06:35:22

Originally posted @ https://codeanddeploy.com visit and download the sample code:
https://codeanddeploy.com/blog/laravel/laravel-8-collection-with-first-and-firstwhere-methods-example

In this example, I will show you how to implement the **Laravel 8 Collection** with `first()` and f`irstWhere()` methods. When doing a Laravel project we should use Laravel collection for easier to process our array data. We will use the `collect` helper function of Laravel to create a new collection instance from our array.

 

And sometimes you need to get the first element or with a condition query that will display the first result of our Laravel collection. With the use of `first()` and `firstWhere()` methods will make it easier for us.

 

## Example 1: Laravel Collection first() Method Example

```php
public function index()
{
    $collection = collect([
        ['id'=>	1, 'name'=>'Juan Dela Cruz', 'age' => 25],
        ['id'=>	2, 'name'=>'Juana Vasquez', 'age' => 31],
        ['id'=>	3, 'name'=>'Jason Reyes', 'age' => 27],
        ['id'=>	4, 'name'=>'Jake Ramos', 'age' => 43],
    ]);
  
    $first = $collection->first();
  
    dd($first);
}
```
Output:


```php
array:3 [▼
  "id" => 1
  "name" => "Juan Dela Cruz"
  "age" => 25
]
```

## Example 2: Laravel Collection first() Method Example

```php
public function index()
{
    $collection = collect([
        ['id'=>	1, 'name'=>'Juan Dela Cruz', 'age' => 25, 'gender' => 'Male'],
        ['id'=>	2, 'name'=>'Juana Vasquez', 'age' => 31, 'gender' => 'Female'],
        ['id'=>	3, 'name'=>'Jason Reyes', 'age' => 27, 'gender' => 'Male'],
        ['id'=>	4, 'name'=>'Jake Ramos', 'age' => 43, 'gender' => 'Male'],
    ]);
  
    $first = $collection->firstWhere('name', 'Juan Dela Cruz');
  
    dd($first);
}
```

Output:

![laravel-8-collection-with-first](https://ecn-storage.s3.us-west-2.amazonaws.com/articles/laravel-8-collection-with-first-and-firstwhere-methods-example-K5U7hSxVnux980.webp?ctm=1640526600)

That's it I hope you learn how to get the first element of the Laravel collection using first() and firstWhere() methods.

I hope this tutorial can help you. Kindly visit here https://codeanddeploy.com/blog/laravel/laravel-8-collection-with-first-and-firstwhere-methods-example if you want to download this code.

Happy coding :)
Introduction to App Service in Azure
Tags: tutorial, azure, devops, cloud
Published: 2022-05-16 06:32:00

In this post would be explaining some term learned from working with app service that beginner would find useful when navigating or creating an app Service.

### Platform as a Service
Platform as a Service is an Azure offering that helps you deploy application on the web without worrying about licensing, Windows or Linux version or Updating your Operating System. It helps you manage the underlying infrastructure and allows you to focus on deploying application.

### Azure App Service 
This is a Platform as a Service (PAAS) from azure that allows you to deploy your code on azure using GitHub or other Code hosting platform, it comes with a lot of pre built functions that makes deploying your app easy, examples are Authentication, API management, CI/CD etc.

### Resource Group 
Resource group is a logical container used to store resources like Storage, App Service, Virtual Network etc. on Azure.
Resource group allows you to manage all resources, manage Permission and Monitor Cost. 

### Zone Redundancy
To make your app available if there is a downtime in a particular location where your app has been deployed, you use Zone Redundancy, this is done when creating your app and it is used to deploy a copy of your app in 3 different azure zone, so that in case of a failure in a a zone another app instance continue to serve the application. 


### Deployment Slot 
If you are trying to test changes you made you previously built or you want some changes to be available to some people who visit your web app, then deployment slot is what you need. It helps you preview changes made to your app, and also share this changes with some of your website visitors to get feedback on your app.
You do this by increase the traffic sent to the new slot created, the default number is 0 percent.
How to Implement Laravel 8 using FPDF Example
Tags: laravel, larvelpdf, beginners, tutorial
Published: 2022-05-16 06:20:25

Originally posted @ https://codeanddeploy.com visit and download the sample code:
https://codeanddeploy.com/blog/laravel/how-to-implement-laravel-8-using-fpdf-example

In this post, I will show you an example how to implement Laravel 8 using FPDF. Let's use FPDF as our package to generate PDF with Laravel.

 

In my previous post I have sereval examples about PDF with other packages. Now let's do with FPDF.

 

## Step 1: Laravel Installation
If you don't have a Laravel 8 install in your local just run the following command below:

```php
composer create-project --prefer-dist laravel/laravel laravel-fpdf

cd laravel-fpdf
```


## Step 2: Install FPDF Package

To generate PDF in Laravel we need to install `laravel-fpdf` package. Run the following command below:

```php
composer require codedge/laravel-fpdf
```


 

## Step 3: Setup Routes and Controller
Let's create routes and controller for our Laravel FPDF generator.

 

**routes.php/web.php**

```php
<?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('/', function () {
    return view('welcome');
});

Route::get('pdf', [PdfController::class, 'index']);
```

Run the command below to make a controller:

```php
php artisan make:controller PdfController
```

## Step 4: Laravel FPDF Example
Then edit the `PdfController` generated. See below:


```php
<?php

namespace App\Http\Controllers;

use Codedge\Fpdf\Fpdf\Fpdf;
use Illuminate\Http\Request;

class PdfController extends Controller
{
	protected $fpdf;
 
    public function __construct()
    {
        $this->fpdf = new Fpdf;
    }

    public function index() 
    {
    	$this->fpdf->SetFont('Arial', 'B', 15);
        $this->fpdf->AddPage("L", ['100', '100']);
        $this->fpdf->Text(10, 10, "Hello World!");       
         
        $this->fpdf->Output();

        exit;
    }
}
```

Here is the result:


![how-to-implement-laravel-8](https://ecn-storage.s3.us-west-2.amazonaws.com/articles/how-to-implement-laravel-8-using-fpdf-with-example-N5WTVpJ1Fax980.webp?ctm=1637590579)

Now you have a basic how to work with Laravel FPDF package. I hope it helps.

 

To learn more about this package please visit[ here.](https://github.com/codedge/laravel-fpdf)

I hope this tutorial can help you. Kindly visit here https://codeanddeploy.com/blog/jquery/how-to-check-if-image-is-loaded-or-not-in-jquery if you want to download this code.

Happy coding :)
Why should you learn JavaScript?
Tags: javascript, webdev, beginners, programming
Published: 2022-05-16 06:06:23

There are many reasons why you should want to learn JavaScript. JavaScript originates from 1995, and is often considered the most widely used programming language. This is because JavaScript is the language that web browsers support and understand. You have everything you need to interpret it already installed on your computer if you have a web browser and text editor.

It is a great programming language for beginners, and most advanced software developers will know at least some JavaScript because they will have run into it at some point.

The first reason is that you can start building really cool apps using JavaScript sooner than you could imagine.

JavaScript can be used to write many different types of applications and scripts. It can be used for programming for the web browser, but also the logic layer of code that we cannot see (such as communication with the database) of an application can be programmed in JavaScript, along with games, automation scripts, and a plethora of other purposes. 

JavaScript can also be used for different programming
styles, by which we mean ways to structure and write code. How you would go about this depends on the purpose of your script.

There are a ton of libraries and frameworks you can use once you get the basics of JavaScript down. These libraries and frameworks will really enhance your software life and make it a lot easier and possible to get more done in less time. Examples of these great libraries and frameworks include **React, Vue.js, jQuery, Angular, andNode.js.**
Introduction to Sveltekit
Tags: svelte, javascript, webdev, wecoded
Published: 2022-05-16 06:04:14

Svelte-kit is a framework for building website with Svelte. It is a front end javascript library with the following features -

- Server and client side rendering
- comes with routing systems
- provides a backend API
- code splitting

This is also a popular SPA framework. According to mdn web docs 

> An SPA (Single-page application) is a web app implementation that loads only a single web document, and then updates the body content of that single document via JavaScript APIs such as XMLHttpRequest and Fetch when different content is to be shown.


The easiest way to start building a SvelteKit app is to run 

```
npm init svelte my-app
```
In order to have a proper functioning svelte app you need to make sure you have an updated version of `node js` installed to your system. Svelte sometimes runs into problems with older versions of node. 

If you use vs code extensions svelte for vs code is a good extension to install. This will provide us with syntax highlighting for svelte components. 

Learn more about svelte kit[ here](https://kit.svelte.dev/docs/introduction)
ZL Technologies
Tags: programming, discuss, career, news
Published: 2022-05-16 05:55:39

[ZL Tech](https://www.zlti.com/) delivers multiple opportunities to protect the data and security level for real-time business. ZL Technologies leverages unified solutions that enable organizations to solve challenges. ZL develops and distributes enterprise-level software related to [SharePoint Archive](https://www.zlti.com/data-sources/sharepoint-archive/), [Microsoft Teams archivin](https://www.zlti.com/data-sources/microsoft-teams-archiving/
), [Microsoft Office 365 email archiving](https://www.zlti.com/data-sources/microsoft-office-365-email-file-archiving/), [Enterprise data migration](https://www.zlti.com/enterprise-data-migration/), and [People Analytics](https://www.zlti.com/people-analytics/).
What exactly is Frontmatter?
Tags: markdown
Published: 2022-05-16 05:45:18

When I'm writing my articles that include Markdown files or data, I often refer to `Frontmatter`.

## What is Frontmatter?

But what is this Frontmatter exactly?

Frontmatter is a way to identify metadata in Markdown files.
Metadata can literally be anything you want it to be, but often it's used for data elements your page needs and you don't want to show directly.

Some examples of common metadata are:

- Title of the post
- Description for SEO purposes
- Tags that belong to a document
- Or the date it was written

These are only some examples, and you can make it as crazy as you want with Frontmatter.

## How to add Frontmatter?

To add Frontmatter to a Markdown document, you have to start by writing a three-dotted block at the top of your file.

```js
---
title: Frontmatter section
---

# Markdown section
```

You can see the three dots as an example in the above example. Everything in there will be seen as metadata.

Below the second three dots is where our default Markdown file will begin.

## Some basic Frontmatter options

It's important to note that Frontmatter is parsed as YAML blocks, so the indentation is important.

For instance, we can set regular variables with a colon setup:

```js
---
title: 'The document title'
---
```

Or we can convert them into an array of objects:

```js
---
tags:
	- JavaScript
	- Markdown
---
```

Alternatively, you can even use the bracket way of defining arrays.

```js
---
tags: ["JavaScript", "Markdown"]
---
```

In extreme cases, you might even want to have multidimensional object arrays.

```js
---
tech:
	- frontend
		stack: Remix
	- backend
		stack: Go
---
```

Besides arrays, you might want to use multi-line text blocks.

The first way to add this is only visually in your code editor. This will not add newlines in the outputted code.

```js
---
description: >
	this is a
	multiline
	string
---
```

Which will output: `this is a multi-line string`

However, if you want to add new lines, use the pipe method.

```js
---
description: |
	this is a
	multiline
	string
---
```

Which will output:

```txt
this is a
multi-line
string
```

## Conclusion

Frontmatter is a super intuitive way of making your Markdown files contain some metadata.

It can enhance your SEO, Website data and even render proper MDX properties.

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Enabling Service Mesh for Oracle Kubernetes Engine
Tags: kubernetes, servicemesh, monitoring, oci
Published: 2022-05-16 05:41:06

In a 𝙢𝙞𝙘𝙧𝙤𝙨𝙚𝙧𝙫𝙞𝙘𝙚𝙨 𝙖𝙧𝙘𝙝𝙞𝙩𝙚𝙘𝙩𝙪𝙧𝙚, monolithic applications are broken down into smaller microservices that 𝙘𝙤𝙢𝙢𝙪𝙣𝙞𝙘𝙖𝙩𝙚 𝙤𝙫𝙚𝙧 𝙩𝙝𝙚 𝙣𝙚𝙩𝙬𝙤𝙧𝙠 using an 𝘼𝙋𝙄. 

This causes:
(1) a 𝙨𝙪𝙧𝙜𝙚 𝙤𝙛 𝙣𝙚𝙩𝙬𝙤𝙧𝙠 𝙩𝙧𝙖𝙛𝙛𝙞𝙘 and 
(2) increases the 𝙘𝙤𝙢𝙥𝙡𝙚𝙭𝙞𝙩𝙮 and 𝙤𝙫𝙚𝙧𝙖𝙡𝙡 𝙖𝙩𝙩𝙖𝙘𝙠 𝙨𝙪𝙧𝙛𝙖𝙘𝙚 in the architecture.

Adding a 𝙨𝙚𝙧𝙫𝙞𝙘𝙚 𝙢𝙚𝙨𝙝 to the microservices 𝙖𝙡𝙡𝙚𝙫𝙞𝙖𝙩𝙚𝙨 𝙢𝙖𝙣𝙮 𝙤𝙛 𝙩𝙝𝙚 𝙘𝙝𝙖𝙡𝙡𝙚𝙣𝙜𝙚𝙨 introduced with a microservices architecture and provides the 𝙛𝙤𝙡𝙡𝙤𝙬𝙞𝙣𝙜 𝙗𝙚𝙣𝙚𝙛𝙞𝙩𝙨:
(1) 🚦Allows you to 𝙘𝙤𝙣𝙩𝙧𝙤𝙡 the microservices 𝙩𝙧𝙖𝙛𝙛𝙞𝙘 𝙛𝙡𝙤𝙬.
(2) 🔭 Provides 𝙫𝙞𝙨𝙞𝙗𝙞𝙡𝙞𝙩𝙮 into your 𝙖𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣𝙨.
(3) 🔐 Enables microservices to 𝙘𝙤𝙣𝙣𝙚𝙘𝙩 𝙨𝙚𝙘𝙪𝙧𝙚𝙡𝙮 without any changes to the application code.

𝙊𝘾𝙄 𝙎𝙚𝙧𝙫𝙞𝙘𝙚 𝙈𝙚𝙨𝙝 uses a 𝙨𝙞𝙙𝙚𝙘𝙖𝙧 𝙢𝙤𝙙𝙚𝙡. This architecture:
(1) encapsulates the code implementing the network functionality into a network proxy and then 
(2) relies on traffic from and to services to be redirected into the sidecar proxy. 

In Oracle 𝙆𝙪𝙗𝙚𝙧𝙣𝙚𝙩𝙚𝙨 𝙀𝙣𝙜𝙞𝙣𝙚 (𝙊𝙆𝙀), the application container sits 𝙖𝙡𝙤𝙣𝙜𝙨𝙞𝙙𝙚 𝙩𝙝𝙚 𝙥𝙧𝙤𝙭𝙮 𝙨𝙞𝙙𝙚𝙘𝙖𝙧 𝙘𝙤𝙣𝙩𝙖𝙞𝙣𝙚𝙧 𝙞𝙣 𝙩𝙝𝙚 𝙨𝙖𝙢𝙚 𝙥𝙤𝙙. Since they are in the same pod, they share:
(1) the 𝙨𝙖𝙢𝙚 𝙣𝙚𝙩𝙬𝙤𝙧𝙠 𝙣𝙖𝙢𝙚𝙨𝙥𝙖𝙘𝙚 and 
(2) 𝙄𝙋 𝙖𝙙𝙙𝙧𝙚𝙨𝙨, 
allowing the 𝙘𝙤𝙣𝙩𝙖𝙞𝙣𝙚𝙧𝙨 𝙩𝙤 𝙘𝙤𝙢𝙢𝙪𝙣𝙞𝙘𝙖𝙩𝙚 𝙫𝙞𝙖 “𝙡𝙤𝙘𝙖𝙡𝙝𝙤𝙨𝙩.”

𝙀𝙣𝙖𝙗𝙡𝙚 𝙊𝘾𝙄 𝙎𝙚𝙧𝙫𝙞𝙘𝙚 𝙈𝙚𝙨𝙝 𝙤𝙣 𝙮𝙤𝙪𝙧 𝙆𝙪𝙗𝙚𝙧𝙣𝙚𝙩𝙚𝙨 𝙖𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣𝙨
https://docs.oracle.com/en/solutions/oci-service-mesh-oke/index.html#GUID-12216A44-2E62-48D8-8C89-864335BE9EF6

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jto75r56um5b81qjv71l.png)
Azure App Services #1
Tags: paas, iaas, webapp, azure
Published: 2022-05-16 05:35:06

Azure App Service is a web application, REST API, and mobile back end hosting service that runs on HTTP. You can code in any language you like, including ASP.NET,.NET Core, Java, Ruby, Node.js, PHP, or Python. Both Windows and Linux-based systems make it easy to run and scale applications.

App Service not only adds the security, load balancing, autoscaling, and automated management features of Microsoft Azure to your application. It also has DevOps features including continuous deployment via Azure DevOps, GitHub, Docker Hub, and other sources, package management, staging environments, custom domains, and TLS/SSL certificates.

You pay for the Azure compute resources you utilize with App Service. The App Service plan that you choose determines the computational resources you use.

Navigating your way to App Serivces on Azure Portal
1. The first thing to do after logging in your azure platform at portal.azure.com

![A guide to navigating your way on Azure portal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zomxy1q4onxgeomc8w0a.png)

2. In creating your first app service....

![Creating your app service](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iql6qbys4yswnskd560k.png)

Watch out for the continuation.