<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: srsagor</title>
    <description>The latest articles on DEV Community by srsagor (@srsagor).</description>
    <link>https://dev.to/srsagor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F625296%2F46ae1f20-de67-4ce7-a072-300b78b07f13.png</url>
      <title>DEV Community: srsagor</title>
      <link>https://dev.to/srsagor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/srsagor"/>
    <language>en</language>
    <item>
      <title>How to confige Elasticsearch in our local system</title>
      <dc:creator>srsagor</dc:creator>
      <pubDate>Tue, 22 Jun 2021 12:37:04 +0000</pubDate>
      <link>https://dev.to/srsagor/how-to-confige-elasticsearch-in-our-local-system-2e39</link>
      <guid>https://dev.to/srsagor/how-to-confige-elasticsearch-in-our-local-system-2e39</guid>
      <description>&lt;p&gt;In this tutorials we have learn how to config a Elastic search in our local system. Our original Post &lt;a href="https://codingspoint.com/how-to-config-elastic-search-in-our-local-system/"&gt; Here &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;follow this step and easily configer an Elastic Search.&lt;/p&gt;

&lt;p&gt;1) Step 1 — Installing Java :&lt;/p&gt;

&lt;p&gt;-Before installing OpenJDK with APT, update the list of available packages for installation on your Ubuntu Droplet by running the command:&lt;/p&gt;

&lt;p&gt;$ sudo apt-get update&lt;/p&gt;

&lt;p&gt;-After that, you can install OpenJDK with the command:&lt;/p&gt;

&lt;p&gt;$ sudo apt-get install openjdk-7-jre&lt;/p&gt;

&lt;p&gt;-To verify your JRE is installed and can be used, run the command:&lt;/p&gt;

&lt;p&gt;$ java -version&lt;/p&gt;

&lt;p&gt;2) Step 2 — Downloading and Installing Elasticsearch :&lt;/p&gt;

&lt;p&gt;$ wget &lt;a href="https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.2.deb"&gt;https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.2.deb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-Then install it in the usual Ubuntu way with the dpkg command like this:&lt;/p&gt;

&lt;p&gt;$ sudo dpkg -i elasticsearch-1.7.2.deb&lt;/p&gt;

&lt;p&gt;-To make sure Elasticsearch starts and stops automatically with the Droplet, add its init script to the default runlevels with the command:&lt;/p&gt;

&lt;p&gt;$ sudo update-rc.d elasticsearch defaults&lt;/p&gt;

&lt;p&gt;Step 3 — Configuring Elastic :&lt;br&gt;
Laravel Query Builder Where Exists Example&lt;/p&gt;

&lt;p&gt;-To start editing the main elasticsearch.yml configuration file:&lt;/p&gt;

&lt;p&gt;$ sudo nano /etc/elasticsearch/elasticsearch.yml&lt;/p&gt;

&lt;p&gt;-Remove the # character at the beginning of the lines for node.name and cluster.name to uncomment them, and then change their values.&lt;/p&gt;

&lt;p&gt;node.name: "My First Node"&lt;/p&gt;

&lt;p&gt;cluster.name: mycluster1&lt;/p&gt;

&lt;p&gt;-Once you make all the changes, please save and exit the file. Now you can start Elasticsearch for the first time with the command:&lt;/p&gt;

&lt;p&gt;$ sudo service elasticsearch start&lt;/p&gt;

&lt;p&gt;Step 4 — Securing Elastic :&lt;/p&gt;

&lt;p&gt;-Elasticsearch has no built-in security and can be controlled by anyone who can access the HTTP API. So, the first security tweak is to prevent public access. To remove public access edit the file elasticsearch.yml:&lt;/p&gt;

&lt;p&gt;$ sudo nano /etc/elasticsearch/elasticsearch.yml&lt;/p&gt;

&lt;p&gt;-Find the line that contains network.bind_host, uncomment it by removing the # character at the beginning of the line, and change the value to localhost so it looks like this:&lt;/p&gt;

&lt;p&gt;network.bind_host: localhost&lt;/p&gt;

&lt;p&gt;-To disable custom expressions, add the following line is at the end of the /etc/elasticsearch/elasticsearch.yml file:&lt;/p&gt;

&lt;p&gt;script.disable_dynamic: true&lt;/p&gt;

&lt;p&gt;Step 5 — Testing :&lt;/p&gt;

&lt;p&gt;$ curl -X GET '&lt;a href="http://localhost:9200"&gt;http://localhost:9200&lt;/a&gt;' or run &lt;a href="http://localhost:9200"&gt;http://localhost:9200&lt;/a&gt; in any browser.&lt;/p&gt;

&lt;p&gt;You should see the following response:&lt;/p&gt;

&lt;p&gt;{&lt;/p&gt;

&lt;p&gt;"status" : 200,&lt;/p&gt;

&lt;p&gt;"name" : "Harry Leland",&lt;/p&gt;

&lt;p&gt;"cluster_name" : "elasticsearch",&lt;/p&gt;

&lt;p&gt;"version" : {&lt;/p&gt;

&lt;p&gt;"number" : "1.7.2",&lt;/p&gt;

&lt;p&gt;"build_hash" : "e43676b1385b8125d647f593f7202acbd816e8ec",&lt;/p&gt;

&lt;p&gt;"build_timestamp" : "2015-09-14T09:49:53Z",&lt;/p&gt;

&lt;p&gt;"build_snapshot" : false,&lt;/p&gt;

&lt;p&gt;"lucene_version" : "4.10.4" &lt;/p&gt;

&lt;p&gt;},&lt;/p&gt;

&lt;p&gt;"tagline" : "You Know, for Search" &lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Laravel Where Clause with Mysql Function Example
</title>
      <dc:creator>srsagor</dc:creator>
      <pubDate>Tue, 22 Jun 2021 12:24:51 +0000</pubDate>
      <link>https://dev.to/srsagor/how-to-image-validation-in-laravel-26a4</link>
      <guid>https://dev.to/srsagor/how-to-image-validation-in-laravel-26a4</guid>
      <description>&lt;p&gt;When you are working on laravel projects and you need to use mysql function in where clause then you can easily use that using DB::raw() and whereRaw(). In this example you can show how to i use mysql function in where clause. In this example i want to compare with year of created_at field but not whole date, that's whay i use mysql function Year(), this function will return only year from timestamp and compare with given value.&lt;br&gt;
Example 1:&lt;/p&gt;

&lt;p&gt;$data = DB::table("items")-&amp;gt;select("items.*")&lt;br&gt;
            -&amp;gt;where(DB::raw("Year(items.created_at)"),'2016')&lt;br&gt;
            -&amp;gt;orderBy('items.created_at')&lt;br&gt;
            -&amp;gt;get();&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;$data = DB::table("items")-&amp;gt;select("items.*")&lt;br&gt;
            -&amp;gt;whereRaw(DB::raw("Year(items.created_at) = '2016'"))&lt;br&gt;
            -&amp;gt;orderBy('items.created_at')&lt;br&gt;
            -&amp;gt;get();&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Image Validation in Laravel ?</title>
      <dc:creator>srsagor</dc:creator>
      <pubDate>Tue, 04 May 2021 10:47:52 +0000</pubDate>
      <link>https://dev.to/srsagor/how-to-image-validation-in-laravel-3j46</link>
      <guid>https://dev.to/srsagor/how-to-image-validation-in-laravel-3j46</guid>
      <description>&lt;p&gt;So the file validation in file size to validate the file in laravel application. Now in case of string, it validates the length in characters. So now we need to a new validation option: image dimensions for image uploads. Now the validation rule is called dimensions.&lt;/p&gt;

&lt;p&gt;public function solution(Request $request)&lt;br&gt;
{&lt;br&gt;
    $request-&amp;gt;validate([&lt;br&gt;
        'image' =&amp;gt; 'required|image|mimes:jpg,png,jpeg,gif,svg|max:2048|dimensions:min_width=100,min_height=100,max_width=1000,max_height=1000',&lt;br&gt;
    ]);&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;a&gt; Details&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
