Read Latest Blog
What is oops in PHP

What is oops in PHP

<p>Oops stands for object-oriented programming language. It is also known as a procedural programming language. It is a programming approach or paradigm that gives us prime consideration of the data and its associated functions. with the help of we can perform operations on data.</p> <p>It allows you to structure your code more organized and modularly, making it easier to manage and maintain.</p> <p><strong>It has several advantages.</strong></p> <ol class="listc"> <li>It is faster and easier to execute.</li> <li>It provides us with the standard structure of programming language.</li> <li>It helps us to debug, make it easy to maintain, modify the code and work on the DRY principle ( Don&rsquo;t Repeat Yourself ).</li> <li>It reduces the code with a shorter time.</li> <li>It provides higher security and less exposure to the data.</li> <li>The object-oriented is used to describe the application&rsquo;s functionality.</li> </ol> <h1 class="ht1"><strong>What is a class in PHP?</strong></h1> <p>In PHP, we can define a class by using the &ldquo;class&rdquo; keyword. It encapsulates the properties (attributes) and behaviours (methods).</p> <p>The class is the blueprint or a set of instructions to build a specific type of object.</p> <ol class="listc"> <li>The class is a template for objects.</li> <li>The class is an entity that is used to determine how an object will behave and what the object will contain.</li> <li>The class is used to hold the objects along with their behavior and properties.</li> <li>It is a programmer-defined data type, that includes local functions as well as local data. You can think of a class as a template for making many instances of the same kind (or class) of object.</li> </ol> <p><strong>Example1</strong></p> <pre><code>&lt;?php<br />class Car {<br /> public function name() {<br /> &nbsp;&nbsp;&nbsp; echo " This is the Simple Example of class";<br /> }<br />}<br />$obj= new Car;<br />$obj-&gt;name();<br />?&gt;</code></pre> <p><strong>Output</strong></p> <p>This is a Simple Example of a class</p> <p><strong>Example 2</strong></p> <pre><code>&lt;?php<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">class Fruit {</span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">function name($parm) {<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> echo $parm;<br /></span>&nbsp; }<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">}</span><br />$apple = new Fruit();<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">echo $apple-&gt;name("Mango");<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">?&gt;<br /></span></code></pre> <p><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">Output</span></p> <p>Mango</p> <p><strong>Example 3</strong></p> <pre><code>&lt;?php<br />class Car{ <br /> &nbsp;&nbsp; private $name= "My Fav Car Hyundai Creta";&nbsp;<br /> &nbsp;&nbsp; public function display(){ <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $this-&gt;name;&nbsp;<br /> &nbsp;&nbsp; }&nbsp;<br />} <br />$obj = new Car(); <br />$obj-&gt;display(); <br />?&gt;<br /><br /><strong>Output<br /></strong>My Fav Car Hyundai Creta<strong><br /></strong></code></pre> <p>&nbsp;</p> <h1 class="ht1">What is an object in PHP?</h1> <p>In PHP, objects can be related to the entities in real life It considers everything that we can see around us, as an object that has some attributes. An object is an instance of a class. It's created from a class blueprint using the new keyword followed by the class name, optionally passing arguments to the constructor if it's defined. Objects have properties (attributes) and methods defined by their class.</p> <p>Multiple objects can be created from the same class, each having its own set of property values. Objects allow you to work with specific instances of a class, allowing for data encapsulation and code reuse.</p> <ol class="listc"> <li>An object is an instance of class.</li> <li>Objects have properties (attributes) and methods defined by their class.</li> <li>An object is something that is used to perform a set of related activities.</li> <li>We can define a class once and then create one or more objects that belong to it.</li> <li>Multiple objects can be created from the same class, each having its own set of property values.</li> <li>An Object is an individual instance of the data structure defined by a class.</li> <li>Class methods and properties can be accessed directly through object instances.</li> <li>We we use the connector (Dot operator-&gt;) symbol to connect objects to their properties or methods.</li> </ol> <div> <div><strong>Example1:</strong></div> <pre><code>&lt;?php <br />class Office <br />{ <br /> // Class properties<br /> // methods go here &nbsp;<br />} <br />$obj = new Office; <br />var_dump($obj); <br />?</code></pre> <br /> <div><strong>Example 2</strong></div> <pre><code>&lt;?php<br />class Office{<br /> public function Chair_name(){<br /> &nbsp; &nbsp; echo "This is Desk Chair"."&amp;lt;br&amp;gt;";<br /> }<br /> public function price(){<br /> &nbsp; &nbsp;echo "RS- 500";<br /> }<br />}<br />$obj = new Office();<br />$obj-&amp;gt;chair_name();<br />$obj-&amp;gt;price();<br />?&gt;</code></pre> <div><strong>Output</strong></div> <div>This is Desk Chair</div> <div>RS- 500</div> <div>&nbsp;</div> <div><strong>Example 3</strong></div> <pre><code>&lt;?php <br />class Room <br />{ <br /> &nbsp; private $name= "Kitchen Room"; &nbsp;<br /> &nbsp; public function display(){ &nbsp;<br /> &nbsp; &nbsp; &nbsp; echo $this-&amp;gt;name; &nbsp;<br /> &nbsp; } &nbsp;<br />} <br />$obj = new Room(); <br />$obj-&amp;gt;display(); <br />? &gt;&nbsp;</code></pre> <div><strong>Output</strong></div> <div>Kitchen Room</div> <div>&nbsp;</div> <div> <div> <h1 class="ht1">What is a Constructor in PHP?</h1> <div>In PHP, the constructor is used to initialize the object of properties,</div> <div>In other words, we can say that it automatically calls when the object will be initializing.</div> <div>If a class name and function name are similar in that case function is known as constructor.</div> <div>We can create a constructor by using the "__construct" Keyword.</div> <br /> <div><strong>Example1</strong></div> <pre><code>&lt;?php<br />class Car{<br /> &nbsp; function CarModel(){<br /> &nbsp; &nbsp; &nbsp; echo "This is the CarModel function. It will automatically invoke";<br /> &nbsp; }<br /> &nbsp; function Car(){<br /> &nbsp; &nbsp; &nbsp; echo "User Defined Constructor (Class name and function Car() name is same )"."&lt;br&gt;";<br /> &nbsp; }<br />}<br />$obj= new Car();<br />$obj-&gt;CarModel();<br />?&gt;</code></pre> <div><strong>Output</strong></div> <div>User Defined Constructor (Class name and function Car() name is same )</div> <div>This is the CarModel function. It will automatically invoke</div> <br /> <div><strong>Example2</strong></div> <pre><code>&lt;?php<br />class Car{<br /> &nbsp; function CarName(){<br /> &nbsp; &nbsp; &nbsp; echo "Car Name- Thar";<br /> &nbsp; }<br /> &nbsp; function __construct(){<br /> &nbsp; &nbsp; &nbsp; echo "This is predefined constructor"."&lt;br&gt;";<br /> &nbsp; }<br />}<br />$obj= new Car();<br />$obj-&gt;CarName();<br />?&gt;</code></pre> <div><strong>Output</strong></div> <div>This is the predefined constructor</div> <div>Car Name- Thar</div> <br /> <div><strong>Example 3</strong></div> <pre><code>&lt;?php<br />class Car{<br /> &nbsp; public $name;<br />&nbsp; &nbsp; function __construct($name){<br /> &nbsp; &nbsp; &nbsp; $this-&gt;name = $name;<br /> &nbsp; }<br /> &nbsp; function get_name(){<br /> &nbsp; &nbsp; &nbsp; return $this-&gt;name;<br /> &nbsp; }<br />}<br />$obj= new Car("THAR");<br />echo $obj-&gt;get_name();<br />?&gt;</code></pre> <div><strong>Output</strong></div> <div>THAR</div> <div>&nbsp;</div> <div> <div> <h1 class="ht1">What is a destructor in PHP?</h1> <p>In PHP, a destructor is a special type of method or function within a class.</p> <p>It is automatically called when an object is destroyed or goes out of scope or the script is stopped or exited.</p> </div> <p>It is defined by using the __destruct() method name.</p> <p>It will be automatically call the function at the end of the script.</p> <p>It is typically used to perform cleanup tasks like closing files or database connections before an object is destroyed.</p> <br /> <div><strong>Example 1</strong></div> <pre><code>&lt;?php<br />class Car {<br /> &nbsp; public function __construct() {<br /> &nbsp; &nbsp; &nbsp; echo "Constructor called"."&lt;br&gt;";<br /> &nbsp; }<br /> &nbsp; public function __destruct() {<br /> &nbsp; &nbsp; &nbsp; echo "Destructor called";<br /> &nbsp; }<br />}<br />$obj = new Car(); // Output: Constructor called<br />unset($obj); &nbsp; &nbsp; &nbsp; &nbsp; // Output: Destructor called<br />?&gt;</code></pre> <br /> <div><strong>Example 2</strong></div> <pre><code>&lt;?php<br />class Car {<br /> public $name;<br /> public $color;<br /> function __construct($name) {<br /> &nbsp; $this-&gt;name = $name;<br /> }<br /> function __destruct() {<br /> &nbsp; echo "My Car name is : {$this-&gt;name}.";<br /> }<br />}<br />$obj = new Car("Thar");<br />?&gt;</code></pre> <br /> <div><strong>Example 3</strong></div> <pre><code>&lt;?php <br /> &nbsp; class car{ &nbsp;<br /> &nbsp; public function car(){ &nbsp;<br /> &nbsp; &nbsp; &nbsp;echo "User defined constructor1"."&lt;br&gt;"; &nbsp;<br /> &nbsp; &nbsp; &nbsp;} &nbsp;<br /> &nbsp; } &nbsp;<br /> &nbsp; class car2 extends car{ &nbsp;<br /> &nbsp; public function __construct(){ &nbsp;<br /> &nbsp; &nbsp; &nbsp;echo parent::car(); &nbsp;<br /> &nbsp; &nbsp; &nbsp;echo "User Defined Extended constructor2"."&lt;br&gt;"; &nbsp;<br /> &nbsp; } &nbsp;<br /> &nbsp; public function __destruct(){ &nbsp;<br /> &nbsp; &nbsp; echo "Destroy"; &nbsp;<br /> &nbsp; } &nbsp;<br />} <br />$obj= new car2(); <br />?&gt; &nbsp;</code></pre> </div> </div> </div> </div> <div> <h2>What is an Access Modifier in PHP?</h2> <div>In PHP, access modifiers are used to control the visibility of class properties and methods.</div> <div>Properties and methods can have access modifiers. It can be controlled where we can be accessed.</div> <div>In other words, we can say that the Access Modifier allows us to alter the visibility of class members (properties and method).</div> <div>There are three main access modifiers:</div> <ol> <ol> <li>&nbsp;Public</li> <li>&nbsp;Protected</li> <li>&nbsp;Private</li> </ol> </ol> <h2 class="ht2">1. Public Access Modifier</h2> <p>&nbsp; &nbsp;public access modifier is default, we can access the property or method from everywhere.</p> <p>&nbsp; &nbsp;In other words, we can say that it is open to use and access inside the class definition and outside the class definition.</p> <p>&nbsp; &nbsp;Public access modifiers can be accessed publicly, even from outside or inside of the scope of the class.</p> <p><strong>&nbsp; &nbsp;Example 1</strong></p> <pre><code> &nbsp; &lt;?php<br /> &nbsp; class Car {<br /> &nbsp; &nbsp; &nbsp; public $name;<br /> &nbsp; &nbsp; &nbsp; protected $color;<br /> &nbsp; &nbsp; &nbsp; private $Model;<br /> &nbsp; }<br /> &nbsp; $obj = new Car();<br /> &nbsp; echo $obj-&gt;name = 'THAR'; // OK<br /> &nbsp; echo $obj-&gt;color = 'RED'; // ERROR<br /> &nbsp; echo $obj-&gt;weight = 'LX Hard Top trim'; // ERROR<br />&nbsp; &nbsp; ?&gt;</code></pre> <div>&nbsp; &nbsp; Output</div> <div>&nbsp; &nbsp;THAR</div> <div><strong>Example 2</strong></div> <pre><code>&lt;?php <br />class Car{ <br /> public $name="RED THAR"; &nbsp;<br /> &nbsp; function display(){ &nbsp;<br /> &nbsp; &nbsp; &nbsp; echo $this-&gt;name."&lt;br/&gt;"; &nbsp;<br /> &nbsp; }<br />} <br />class Model extends Car{ <br /> function show(){ &nbsp;<br /> &nbsp; &nbsp; echo $this-&gt;name; &nbsp;<br /> &nbsp; &nbsp;} &nbsp;<br /> } &nbsp; &nbsp;<br />$obj= new Model; <br />echo $obj-&gt;name."&lt;br&gt;"; &nbsp; <br />$obj-&gt;display(); <br />$obj-&gt;show(); <br />?&gt;<code></code></code></pre> <div>Output</div> <div>RED THAR</div> <div>RED THAR</div> <div>RED THAR</div> <br /> <h2 class="ht2">2. Protected Access Modifier</h2> <div>&nbsp; &nbsp;Protected access modifier is access &nbsp;within the class and parent or inherited classes.</div> <div>&nbsp; &nbsp;In another words we can say the property or method can be accessed within the class and by classes derived from that class</div> <div>&nbsp; <strong>&nbsp;Example 1.</strong></div> <pre><code> &nbsp;&lt;?php<br /> &nbsp; class Test{<br /> &nbsp; &nbsp; &nbsp; protected $a=200;<br /> &nbsp; &nbsp; &nbsp; protected $b=300;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function add(){<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Addition of (A+B): ".$sum=$this-&gt;a+$this-&gt;b."&lt;br/&gt;";<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp;<br /> &nbsp; &nbsp; &nbsp; } &nbsp;<br /> &nbsp; &nbsp; &nbsp; class childtest extends test{<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function sub(){<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "Subtraction of (A-B): ".$sub=$this-&gt;a-$this-&gt;b."&lt;br/&gt;";<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br /> &nbsp; &nbsp; &nbsp; } &nbsp;<br /> &nbsp; &nbsp; &nbsp; $obj= new childtest;<br /> &nbsp; &nbsp; &nbsp; $obj-&gt;add();<br /> &nbsp; &nbsp; &nbsp; $obj-&gt;sub();<br />&nbsp; &nbsp; ?&gt; &nbsp;</code></pre> <h2 class="ht2">3. Private Access Modifier</h2> <div>In Private access modifier the property or method can &nbsp;be accessed within the class.</div> <div>( it can't be access outside the class means in inherited class).</div> <br /> <div><strong>Example1</strong></div> <pre><code>&lt;?php<br />class Car{<br /> &nbsp; private $name="THAR CAR";<br /> &nbsp; private function show(){<br /> &nbsp; &nbsp; &nbsp; echo "This is private method of parent class";<br /> &nbsp; }<br />} <br />class Model extends Car{<br /> &nbsp;function show1(){<br /> &nbsp; &nbsp; &nbsp;echo $this-&gt;name;<br /> &nbsp;}<br />} <br />$obj= new Model();<br />$obj-&gt;show();<br />$obj-&gt;show1();<br />?&gt;</code></pre> <div>Output Fatal error: Call to private method demo::show()</div> <br /> <div><strong>Example2</strong></div> <pre><code>class parents{ <br />public $name="Thar";<br />protected $Model="Thar-02913";<br />private $price=50000;<br />public function show(){<br /> &nbsp; echo "Welcome : ".$this-&gt;name."&lt;br/&gt;";<br /> &nbsp; echo "Profile : ".$this-&gt;profile."&lt;br/&gt;";<br /> &nbsp; echo "Salary : ".$this-&gt;price."&lt;br/&gt;";<br /> &nbsp; }<br />} <br />class childs extends parents{ <br /> &nbsp; &nbsp;public function show1(){<br /> &nbsp; &nbsp; &nbsp; echo "My New Car : ".$this-&gt;name."&lt;br/&gt;";<br /> &nbsp; &nbsp; &nbsp; echo "Model : ".$this-&gt;profile."&lt;br/&gt;";<br /> &nbsp; &nbsp; &nbsp; echo "Price : ".$this-&gt;salary."&lt;br/&gt;";<br /> }<br />} <br />$obj= new childs; <br />$obj-&gt;show1();<br />?&gt;</code></pre> <br /> <div><strong>Example3</strong></div> <pre><code>&lt;?php<br />class parents{ <br />public $name="Thar";<br />protected $model="Thar-02913";<br />private $price=50000;<br />public function show(){<br /> &nbsp; echo "Welcome : ".$this-&gt;name."&lt;br/&gt;";<br /> &nbsp; echo "Profile : ".$this-&gt;model."&lt;br/&gt;";<br /> &nbsp; echo "Salary : ".$this-&gt;price."&lt;br/&gt;";<br /> &nbsp; }<br />} <br />class childs extends parents{ <br /> &nbsp;public function show1(){<br /> &nbsp; &nbsp; &nbsp; echo "My New Car : ".$this-&gt;name."&lt;br/&gt;";<br /> &nbsp; &nbsp; &nbsp; echo "Model : ".$this-&gt;model."&lt;br/&gt;";<br /> &nbsp; &nbsp; &nbsp; echo "Price : ".$this-&gt;salary."&lt;br/&gt;";<br /> }<br />} <br />$obj= new childs; <br />$obj-&gt;show1();<br />?&gt;</code></pre> <div><strong>Output</strong></div> <div>My New Car : Thar</div> <div>Model : Thar-02913</div> <div>Price :</div> <div>&nbsp;</div> <h2>&nbsp;</h2> <div> <h1 class="ht1">What is Encapsulation in PHP?</h1> <p>In PHP, encapsulation is a fundamental concept in object-oriented programming (oops) that binds the data and methods within a class. It provides us protective barrier around the internal workings of an object.</p> <p>In PHP, encapsulation means wrapping up data members and methods (functions) in a single module. In other words, it is a technique of binding data members and methods.</p> <p>Hiding the essential internal property of that module is known as data abstraction.</p> <p>When we wrap up data members and methods together into a single unit that is called Encapsulation.</p> <p>It allows us to change class to internal implementation without affecting the overall functioning of the system.</p> <p><img style="display: block; margin-left: auto; margin-right: auto;" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wgARCADBAeUDASIAAhEBAxEB/8QAGwABAAIDAQEAAAAAAAAAAAAAAAQFAQIDBgf/xAAaAQEAAwEBAQAAAAAAAAAAAAAAAQIEAwUG/9oADAMBAAIQAxAAAAH6oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABjPJFXjPXtz44kIRdc7S46TtJiBpO52iFiVymtjdeV9Vx7BzuAAAAAAAAAAVdL2y+ueMsJj0bTfhqBIAAAAAAADl15Ipe0Dto5TNovSs1HKf2pamzaJRLflKmI3OXrMQfTee9DWwc7gAAAAAACKrK08r57X53rfNwc7PJ1zs6440G089fVdfUPiN1j9n6+pXmeldKUXSlF0pRdKUXSlF0pRdKUXSlEe7+a+7KXp2rtWef0rswtelTtFrfao2ibfNRtC1xV5hJvvNelrcKWAAAAANaWtryD4yNk1zqmx3ydIHOdD9j53Vxi+98/Nj1UNvnQeetfS311xTT97lVFv4/YIkAAADhH3xw7a46InnjriJ447conTnJ0i3DXfNLct2tbXWY0vdh1bLRq2AAAAABD85aPT0kGJm0Rtp+PJ9Pm35xwxF61lesqJCi6axI0mF9Z4O2uNb22xrpS2+3D2/J9P7Hn9AAAADzfpCDpnhl1SPE+wiTHnpVh1vSHWel5Ig9e3aJ8v66FYJayNed+k2FN0ZwvUAAAABCm+JtHm5VXnk9T1rZvn9+sislRGKn1fm73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w9AKxKNb3KQWMWhW/T1JToSBUsGddoM2x1fWVRaOn5jBWx2fubjxtUzBotI/SZsAPdEpiBQHXmaYuABRODxUi54+BVTl+/g7jJ9QFBaSY4mHRBHm+JTqQULJSi88BKo7rJld0XQCfcTa80pHLvUunUF4LQcgo10SglXuvuKrKiliJq3gKlYFQMXAKQIORdISpAparSXBkFruyqRd4hhVU6oKxqyuIWrl9vlXqSgCYToNyJljoDWe1xNPfCr6aRgo22fUaVLKuzCU7yiUWLNNsd4hjoWAW6kxsG9kEhXY7y3BiCFFN2JaqDrcehWml7Q/gFOuEWawAMfAKhy/fwOT+CJJAzDEjFTcfj5XeAx23/AFEEnKpUpDVBjfeEbPSLIAvqcytZd3bVhpIssrVPSPEIaO0csNyiNCwOkJx82WpuEgOk1vB6E6kAfC1ztXqf1DnBN4PROhes/s03fqT+1w/t4f2sP7Cf6kVSkFc4+Ve00HdgCOu7BcaKsKmeENoascUrFJcpUJ5syALxKxdFzwgrFX1grpIE0mYwrACDXSdSAGnxKMrrHRXUdooqFwfDGDBgwYMGDBgwdMOLadtvlV0LMMEosGneDoJoTHWrBIvyINQUVUr7ykII7EGwJrDH/PZZYZfiPZW20AemiCLuzCHE1rzAN3m4YGIFGYZ0ibwBp/0tBJIhNTyuMaAK3FuK2HPSYYlwTXpK0NGCdNIBrmAGn/V+4ho7/ianvafen3oQ/wCl/9k=" /></p> <br /> <div><strong>Advantages of Encapsulation</strong></div> <ol class="listc"> <li>Data Hiding</li> <li>Code Organization and Maintainability</li> <li>Code Reusability</li> <li>Abstraction</li> <li>Security and Validation</li> <li>Flexibility and Extensibility</li> </ol> <br /> <div><strong>Disadvantages of Encapsulation</strong></div> <ol class="listc"> <li>Increased Complexity</li> <li>Overhead in Performance</li> <li>Dependency on Class Structure</li> <li>Limited Accessibility</li> <li>Potential for Code Duplication</li> <li>Testing Challenges</li> </ol> <br /> <div><strong>Example 1</strong></div> <pre><code>&lt;?php&nbsp; <br />class car{&nbsp;&nbsp;<br /> public $name;&nbsp; <br /> public $price;&nbsp; <br /> function __construct($n, $p)&nbsp; {&nbsp; <br /> $this-&gt;name=$n;&nbsp; <br /> $this-&gt;price=$m;&nbsp; <br /> }&nbsp; <br /> public function setPrice($pr){&nbsp; <br /> $this-&gt;pr=$pr;&nbsp; <br /> &nbsp;}&nbsp;&nbsp;<br /> &nbsp;public function display(){&nbsp;&nbsp;<br /> echo&nbsp; "We have Kids Toy : ".$this-&gt;name."&lt;br/&gt;";&nbsp; <br /> &nbsp; &nbsp; return $this-&gt;color=$this-&gt;pr;&nbsp; &nbsp;<br /> &nbsp;}&nbsp;&nbsp;<br />}&nbsp; &nbsp; <br />// Create a Car object and set Car name, price<br />$obj=new car("THAR",5000000);&nbsp;<br /><br />// Update the car price setPrice() method<br />$obj-&gt;setPrice(900000);&nbsp; <br /><br />// Display the updated Price<br />echo "Price: ".$obj-&gt;display(); <br />?&gt;</code></pre> <strong>Output</strong> <div>We have Kids Toy: THAR</div> <div>Price : 900000</div> <br /> <div><strong>Example 2</strong></div> <div> <pre><code>&lt;?php<br />class calculator{<br /> var $x=100;<br /> var $y=50;<br /> function sum(){<br /> &nbsp; &nbsp; &nbsp; $res=$this-&gt;x+$this-&gt;y;<br /> &nbsp; &nbsp; &nbsp; echo "Addition (X+Y): ".$res."&lt;br/&gt;";<br /> &nbsp; }<br /> &nbsp; function sub(){<br /> &nbsp; &nbsp; &nbsp; $res=$this-&gt;x-$this-&gt;y;<br /> &nbsp; &nbsp; &nbsp; echo "Subtraction(X-Y): ".$res."&lt;br/&gt;";<br /> &nbsp; }<br /> &nbsp; function mult(){<br /> &nbsp; &nbsp; &nbsp; $res=$this-&gt;x*$this-&gt;y;<br /> &nbsp; &nbsp; &nbsp; echo "Multiplication (X*Y): ".$res."&lt;br/&gt;";<br /> &nbsp; }<br /> &nbsp; function div(){<br /> &nbsp; &nbsp; &nbsp; $res=$this-&gt;x/$this-&gt;y;<br /> &nbsp; &nbsp; &nbsp; echo "Division(x/y) : ".$res."&lt;br/&gt;";<br /> &nbsp; }<br />}<br />$obj= new calculator( );<br />$obj-&gt;sum();<br />$obj-&gt;sub();<br />$obj-&gt;mult();<br />$obj-&gt;div();<br />?&gt;</code></pre> </div> <div><strong>Output</strong></div> <div>Addition (X+Y): 150</div> <div>Subtraction(X-Y): 50</div> <div>Multiplication (X*Y): 5000</div> <div>Division(x/y) : 2</div> </div> </div>
Read More
How to disable click outside modal to close modal in bootstrap
html

How to disable click outside modal to close modal in bootstrap

<p>In bootstrap when you want to use Modal to show any message then it is very important but one more important thing is that when click out side of the modal then modal will be disable. If you do not want to use disable back click then use following code.&nbsp;</p> <p>Bootstrap is a very powerful, extensible, and feature-packed fronted toolkit which is used to build fast and responsive websites.&nbsp;</p> <p><a href="https://www.geeksforgeeks.org/bootstrap-5/"><strong>Bootstrap</strong></a><strong>&nbsp;</strong>provides powerful <a href="https://www.geeksforgeeks.org/bootstrap-5-modal/">Modal component</a> which is used to create models within the web pages or website. In this article, we will learn how we&nbsp; can disable the click outside of the bootstrap modal area to close the modal functionality.</p> <p>Bootstrap provides the static <strong>backdrop</strong> option to set the backdrop static , it does not close the modal even if the user clicks outside the modal area.</p> <p><strong>Syntax:&nbsp;</strong></p> <p>To set the backdrop to static, in the modal set element&nbsp; &ldquo;<strong>data-bs-backdrop</strong>&rdquo; attribute to &ldquo;<strong>static</strong>&ldquo;.</p> <pre><code> &lt;div class='modal' data-bs-backdrop='static' ...&gt; ... &lt;/div&gt;</code></pre> <p><strong>Example 1</strong></p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;Prevent Back click in bootstrap Modal&lt;/title&gt; &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ &nbsp;&nbsp; &nbsp;$('.launch-modal').click(function(){ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$('#myModal').modal({ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;backdrop: 'static' &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}); &nbsp;&nbsp; &nbsp;});&nbsp; }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="bs-example"&gt; &nbsp; &nbsp; &lt;!-- Button HTML (to Trigger Modal) --&gt; &nbsp; &nbsp; &lt;input type="button" class="btn btn-lg btn-primary launch-modal" value="Click Modal"&gt; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &lt;!-- Modal HTML --&gt; &nbsp; &nbsp; &lt;div id="myModal" class="modal fade"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="modal-dialog"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="modal-content"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="modal-header"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h4 class="modal-title"&gt;Welcome to Agyanadda&lt;/h4&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="modal-body"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Clicke outside of the modal to check modal is disable or not&lt;/p&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="modal-footer"&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt; &nbsp; &nbsp; &lt;/div&gt;<br /> &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
Read More
What is traits in PHP with example
Laravel

What is traits in PHP with example

<p>In Laravel we will learn about Traits and how to upload image in folder using traits.</p> <p><strong>What are Traits?<br /></strong>PHP only support single inheritance (a child class can inherit only from one single parent). But if we want to use multi-inheritance (if a class needs to inherit multiple behaviours) then PHP OOP Traits solve this problem.</p> <p>Traits is used to declare methods that can be used in multiple classes, and it can have methods and abstract methods that can be used in multiple classes, and the methods can have any access modifier (public, private, or protected).</p> <p><strong>Note:</strong> We can declare Traits with the <code><strong>trait</strong> </code>keyword.</p> <p>Here a small example of trails just for understand. We will learn more to next point.</p> <p><strong>Example.</strong></p> <pre><code>&lt;?php<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">trait class1 {<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp;public function msg1() {<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "OOP is fun! ";<br /></span>&nbsp; &nbsp; &nbsp; }<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; }<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">Class class2 {</span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp;<br /></span> &nbsp; use class1;<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">}</span><br /><br />$obj = new class2();<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">$obj-&gt;msg1();<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">?&gt;</span></code></pre> <h2><strong>How to upload image in Laravel using Traits</strong></h2> <p>In Laravel we will upload image in public folder using traits, so there are given few step we should follow:</p> <ol> <li><strong>First Create trait folder inside the app folder.<br /></strong>We can create Traits file <code>&ldquo;saveFile.php&rdquo;</code><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> inside </span><code>&ldquo;App\Traits&rdquo;</code><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> folder and follow the below code.</span></li> </ol> <pre><code>&lt;?php<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">namespace App\traits;<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">trait saveFile{<br /></span>&nbsp; &nbsp; &nbsp; &nbsp;protected function saveImage($file){<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$image_name= time().'.'.$file-&gt;extension(); // get image name<br /></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$file-&gt;move(public_path('images/'), $image_name); // move image to public image folder<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return $image_name;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp;}</span></code></pre> <ol start="2"> <li> <p><strong>Now create Blade file as per your&nbsp;</strong><strong>choice<br /></strong><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">We are going to create blade </span><code>&ldquo;blog.balde.php&rdquo;</code><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> file inside views folder and create form for upload image. In form action </span><code>&ldquo;saveImageTrait&rdquo;</code><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> route we will create next part.</span></p> </li> </ol> <pre><code>&lt;div class="container"&gt;<br />&lt;h2&gt;Upload Image Via Traits&lt;/h2&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp; &lt;label for="email"&gt;Image Upload&lt;/label&gt;<br /> &lt;form action="{{url('saveImageTrait')}}" method="post" enctype="multipart/form-data"&gt;<br /> @csrf<br /> &lt;div class="form-group"&gt;<br /> &lt;input type="file" class="form-control" name="image"&gt;<br /> &lt;/div&gt;<br /> &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;<br /> &lt;/form&gt;<br />&lt;/div&gt;<br /><br /></code></pre> <ol start="3"> <li><strong>Create Controller and call traits.<br /></strong>Now we will create a controller and call traits function , you can create controller using given below command.</li> </ol> <pre><code>php artisan make:controller BlogController</code></pre> <p>Now put the given code into it</p> <pre><code>&lt;?php<br />namespace App\Http\Controllers;<br />use App\Models\blogs; // add Model<br />use Illuminate\Http\Request;<br />use App\Traits\saveFile; // Declare traits<br />class BlogsController extends Controller<br />{&nbsp; <br /> use&nbsp; saveFile;&nbsp; // use traits<br /> &nbsp;&nbsp; public function saveImageTrait(Request $request){<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> /* saveImage() call from traits class */<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $imageName=$this-&gt;saveImage($request-&gt;image);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /> <br /> print($imageName);<br /> /* You can write code for save the image name&nbsp; */<br />&nbsp;&nbsp;&nbsp; }<br /><br /> &nbsp; &nbsp;// For call blade file upload image<br /> &nbsp;&nbsp; public function index(){<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return view('blog');<br />&nbsp;&nbsp;&nbsp; }<br />}<br /><br /></code></pre> <ol start="4"> <li><strong>Now create Route <br /></strong>We can create route for call blade file form and save image to folder follow then give code.</li> </ol> <pre><code> &lt;?php<br />use Illuminate\Support\Facades\Route;<br />use App\Http\Controllers\BlogsController;<br /><br /># call blade file<br />Route::get('blogs', [BlogsController::class, 'index']);<br /><br /># save image to folder<br />Route::post('saveImageTrait',[BlogsController::class, 'saveImageTrait']);</code></pre> <p><br /><br />Now you can see image in <code>"public/image"</code> folder</p>
Read More
Laravel Eloquent display query log in php
Laravel

Laravel Eloquent display query log in php

<p>In this article we will learn about log query in Laravel. &nbsp;It helps us to view the query of laravel application. Sometime we want &nbsp;to display last executed query in laravel application for debug.</p> <p>While working with project then sometime we need to display some log query &nbsp;so that we need to check the query is correct or not . it reduces our time while debugging the code.</p> <p>Lets see the following example of eloquent query in laravel.</p> <ol class="listc"> <li><strong>toSql()</strong></li> <li><strong>DB::enableQueryLog()</strong></li> <li><strong>DB::getQueryLog()</strong></li> </ol> <ol> <li> <h2 class="ht2"><strong>toSql() : </strong></h2> </li> </ol> <p>We will see the example of <strong>toSql() </strong>query . while we working with database query then we need to see the query that is correct or not that why we should use <strong>toSql().</strong></p> <p><strong>Example 1 ( </strong><strong>Controller Code )</strong></p> <pre><code>$query = User::select("*")-&gt;toSql();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dd($query);</code></pre> <p><strong>Output</strong></p> <pre>select * from `users`</pre> <ol start="2"> <li> <h2 class="ht2"><strong>DB::enableQueryLog()</strong></h2> </li> </ol> <p>While working with DB query builder the we should use this db enable query. we have to use this package <code>"use Illuminate\Support\Facades\DB"</code></p> <p><strong>Example 2. (controller Code)</strong></p> <pre><code>use Illuminate\Support\Facades\DB;&rdquo;&nbsp; <br />...<br />...<br />public function show()<span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">{<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; DB::enableQueryLog();<br /></span>&nbsp; &nbsp; &nbsp; $arr_user = DB::table('users')-&gt;select('name', 'email as user_email')-&gt;get();<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp;</span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">// same will work for Eloquent<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp;// $user = User::find(1);<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp;dd(DB::getQueryLog());<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">}</span></code></pre> <p><strong>Output</strong></p> <pre>array:1 [▼ // app/Http/Controllers/Api/ContactController.php:28<br />&nbsp; 0 =&gt; array:3 [▼<br />"query" =&gt; "select `name`, `email` as `user_email` from `users`"<br />&nbsp; &nbsp; "bindings" =&gt; []<br />&nbsp; &nbsp; "time" =&gt; 11.0<br />&nbsp; &nbsp; ]<br />]<strong>&nbsp;</strong></pre> <p><strong>Example 2 ( Controller code )</strong></p> <pre><code>DB::enableQueryLog();<br />$users = User::<strong>select</strong>("*")-&gt;<strong>get</strong>();<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">$quries = DB::getQueryLog();<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">dd($quries);</span></code></pre> <p>Output</p> <pre>array:1 [▼<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp;0 =&gt; array:3 [▼<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp;"query" =&gt; "select * from `users`"<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp;"bindings" =&gt; [] <br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp;"time" =&gt; 4.25<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; ]<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">]</span></pre> <ol start="3"> <li> <h2 class="ht2"><strong>DB::getQueryLog()</strong></h2> </li> </ol> <p>This is the another example of query builder in laravel in which we can use &ldquo;<strong>DB::getQueryLog()&rdquo; to get query. </strong>It will execute in short time in compression toDB::enableQueryLog();</p> <pre><code> &nbsp; &nbsp;DB::enableQueryLog();<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; $users = User::</span><strong style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">select</strong><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">("*")-&gt;</span><strong style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">get</strong><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">();<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; $query = DB::getQueryLog();<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp;$query =</span><strong style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">end</strong><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">($query);<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp;dd($query);</span></code></pre> <p><strong>Output&nbsp;</strong></p> <pre>array:3 [▼<br />&nbsp; &nbsp;"query" =&gt; "select * from `users`"<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; "bindings" =&gt; []<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; "time" =&gt; 2.07<br /></span>&nbsp; &nbsp;]<strong>&nbsp;</strong></pre> <p>Thank you reading this article , Hope it will helpful to you ..!</p>
Read More
How to add new column to existing table without losing data in Laravel
Laravel

How to add new column to existing table without losing data in Laravel

<p>&nbsp; In Laravel we will learn how to add new column to existing table without losing data by using migration.<br />&nbsp; Lets us see an example , we are going to create a migration for blogs.</p> <ol> <li> <p><strong>If you don&rsquo;t know how to create migration then you can see below command otherwise leave it, and move to second point.</strong></p> </li> </ol> <p><strong>&nbsp; Syntax</strong></p> <pre><code> php artisan make:migration create_tablename_table</code></pre> <p><strong>&nbsp;</strong><strong>Example<br /></strong>&nbsp;We will follow the syntax and create migration for blog, after created migration you can see the table. In this table there are two function<strong><code>up()</code> &nbsp;</strong>for run the migration table and <code><strong>down()</strong></code> for reverse migration<strong>. </strong>Now run the below command.</p> <pre><code>&nbsp; &nbsp; Php artisan make:migration create_blogs_table</code></pre> <p>After migration you can add table field name, we are adding one field that is <code>&ldquo;title&rdquo;.</code></p> <pre><code>/** Run the migrations */<br />public function up(): void<br />{<br /> Schema::create('blogs', function (Blueprint $table) { <br /> $table-&gt;id();<br /> $table-&gt;string('title'); <br /> $table-&gt;timestamps();<br /> });<br />}<br /><br />/** Reverse the migrations. */<br />public function down(): void<br />{<br /> Schema::dropIfExists('blogs');<br />}</code></pre> <p>Now run command <code><strong>php artisan migrate</strong></code> and see your table in MySQL database.</p> <ol start="2"> <li> <p><strong>Now we want to add new column &ldquo;slug&rdquo; in blogs existing table without losing data.</strong></p> </li> </ol> <p>So we have to create another migration for add new column , you can put any name as per your choice so we are creating migrate with <code>&ldquo;<strong>alter_blog_table&rdquo; </strong></code>name.</p> <pre><code><strong>php artisan make:migration create_alter_blogs_table</strong></code></pre> <p>now you can see your migrated schema blow code in this, we have to add new field &ldquo;slug&rdquo; in both <strong><code>up()</code> </strong>and <code><strong>down() </strong></code>function and run &nbsp;artisan</p> <pre><code>&nbsp; &nbsp;public function up(): void&nbsp;<br />&nbsp; &nbsp; {<br /> /** here you have add schema with previous table name, in previous table blogs is the table name. */<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> &nbsp; &nbsp; &nbsp;Schema::table('blogs', function (Blueprint $table) {<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $table-&gt;string('slug'); // add new column HERE<br /></span> &nbsp; &nbsp; });<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"> &nbsp; }</span><br /><br /> &nbsp;&nbsp; /** Reverse the migrations. */<br />&nbsp;&nbsp;&nbsp; public function down(): void<br />&nbsp; &nbsp; &nbsp;{<br /><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Schema::table('blogs', function (Blueprint $table) {<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$table-&gt;dropColumn('slug');&nbsp; // Here you have to add field<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br /></span><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&nbsp; &nbsp; &nbsp;}</span></code></pre> <p>Now you can see again blogs table in your database, new field added successfully without losing data in Laravel.</p>
Read More
Upload Image in MySQL database using Node js and React js
React

Upload Image in MySQL database using Node js and React js

<p>In this article, we will learn how to upload an image in React and Node using a library called<strong> Multer.</strong> So we will upload an image and insert a record in the MySQL database by using React frontend. <br />We will also learn how to view an image on the frontend.</p> <p><strong>Frontend</strong><br />We will create a basic client-side React app and then upload an image by creating an API in <strong>Node.js</strong> using Multer.</p> <ol> <li>&nbsp;We will first create a React app boilerplate as follows. <pre><code>npx install create-react-app frontend</code></pre> It will take some time to install. Once the installation is complete create a simple upload form in App.js.</li> <li>Create a simple form to upload an image in app.js <pre><code>return (<br />&lt;div className='App'&gt;<br />&lt;h1&gt;Upload to server&lt;/h1&gt;<br />{image.preview &amp;&amp; &lt;img src={image.preview} width='100' height='100' /&gt;}<br />&lt;hr&gt;&lt;/hr&gt;<br />&lt;form onSubmit={handleSubmit}&gt;<br />&lt;input type="file" name="imageFile" multiple onChange={onSelectFile} accept="image/png , image/jpeg, image/webp"/&gt;<br />&lt;/div&gt;<br />)</code></pre> </li> <li>Now we have to create 2 methods: <ol class="list" style="margin-top: 2px;"> <li style="font-weight: 400;" aria-level="1"><strong>handleSubmit()</strong><span style="font-weight: 400;"> : To submit the image data to the server.</span></li> <li style="font-weight: 400;" aria-level="1"><strong>onSelectFile()</strong><span style="font-weight: 400;"> :&nbsp; It will be triggered when the user selects the image file. It will display the image preview and store the image data in the state.</span>&nbsp;</li> </ol> </li> </ol> <pre><code> &nbsp; const App = () =&gt; {<br /> const [image, setImage] = useState({ preview: '', data: '' })<br /> const onSelectFile = (e) =&gt; {<br /> const img = {<br /> preview: URL.createObjectURL(e.target.files[0]),<br /> data: e.target.files[0],<br /> }<br /> setImage(img)<br /> };<br /> const handleSubmit =async (e) =&gt; {<br /> e.preventDefault();<br /> let formData = new FormData(); <br /> formData.append("imageFile", image.data);<br /> const response = await fetch('http://localhost:5000/imageUpload', {<br /> method: 'POST',<br /> body: formData,<br /> })<br /> if (response) setStatus(response.statusText)<br /> // }<br /> };<br /> }</code></pre> <p><span style="font-weight: 400;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Now go to the terminal and run </span><strong>npm start. </strong><span style="font-weight: 400;">You will see an image upload form.</span></p> <p><strong>Backend</strong><strong><br /></strong><span style="font-weight: 400;">Here we are using </span><strong>Multer</strong><span style="font-weight: 400;"> which will handle <code>"multipart/form-data"</code> sent from our form at frontend.</span></p> <ol start="4"> <li><span style="font-weight: 400;"> Create a file </span><strong>user.model.js</strong><span style="font-weight: 400;"><span style="font-weight: 400;"> and paste the following code into it. This will create tables in the MySQL database when the backend server is started.</span></span> <p><strong>&ndash;user.model.js</strong></p> <pre><code><span style="font-weight: 400;">module.exports = (sequelize, Sequelize) =&gt; {<br />const user = sequelize.define("user", {<br />imageFile: {<br /> &nbsp;type: Sequelize.TEXT('long'),</span> <span style="font-weight: 400;">}});return user;}; &gt;</span></code></pre> </li> <li><span style="font-weight: 400;">Create a file <code>user.routes.js</code> and paste the following code into it. In this code first, we are using </span><strong>Multer</strong><span style="font-weight: 400;"><span style="font-weight: 400;"> to upload the image in the uploads folder. We have imported the <code>user.controller</code> at the top which we will create in the next step. Then we created a route <code>&ldquo;/imageUpload&rdquo;</code> in which we are uploading an image using <code>upload.fields</code>. The field name must be the same as the input element in the frontend. Here the name is&nbsp; <code>&ldquo;</code><code>imageFile&rdquo;.</code><br /></span></span><strong style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;">&ndash;user.router.js</strong> <pre><code><span style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;"><span style="font-weight: 400;">const users = require("./user.Controller");<br />const multer = require("multer");<br />var storage = multer.diskStorage({<br />destination: function (req, file, cb) {<br />cb(null, "./uploads");<br />},<br />filename: function (req, file, cb) {<br />cb(null, file.originalname);<br />},<br />});<br />var upload = multer({ storage: storage });<br />module.exports = (app) =&gt; {<br />router.post("/imageUpload", upload.fields([<br />{ name: "imageFile" }<br />]), users.createUser);<br />}</span></span></code></pre> </li> <li> <p><span style="font-weight: 400;">Now create a file named user.Controller.js. Inside that, we are creating a method to create learning. Inside this function we will access the path of the image from the request which is: </span><code><strong>req?.files?.imageFile[0].path</strong></code></p> <strong>&ndash;user.controller.js</strong> <pre><code><span style="font-weight: 400;">const createLearn = async (req, res) =&gt; {<br />&nbsp; &nbsp;const saveLearnblogs = await LearnBlogs.create({<br />&nbsp; &nbsp; &nbsp;imageFile: req?.files?.imageFile[0].path, <br />&nbsp;})<br />}</span></code></pre> <pre><code>review: URL.createObjectURL(e.target.files[0]),<br /> data: e.target.files[0],<br />}<br />setImage(img)<br />};</code></pre> <pre><code>&lt;div className="formInput"&gt;<br />&lt;label&gt;Document&lt;/label&gt;<br />{/* &lt;img src={file} /&gt; */}<br />{/* &lt;input type="file" multiple={false} onChange={onSelectFile} name="imageFile" /&gt; */}<br />&lt;input type="file" name="imageFile" multiple onChange={onSelectFile} accept="image/png , image/jpeg, image/webp" style={{ display: "none" }} /&gt;<br />{/* &lt;img src={file.preview} /&gt; */}<br />{selectedImages &amp;&amp; selectedImages.map((image) =&gt; {<br />return (<br /> &lt;div key={image} className="image"&gt;<br /> &lt;img src={image} alt="upload" /&gt;<br /> &lt;/div&gt;<br />);<br />})}<br />&lt;/div&gt;</code></pre> <span style="font-weight: 400;">Now create a .env file where you will create a base URL of all the APIs. This URL will be used to fetch the image on the frontend view.</span></li> </ol> <p><strong>&nbsp; &nbsp; &nbsp; .env</strong></p> <pre><code>REACT_APP_BASE_API_URL=http://localhost:4249/</code></pre> <p><span style="font-weight: 400;">Now create a UserProfile.js functional component and paste the following code into it. Here we are passing the image file as props to the component which is then used to fetch the path of the image. </span></p> <p><strong>LearnCard.js</strong></p> <pre><code>function UserProfile({imageFile}) {<br />return (<br />&lt;div&gt;<br />&lt;div className="p-5 m-3"&gt;<br />&lt;img<br />src={`${REACT_APP_BASE_API_URL}${imageFile}`}<br />alt=""<br />width="400px"<br />/&gt;<br />&lt;/div&gt;<br />&lt;/div&gt;<br />);<br />}<br /><br /></code></pre> <p>Now you can call the UserProfile component inside <code>App.js</code> to display the uploaded image.</p> <p>&nbsp;</p>
Read More