Thursday, 18 October 2018

Force git to add dotfiles to repository


how would you add files which are started with dot(hidden files) in git repo?
when i am new at git , I also faced the same problem,  as usual search on internet especially in stackoverflow.com i found the following question with a number of answer
I got the same question on stackoverflow.com.

following is query description

stackoverflow.com query
When I type "git add .", dotfiles in GIT_DIR are added, but not from subdirectories. On the other hand, "git add subdir/.dotfile" won't work.
I tried "git add -f" and putting "!.*" in GIT_DIR/.git/info/exclude. 

Here is the answer
you can simply type below command and hit enter
git add */.*
or
find . -name '.[a-z]*' -exec git add '{}' ';'



Wednesday, 26 September 2018

Laravel 5 Failed opening required bootstrap/../vendor/autoload.php

Question description 

I have recently installed Laravel 5.4 via composer. then after trying to run the project. I am getting the following issue.

If you are simply hitting url you are getting following think as the issue

Warning: require(C:\xampp\htdocs\laravelecommerce\golmarket\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\laravelecommerce\golmarket\bootstrap\autoload.php on line 17

Fatal error: require(): Failed opening required 'C:\xampp\htdocs\laravelecommerce\golmarket\bootstrap/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\laravelecommerce\golmarket\bootstrap\autoload.php on line 17

If you are going through Artisan Console then following this showed up.


Laravel 5.4 Failed opening required bootstrap
Laravel 5 Failed opening required bootstrap
Following is the solution

Answer:
I encountered the same problem. It occurred because the composer was not able to install the dependencies specified in a composer.json file. try running
composer install 
If this does not solve the problem, make sure the following PHP modules are installed php-mbstring PHP-dom
To install this extension run the following in terminal
sudo apt-get install php-mbstring php-dom
once the installation is complete
try running the command in your project root folder
composer install 

Monday, 9 July 2018

Where is the security section of google analytics? “Security Issues” section.

Accessing the securty issues tool is done from within the search properties section that you register. For ease of use you can go to https://www.google.com/webmasters/tools/security-issues which will link you directly to the security issues section of GWT however you will have to have added your website as a property already within GWT and gone through the steps to validate the site.
You don't mention if you have actually registered the site in GWT or not so basically...
  1. Log into Google Webmaster Tools
  2. Register your site using all possible validations including http, https (if used), www, and non www versions of your site
  3. You will be given several methods of validation and you have to pick one. These include adding a meta tag to your site pages, adding a file with a special filename to the site root, adding a DNS entry to your DNS zone file. You need to choose one of these options and follow the instructions to validate the property to your GWT account.
  4. Once validated it may take up to 24 hours for alerts and data to start appearing in your GWT account.
  5. Once you start seeing data in GWT go to https://www.google.com/webmasters/tools/security-issues to see any issues that have been flagged for your site

Sunday, 27 May 2018

Get only domain name from email using PHP.

public function getDomainName($business_email){
$domain_name = substr(strrchr($email, "@"), 1);
echo $domain_name;
}

public function getDomainNameMethodSecond($email){
if( filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
// split on @ and return last value of array (the domain)
$domain = array_pop(explode('@', $email));
// output domain
echo $domain;
}
}

Thursday, 24 May 2018

How can I debug PHP cURL sessions?

Setting CURLOPT_HEADER and CURLOPT_VERBOSE to 'true' are two of the most important ways to debug PHP cURL sessions. 

Detailed Description

PHP’s cURL library is widely used by PHP applications to communicate with the eBay API. However, debugging cURL sessions can be problematic. 

Since many of eBay’s services require proper information in the HTTP headers, verifying correct header transfer is important. This can be done by setting the CURLOPT_HEADER to 'true'. 

Setting CURLOPT_VERBOSE to 'true' will display two-way communication between the PHP application and the server. 
You can also use curl_getinfo to get error messages. 

Sample Code and Session for CURLOPT_VERBOSE

 <?php
 $headers = array (
 'X-EBAY-API-COMPATIBILITY-LEVEL: 507',
 'X-EBAY-API-DEV-NAME: ABCD',
 'X-EBAY-API-APP-NAME: EFGH',
 'X-EBAY-API-CERT-NAME: IJKL',
 'X-EBAY-API-SITEID: 0',
 );
 $session = curl_init();
 curl_setopt($session, CURLOPT_URL, "http://ebay.com/ws/api.dll"); // Oops - wrong URL for API
 curl_setopt($session, CURLOPT_HTTPHEADER, $headers); // Set headers to above array
 curl_setopt($session, CURLOPT_HEADER, true); // Display headers
 curl_setopt($session, CURLOPT_VERBOSE, true); // Display communication with server
 curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Return data instead of display to std out
 curl_exec($session);
 curl_close($session);
?>


C:\>php curlDebug.php * About to connect() to ebay.com port 80
* Trying 66.135.192.87... * connected
* Connected to ebay.com (66.135.192.87) port 80
> GET /ws/api.dll HTTP/1.1
Host: ebay.com
Accept: */*
X-EBAY-API-COMPATIBILITY-LEVEL: 507
X-EBAY-API-DEV-NAME: ABCD
X-EBAY-API-APP-NAME: EFGH
X-EBAY-API-CERT-NAME: IJKL
X-EBAY-API-SITEID: 0
< HTTP/1.1 301 Moved Permanently
< Date: Fri, 01 Jun 2007 06:16:15 GMT
< Server: Microsoft-IIS/6.0
< Location: http://pages.ebay.com/ws/api.dll
* Connection #0 to host ebay.com left intact
* Closing connection #0
C:>


In the above, lines that start with * are cURL informational messages. Lines that start with > are headers sent by cURL. Lines that start with < are headers sent by the server, 

Another way to debug : curl_getinfo


Assume you have the following php file to be executed on a web server. Note the debug statements :

<?php
$ch = curl_init("http://www.ebayXYZ.com/"); // simple get on ebay.com home page - oops wrong host
$fp = fopen("ebay_homepage.html", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);

print "<pre>\n";
print_r(curl_getinfo($ch));  // get error info
echo "\n\ncURL error number:" .curl_errno($ch); // print error info
echo "\n\ncURL error:" . curl_error($ch); 
print "</pre>\n";
curl_close($ch); // close curl session
fclose($fp);
?>


OUTPUT :
Array
(
 [url] => http://www.ebayXYZ.com/
 [http_code] => 0
 [header_size] => 0
 [request_size] => 0
 [filetime] => -1
 [ssl_verify_result] => 0
 [redirect_count] => 0
 [total_time] => 0
 [namelookup_time] => 0
 [connect_time] => 0
 [pretransfer_time] => 0
 [size_upload] => 0
 [size_download] => 0
 [speed_download] => 0
 [speed_upload] => 0
 [download_content_length] => 0
 [upload_content_length] => 0
 [starttransfer_time] => 0
 [redirect_time] => 0
)

cURL error number:6
cURL error:Could not resolve host: www.ebayXYZ.com; Host not found

Monday, 23 April 2018

Simple Laravel CRUD with Resource Controllers

Creating, reading, updating, and deleting resources is used in pretty much every application. Laravel helps make the process easy using resource controllers. Resource Controllers can make life much easier and takes advantage of some cool Laravel routing techniques. Today, we'll go through the steps necessary to get a fully functioning CRUD application using resource controllers.
For this tutorial, we will go through the process of having an admin panel to create, read, update, and delete (CRUD) a resource. Let's use nerds as our example. We will also make use of Eloquent ORM.
This tutorial will walk us through: * Setting up the database and models * Creating the resource controller and its routes * Creating the necessary views * Explaining each method in a resource controller
To get started, we will need the controller, the routes, and the view files.

#Getting our Database Ready

Nerd Migration

(This sounds like a bunch of nerds moving south for the winter). We need to set up a quick database so we can do all of our CRUD functionality. In the command line in the root directory of our Laravel application, let's create a migration.
php artisan migrate:make create_nerds_table --table=nerds --create This will create our nerd migration in app/database/migrations. Open up that file and let's add name, email, and nerd_level fields.
// app/database/migrations/####_##_##_######_create_nerds_table.php

<?php

use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;

class CreateNerdsTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('nerds', function(Blueprint $table)
        {
            $table->increments('id');

            $table->string('name', 255);
            $table->string('email', 255);
            $table->integer('nerd_level');

            $table->timestamps();
        });
    }

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

}
Now from the command line again, let's run this migration. Make sure your database settings are good in app/config/database.php and then run:
php artisan migrate Our database now has a nerds table to house all of the nerds we CRUD (create, read, update, and delete). Read more about migrations at the Laravel docs.

#Eloquent Model for the Nerds

Now that we have our database, let's create a simple Eloquent model so that we can access the nerds in our database easily. You can read about Eloquent ORMand see how you can use it in your own applications.
In the app/models folder, let's create a Nerd.php model.
// app/models/Nerd.php

<?php

    class Nerd extends Eloquent
    {

    }
That's it! Eloquent can handle the rest. By default, this model will link to our nerdstable and and we can access it later in our controllers.

#Creating the Controller

From the official Laravel docs, on resource controllers, you can generate a resource controller using the artisan tool.
Let's go ahead and do that. This is the easy part. From the command line in the root directory of your Laravel project, type:
php artisan controller:make NerdController This will create our resource controller with all the methods we need.
// app/controllers/NerdController.php

<?php

class NerdController extends BaseController {

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store()
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function update($id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        //
    }

}

#Setting Up the Routes

Now that we have generated our controller, let's make sure our application has the routes necessary to use it. This is the other easy part (they actually might all be easy parts). In your routes.php file, add this line:
// app/routes.php

<?php

    Route::resource('nerds', 'NerdController');
This will automatically assign many actions to that resource controller. Now if you, go to your browser and view your application at example.com/nerds, it will correspond to the proper method in your NerdController.

Actions Handled By the Controller

HTTP VerbPath (URL)Action (Method)Route Name
GET/nerdsindexnerds.index
GET/nerds/createcreatenerds.create
POST/nerdsstorenerds.store
GET/nerds/{id}shownerds.show
GET/nerds/{id}/editeditnerds.edit
PUT/PATCH/nerds/{id}updatenerds.update
DELETE/nerds/{id}destroynerds.destroy
Tip: From the command line, you can run php artisan routes to see all the routes associated with your application.

#The Views

Since only four of our routes are GET routes, we only need four views. In our app/views folder, let's make those views now.
  • app
    • views
      • nerds
        • index.blade.php
        • create.blade.php
        • show.blade.php
        • edit.blade.php

#Making It All Work Together

Now we have our migrations, database, and models, our controller and routes, and our views. Let's make all these things work together to build our application. We are going to go through the methods created in the resource controller one by one and make it all work.

Showing All Resources nerds.index

DescriptionURLController FunctionView File
Default page for showing all the nerds.GET example.com/nerdsindex()app/views/nerds/index.blade.php

Controller Function index()

In this function, we will get all the nerds and pass them to the view.
// app/controllers/NerdController.php

<?php

...

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        // get all the nerds
        $nerds = Nerd::all();

        // load the view and pass the nerds
        return View::make('nerds.index')
            ->with('nerds', $nerds);
    }

...


The View app/views/nerds/index.blade.php

Now let's create our view to loop over the nerds and display them in a table. We like using Twitter Bootstrap for our sites, so the table will use those classes.
<!-- app/views/nerds/index.blade.php -->

<!DOCTYPE html>
<html>
<head>
    <title>Look! I'm CRUDding</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">

<nav class="navbar navbar-inverse">
    <div class="navbar-header">
        <a class="navbar-brand" href="{{ URL::to('nerds') }}">Nerd Alert</a>
    </div>
    <ul class="nav navbar-nav">
        <li><a href="{{ URL::to('nerds') }}">View All Nerds</a></li>
        <li><a href="{{ URL::to('nerds/create') }}">Create a Nerd</a>
    </ul>
</nav>

<h1>All the Nerds</h1>

<!-- will be used to show any messages -->
@if (Session::has('message'))
    <div class="alert alert-info">{{ Session::get('message') }}</div>
@endif

<table class="table table-striped table-bordered">
    <thead>
        <tr>
            <td>ID</td>
            <td>Name</td>
            <td>Email</td>
            <td>Nerd Level</td>
            <td>Actions</td>
        </tr>
    </thead>
    <tbody>
    @foreach($nerds as $key => $value)
        <tr>
            <td>{{ $value->id }}</td>
            <td>{{ $value->name }}</td>
            <td>{{ $value->email }}</td>
            <td>{{ $value->nerd_level }}</td>

            <!-- we will also add show, edit, and delete buttons -->
            <td>

                <!-- delete the nerd (uses the destroy method DESTROY /nerds/{id} -->
                <!-- we will add this later since its a little more complicated than the other two buttons -->

                <!-- show the nerd (uses the show method found at GET /nerds/{id} -->
                <a class="btn btn-small btn-success" href="{{ URL::to('nerds/' . $value->id) }}">Show this Nerd</a>

                <!-- edit this nerd (uses the edit method found at GET /nerds/{id}/edit -->
                <a class="btn btn-small btn-info" href="{{ URL::to('nerds/' . $value->id . '/edit') }}">Edit this Nerd</a>

            </td>
        </tr>
    @endforeach
    </tbody>
</table>

</div>
</body>
</html>
We can now show all of our nerds on a page. There won't be any that show up currently since we haven't created any or seeded our database with nerds. Let's move on to the form to create a nerd.
index-blade

Creating a New Resource nerds.create

DescriptionURLController FunctionView File
Show the form to create a new nerd.GET example.com/nerds/createcreate()app/views/nerds/create.blade.php

Controller Function create()

In this function, we will show the form for creating a new nerd. This form will be processed by the store() method.
// app/controllers/NerdController.php

<?php

...

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        // load the create form (app/views/nerds/create.blade.php)
        return View::make('nerds.create');
    }

...

The View app/views/nerds/create.blade.php

<!-- app/views/nerds/create.blade.php -->

<!DOCTYPE html>
<html>
<head>
    <title>Look! I'm CRUDding</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">

<nav class="navbar navbar-inverse">
    <div class="navbar-header">
        <a class="navbar-brand" href="{{ URL::to('nerds') }}">Nerd Alert</a>
    </div>
    <ul class="nav navbar-nav">
        <li><a href="{{ URL::to('nerds') }}">View All Nerds</a></li>
        <li><a href="{{ URL::to('nerds/create') }}">Create a Nerd</a>
    </ul>
</nav>

<h1>Create a Nerd</h1>

<!-- if there are creation errors, they will show here -->
{{ HTML::ul($errors->all()) }}

{{ Form::open(array('url' => 'nerds')) }}

    <div class="form-group">
        {{ Form::label('name', 'Name') }}
        {{ Form::text('name', Input::old('name'), array('class' => 'form-control')) }}
    </div>

    <div class="form-group">
        {{ Form::label('email', 'Email') }}
        {{ Form::email('email', Input::old('email'), array('class' => 'form-control')) }}
    </div>

    <div class="form-group">
        {{ Form::label('nerd_level', 'Nerd Level') }}
        {{ Form::select('nerd_level', array('0' => 'Select a Level', '1' => 'Sees Sunlight', '2' => 'Foosball Fanatic', '3' => 'Basement Dweller'), Input::old('nerd_level'), array('class' => 'form-control')) }}
    </div>

    {{ Form::submit('Create the Nerd!', array('class' => 'btn btn-primary')) }}

{{ Form::close() }}

</div>
</body>
</html>
We will add the errors section above to show validation errors when we try to store() the resource.
Tip: When using {{ Form::open() }}, Laravel will automatically create a hidden input field with a token to protect from cross-site request forgeries. Read more at the Laravel docs.
We now have the form, but we need to have it do something when it the submit button gets pressed. We set this form's action to be a POST to example.com/nerds. The resource controller will handle this and automatically route the request to the store() method. Let's handle that now.

Storing a Resource store()

DescriptionURLController FunctionView File
Process the create form submit and save the nerd to the database.POST example.com/nerdsstore()NONE
As you can see from the form action and the URL, you don't have to pass anything extra into the URL to store a nerd. Since this form is sent using the POST method, the form inputs will be the data used to store the resource.
To process the form, we'll want to validate the inputssend back error messages if they existauthenticate against the database, and store the resource if all is good. Let's dive in.

Controller Function store()

// app/controllers/NerdController.php

<?php

...

    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store()
    {
        // validate
        // read more on validation at http://laravel.com/docs/validation
        $rules = array(
            'name'       => 'required',
            'email'      => 'required|email',
            'nerd_level' => 'required|numeric'
        );
        $validator = Validator::make(Input::all(), $rules);

        // process the login
        if ($validator->fails()) {
            return Redirect::to('nerds/create')
                ->withErrors($validator)
                ->withInput(Input::except('password'));
        } else {
            // store
            $nerd = new Nerd;
            $nerd->name       = Input::get('name');
            $nerd->email      = Input::get('email');
            $nerd->nerd_level = Input::get('nerd_level');
            $nerd->save();

            // redirect
            Session::flash('message', 'Successfully created nerd!');
            return Redirect::to('nerds');
        }
    }

...
If there are errors processing the form, we will redirect them back to the create form with those errors. We will add them in so the user can understand what went wrong. They will show up in the errors section we setup earlier.
Now you should be able to create a nerd and have them show up on the main page! Navigate to example.com/nerds and there they are. All that's left is showing a single nerdupdating, and deleting.
created

Showing a Resource show()

DescriptionURLController FunctionView File
Show one of the nerds.GET example.com/nerds/{id}show()app/views/nerds/show.blade.php

Controller Function show()

// app/controllers/NerdController.php

<?php

...

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        // get the nerd
        $nerd = Nerd::find($id);

        // show the view and pass the nerd to it
        return View::make('nerds.show')
            ->with('nerd', $nerd);
    }

...

The View app/views/nerds/show.blade.php

<!-- app/views/nerds/show.blade.php -->

<!DOCTYPE html>
<html>
<head>
    <title>Look! I'm CRUDding</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">

<nav class="navbar navbar-inverse">
    <div class="navbar-header">
        <a class="navbar-brand" href="{{ URL::to('nerds') }}">Nerd Alert</a>
    </div>
    <ul class="nav navbar-nav">
        <li><a href="{{ URL::to('nerds') }}">View All Nerds</a></li>
        <li><a href="{{ URL::to('nerds/create') }}">Create a Nerd</a>
    </ul>
</nav>

<h1>Showing {{ $nerd->name }}</h1>

    <div class="jumbotron text-center">
        <h2>{{ $nerd->name }}</h2>
        <p>
            <strong>Email:</strong> {{ $nerd->email }}<br>
            <strong>Level:</strong> {{ $nerd->nerd_level }}
        </p>
    </div>

</div>
</body>
</html>
show

Editing a Resource edit()

DescriptionURLController FunctionView File
Pull a nerd from the database and allow editing.GET example.com/nerds/{id}/editedit()app/views/nerds/edit.blade.php
To edit a nerd, we need to pull them from the database, show the creation form, but populate it with the selected nerd's info. To make life easier, we will use form model binding. This allows us to pull info from a model and bind it to the input fields in a form. Just makes it easier to populate our edit form and you can imagine that when these forms start getting rather large this will make life much easier.

Controller Function edit()

// app/controllers/NerdController.php

<?php

...

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        // get the nerd
        $nerd = Nerd::find($id);

        // show the edit form and pass the nerd
        return View::make('nerds.edit')
            ->with('nerd', $nerd);
    }

...

The View app/views/nerds/edit.blade.php

<!-- app/views/nerds/edit.blade.php -->

<!DOCTYPE html>
<html>
<head>
    <title>Look! I'm CRUDding</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">

<nav class="navbar navbar-inverse">
    <div class="navbar-header">
        <a class="navbar-brand" href="{{ URL::to('nerds') }}">Nerd Alert</a>
    </div>
    <ul class="nav navbar-nav">
        <li><a href="{{ URL::to('nerds') }}">View All Nerds</a></li>
        <li><a href="{{ URL::to('nerds/create') }}">Create a Nerd</a>
    </ul>
</nav>

<h1>Edit {{ $nerd->name }}</h1>

<!-- if there are creation errors, they will show here -->
{{ HTML::ul($errors->all()) }}

{{ Form::model($nerd, array('route' => array('nerds.update', $nerd->id), 'method' => 'PUT')) }}

    <div class="form-group">
        {{ Form::label('name', 'Name') }}
        {{ Form::text('name', null, array('class' => 'form-control')) }}
    </div>

    <div class="form-group">
        {{ Form::label('email', 'Email') }}
        {{ Form::email('email', null, array('class' => 'form-control')) }}
    </div>

    <div class="form-group">
        {{ Form::label('nerd_level', 'Nerd Level') }}
        {{ Form::select('nerd_level', array('0' => 'Select a Level', '1' => 'Sees Sunlight', '2' => 'Foosball Fanatic', '3' => 'Basement Dweller'), null, array('class' => 'form-control')) }}
    </div>

    {{ Form::submit('Edit the Nerd!', array('class' => 'btn btn-primary')) }}

{{ Form::close() }}

</div>
</body>
</html>
Note that we have to pass a method of PUT so that Laravel knows how to route to the controller correctly.

Updating a Resource update()

DescriptionURLController FunctionView File
Process the create form submit and save the nerd to the database.PUT example.com/nerdsupdate()NONE
This controller method will process the edit form. It is very similar to store(). We will validateupdate, and redirect.

Controller Function update()

// app/controllers/NerdController.php

<?php

...

    /**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function update($id)
    {
        // validate
        // read more on validation at http://laravel.com/docs/validation
        $rules = array(
            'name'       => 'required',
            'email'      => 'required|email',
            'nerd_level' => 'required|numeric'
        );
        $validator = Validator::make(Input::all(), $rules);

        // process the login
        if ($validator->fails()) {
            return Redirect::to('nerds/' . $id . '/edit')
                ->withErrors($validator)
                ->withInput(Input::except('password'));
        } else {
            // store
            $nerd = Nerd::find($id);
            $nerd->name       = Input::get('name');
            $nerd->email      = Input::get('email');
            $nerd->nerd_level = Input::get('nerd_level');
            $nerd->save();

            // redirect
            Session::flash('message', 'Successfully updated nerd!');
            return Redirect::to('nerds');
        }
    }

...

Deleting a Resource destroy()

DescriptionURLController FunctionView File
Process the create form submit and save the nerd to the database.DELETE example.com/nerds/{id}destroy()NONE
The workflow for this is that a user would go to view all the nerds, see a delete button, click it to delete. Since we never created a delete button in our app/views/nerds/index.blade.php, we will create that now. We will also add a notification section to show a success message.
We have to send the request to our application using the DELETE HTTP verb, so we will create a form to do that since a button won't do.
Alert: The DELETE HTTP verb is used when accessing the nerds.destroy route. Since you can't just create a button or form with the method DELETE, we will have to spoof it by creating a hidden input field in our delete form.

The View app/views/nerds/index.blade.php

<!-- app/views/nerds/index.blade.php -->

...

    @foreach($nerds as $key => $value)
        <tr>
            <td>{{ $value->id }}</td>
            <td>{{ $value->name }}</td>
            <td>{{ $value->email }}</td>
            <td>{{ $value->nerd_level }}</td>

            <!-- we will also add show, edit, and delete buttons -->
            <td>

                <!-- delete the nerd (uses the destroy method DESTROY /nerds/{id} -->
                <!-- we will add this later since its a little more complicated than the other two buttons -->
                {{ Form::open(array('url' => 'nerds/' . $value->id, 'class' => 'pull-right')) }}
                    {{ Form::hidden('_method', 'DELETE') }}
                    {{ Form::submit('Delete this Nerd', array('class' => 'btn btn-warning')) }}
                {{ Form::close() }}

                <!-- show the nerd (uses the show method found at GET /nerds/{id} -->
                <a class="btn btn-small btn-success" href="{{ URL::to('nerds/' . $value->id) }}">Show this Nerd</a>

                <!-- edit this nerd (uses the edit method found at GET /nerds/{id}/edit -->
                <a class="btn btn-small btn-info" href="{{ URL::to('nerds/' . $value->id . '/edit') }}">Edit this Nerd</a>

            </td>
        </tr>
    @endforeach

...
Now when we click that form submit button, Laravel will use the nerds.destroy route and we can process that in our controller.

Controller Function destroy()

// app/controllers/NerdController.php

<?php

...

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        // delete
        $nerd = Nerd::find($id);
        $nerd->delete();

        // redirect
        Session::flash('message', 'Successfully deleted the nerd!');
        return Redirect::to('nerds');
    }

...

Force git to add dotfiles to repository

how would you add files which are started with dot(hidden files) in git repo? when i am new at git , I also faced the same problem,  as...