ERROR: Unable to store image in particular directory

today when i storing image then one error appears

Solution:I have given permission to that directory folder public folder after that my issue is resolved

chmod -R 777 ./public

refrence:https://stackoverflow.com/questions/34836602/laravel-uploading-file-unable-to-write-in-directory

Tagged : /

DBMS Interview Q&A Part- 1

Q. What is Data ?

A. Data refers to raw facts and figures that can be recorded.

Q. What is Database ?

A. Database refers to the collection of interrelated and coherent data.

Q. Explain DBMS ?

A. DBMS stands for Database Management System. It is a software
package designed to define, manipulate, retrieve and manage data in
database.

Q. Why DBMS ?

A. To make information easy to access and protected, we use database
management systems. DBMS is important because it manages the data
efficiently and allow users to perform multiple tasks on it with the ease.

Q. What is a database system?

A. The collection of database and DBMS software together is known as a
database system.

Q. What do you mean by Data Modelling ?

A. Data Modelling is the set of conceptual tools for describing data
relationship, data semantics, and consistency constraints. Different data
models are : Network model, Relational model, Object Oriented model, ER
model, and more.

Q. Explain RDBMS ?

A. RDBMS stands for Relational Database Management System. It
arranges information into allied rows and columns. RDMS is an information
management system which is oriented on a data model. RDBMS Example
systems are SQL Server, Oracle, MySQL, MariaDB and SQLite.

Q. Explain Abstraction of Data, with reference to DBMS ?

A. Data Abstraction refers to the process of hiding background details from
user.

Q. Explain the 3 L’s of Data Abstraction ?

A. It refers to three levels of abstraction. They are :

  1. Physical Level : It is lowest level of abstraction. It describes how data is
    actually stored. It also describes complex data structure in detail.
  2. Logical Level : It describes what data get stored in the database and what are the relationships among them.
  3. View Level : It is the highest level of data abstraction that only describes a part of database indirectly
Q. What is Database Schema ?

A. Schema refers to the overall structure of database without data values.

Q. What do you mean by transparent DBMS?

A. The transparent DBMS is a type of DBMS which keeps its physical
structure hidden from users.

Q. Explain ER Model ?

A. This model is based on the perception of real world that consists of
collection of basic entities and relationship among these objects. It is the
graphical representation of the database.

Q. What do you understand by Data Independency ?

A. It refers to the capacity to change data at one level without affecting next
higher level is called Data Independence. It is of two types : Physical DI,
Logical DI.
Physical DI : It indicates that physical storage of device could be changed
without affecting conceptual view.
Logical DI : It indicates that conceptual schema can be changed without
affecting existing external schema.

Q. What is a Database Language ?

A. Database Language is a medium by which we can interact with the
database system through some set of commands. These commands are
structured.

Q. What is a Tuple ?

A. A single row of a table, which contains a single record for that relation is
called a tuple.

Q. Explain degree and Cardinality ?

A. Degree is the total number of attributes in a relation or table and
cardinality is total number of tuples/rows in a relation/table.

Q. What is a relation in DBMS ?

A. A database relation refers to an individual table in a relational database.
A table is a relation because it stores the relation between data in its
column-row format.

Q. What is the role of DML Compiler ?

A. It translates DML statements in a query language into low-level
instructions that the query evaluation engine can easily understand.

Q. Explain me the role of using clause for queries ?

A. Clause enables you to specify conditions that filters the results as per
the requirement. Some of the most commonly used clauses are : having,
where etc.

Q. What is a Query ?

A. Query is a statement that is used for the extraction of data from
database.
For example – select * from table1 is a query

Q. What is Subquery ?

A. Subquery is a query within query.
For example – select * from students where marks = ( select max(marks)
from students);

Q. Explain BCNF ?

A. BCNF is Boyce-Codd Normal Form. It is considered to be the advanced
version of 3 NF. Hence it is also refered to as 3.5 NF. A relation is said to
be in BCNF, if it satisfies following rules :

  1. It is in 3NF.
  2. For every functional dependency P->Q, P should be the super key of the table.
Q. What are Stored Procedures ?

A. Stored Procedure refers to the set of Structured Query Language(SQL)
statements stored in a relational database management system as a group.
It can further be reused and shared by multiple programs. It provides a
layer of security between a user interface and database.

Tagged : / /

Crud Operation in Laravel

In this tutorial I’m going to learn how to create Crud operation in Laravel. Please follow some easy steps define below.

Step 1 — Installing Laravel 8

Open terminal in xampp/htdocs and paste below code

composer create-project laravel/laravel example-app

Step 2 — Setting up a MySQL Database

👇 Step 2 — Database Configuration

Setup database with your installed laravel 8 project . lets go to .env folder and put database name and connect to database.

👇 Next go to .env folder and put database name

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=crud-operation
DB_USERNAME=root
DB_PASSWORD=

Next run this command

php artisan migrate

Step 3 — Creating a Database Migration

Run this command

php artisan make:migration create_products_table --create=products

Copy below code and simply paste in your products table

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('detail');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products');
}
}

Step 4 — Adding a Resource Route

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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::resource('products','ProductController');

Step 5 — Adding a Laravel 8 Controller and Model

run this command

php artisan make:controller ProductController --resource --model=Product

Go to your product controller and paste below code

<?php

namespace App\Http\Controllers;

use App\Product;
use Illuminate\Http\Request;

class ProductController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$products = Product::latest()->paginate(5);

return view('products.index',compact('products'))
->with('i', (request()->input('page', 1) - 1) * 5);
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('products.create');
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$request->validate([
'name' => 'required',
'detail' => 'required',
]);

Product::create($request->all());

return redirect()->route('products.index')
->with('success','Product created successfully.');
}

/**
* Display the specified resource.
*
* @param \App\Product $product
* @return \Illuminate\Http\Response
*/
public function show(Product $product)
{
return view('products.show',compact('product'));
}

/**
* Show the form for editing the specified resource.
*
* @param \App\Product $product
* @return \Illuminate\Http\Response
*/
public function edit(Product $product)
{
return view('products.edit',compact('product'));
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Product $product
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Product $product)
{
$request->validate([
'name' => 'required',
'detail' => 'required',
]);

$product->update($request->all());

return redirect()->route('products.index')
->with('success','Product updated successfully');
}

/**
* Remove the specified resource from storage.
*
* @param \App\Product $product
* @return \Illuminate\Http\Response
*/
public function destroy(Product $product)
{
$product->delete();

return redirect()->route('products.index')
->with('success','Product deleted successfully');
}
}

Lets Go to Model and paste below code

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
protected $fillable = [
'name', 'detail'
];
}

Step 6 — Adding your Larevl 8 Blade Views

Go to Resource folder and create view file

1) layout.blade.php

2) index.blade.php

3) create.blade.php

4) edit.blade.php

5) show.blade.php

resources/views/products/layout.blade.php

<!DOCTYPE html>
<html>
<head>
<title>Laravel 6 CRUD Application - Laravel Amit</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.css" rel="stylesheet">
</head>
<body>

<div class="container">
@yield('content')
</div>

</body>
</html>

resources/views/products/index.blade.php

@extends('products.layout')

@section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2>Laravel 6 CRUD Example from By Laravel Amit</h2>
</div>
<div class="pull-right">
<a class="btn btn-success" href="{{ route('products.create') }}"> Create New Product</a>
</div>
</div>
</div>

@if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
@endif

<table class="table table-bordered">
<tr>
<th>No</th>
<th>Name</th>
<th>Details</th>
<th width="280px">Action</th>
</tr>
@foreach ($products as $product)
<tr>
<td>{{ ++$i }}</td>
<td>{{ $product->name }}</td>
<td>{{ $product->detail }}</td>
<td>
<form action="{{ route('products.destroy',$product->id) }}" method="POST">

<a class="btn btn-info" href="{{ route('products.show',$product->id) }}">Show</a>

<a class="btn btn-primary" href="{{ route('products.edit',$product->id) }}">Edit</a>

@csrf
@method('DELETE')

<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
@endforeach
</table>

{!! $products->links() !!}

@endsection

👇 resources/views/products/create.blade.php

@extends('products.layout')

@section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2>Add New Product</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{{ route('products.index') }}"> Back</a>
</div>
</div>
</div>

@if ($errors->any())
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

<form action="{{ route('products.store') }}" method="POST">
@csrf

<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Name:</strong>
<input type="text" name="name" class="form-control" placeholder="Name">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Detail:</strong>
<textarea class="form-control" style="height:150px" name="detail" placeholder="Detail"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>

</form>
@endsection

resources/views/products/edit.blade.php

@extends('products.layout')

@section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2>Edit Product</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{{ route('products.index') }}"> Back</a>
</div>
</div>
</div>

@if ($errors->any())
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

<form action="{{ route('products.update',$product->id) }}" method="POST">
@csrf
@method('PUT')

<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Name:</strong>
<input type="text" name="name" value="{{ $product->name }}" class="form-control" placeholder="Name">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Detail:</strong>
<textarea class="form-control" style="height:150px" name="detail" placeholder="Detail">{{ $product->detail }}</textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>

</form>
@endsection

resources/views/products/show.blade.php

@extends('products.layout')
@section('content')
<div class="row">
<div class="col-lg-12 margin-tb">
<div class="pull-left">
<h2> Show Product</h2>
</div>
<div class="pull-right">
<a class="btn btn-primary" href="{{ route('products.index') }}"> Back</a>
</div>
</div>
</div>

<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Name:</strong>
{{ $product->name }}
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Details:</strong>
{{ $product->detail }}
</div>
</div>
</div>
@endsection

Lets run php artisan serve

http://localhost:8000/products

I hope its helpful for you.

Tagged : / / /