<repo_name>manishyadav436/MyFirstRepo<file_sep>/vendor/ernysans/laraworld/tests/TimeZonesTest.php
<?php

use ErnySans\Laraworld\Models\TimeZones;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Schema;

class TimeZonesTest extends AppTestCase
{

	/**
	 * Check if JSON file exist
	 */
	public function testItFetchesJsonFile()
	{
		$collection = TimeZones::allJSON();
		$this->assertNotNull($collection);
	}

	/**
	 * Publish migrations for testing
	 */
	public function testPublishedMigrations()
	{
		$source = __DIR__ . '/../src/Database/migrations/0000_00_00_000000_create_time_zones_table.php';
		$destination = database_path('migrations/0000_00_00_000000_create_time_zones_table.php');
		File::copy($source, $destination);
		$success = File::exists($destination);
		$this->assertTrue($success);
	}

	/**
	 * Publish seeds for testing
	 */
	public function testPublishedSeeds()
	{
		$source = __DIR__ . '/../src/Database/seeds/TimeZonesTableSeeder.php';
		$destination = database_path('seeds/TimeZonesTableSeeder.php');
		File::copy($source, $destination);
		$success = File::exists($destination);
		$this->assertTrue($success);
	}

	/**
	 * Run migrations
	 * @depends testPublishedMigrations
	 */
	public function testItHasMigrated()
	{
		Artisan::call('migrate');
		$this->assertTrue(true);
	}

	/**
	 * Check if the table exist
	 * @depends testItHasMigrated
	 */
	public function testItCheckForTable()
	{
		$collection = Schema::hasTable('time_zones');
		$this->assertTrue($collection);
	}

	/**
	 * Seed the table
	 * @depends testPublishedSeeds
	 * @depends testItFetchesJsonFile
	 */
	public function testItHasSeeded()
	{
		Artisan::call('db:seed');
		$this->assertTrue(true);
	}

	/**
	 * Check if the table was seeded
	 * @depends testItHasSeeded
	 */
	public function testItCanSeed()
	{
		$collection = TimeZones::all();
		$this->assertNotNull($collection->count());
	}

	/**
	 * Publish migrations for testing
	 * @depends testItHasMigrated
	 */
	public function testDeleteMigrations()
	{
		$base = database_path('migrations/****_**_**_******_create_time_zones_table.php');
		$source = File::glob($base);
		$route = $source[0];
		File::delete($route);
		$success = File::exists($route);
		$this->assertFalse($success);
	}

	/**
	 * Publish seeds for testing
	 * @depends testItHasSeeded
	 */
	public function testDeleteSeeds()
	{
		$source = database_path('seeds/TimeZonesTableSeeder.php');
		File::delete($source);
		$success = File::exists($source);
		$this->assertFalse($success);
	}

}
<file_sep>/vendor/ernysans/laraworld/src/LaraworldServiceProvider.php
<?php

namespace ErnySans\Laraworld;

use ErnySans\Laraworld\Models\Countries;
use ErnySans\Laraworld\Models\Languages;
use ErnySans\Laraworld\Models\TimeZones;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\File;

class LaraworldServiceProvider extends ServiceProvider
{

    /**
     * Register bindings in the container.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('Countries', function() {
            return new Countries;
        });

        $this->app->bind('Languages', function() {
            return new Languages;
        });

        $this->app->bind('TimeZones', function() {
            return new TimeZones;
        });
    }

    /**
     * Perform post-registration booting of services.
     *
     * @return void
     */
    public function boot()
    {
        // Countries Migration =========================
        $countries_migration = $this->getTimePath('create_countries_table', 'migrations');

        $this->publishes([
            __DIR__.'/Database/migrations/0000_00_00_000000_create_countries_table.php' => database_path($countries_migration)
        ], 'migrate-countries');

        // Countries Seed ==============================
        $this->publishes([
            __DIR__.'/Database/seeds/CountriesTableSeeder.php' => database_path('seeds/CountriesTableSeeder.php')
        ], 'seed-countries');


        // Languages Migration =========================
        $languages_migration = $this->getTimePath('create_languages_table', 'migrations');

        $this->publishes([
            __DIR__.'/Database/migrations/0000_00_00_000000_create_languages_table.php' => database_path($languages_migration)
        ], 'migrate-languages');

        // Languages Seed ==============================
        $this->publishes([
            __DIR__.'/Database/seeds/LanguagesTableSeeder.php' => database_path('seeds/LanguagesTableSeeder.php')
        ], 'seed-languages');


        // Time Zones Migration ========================
        $time_zones_migration = $this->getTimePath('create_time_zones_table', 'migrations');

        $this->publishes([
            __DIR__.'/Database/migrations/0000_00_00_000000_create_time_zones_table.php' => database_path($time_zones_migration)
        ], 'migrate-time-zone');

        // Time Zones Seed =============================
        $this->publishes([
            __DIR__.'/Database/seeds/TimeZonesTableSeeder.php' => database_path('seeds/TimeZonesTableSeeder.php')
        ], 'seed-time-zone');

    }

    /**
     * Get the date prefix for the migration.
     *
     * @return string
     */
    protected function getDatePrefix()
    {

        return date('Y_m_d_His');
    }

	/**
     * If the file exist retrieve the same name
     *
     * @param $name
     * @return null
     */
    private function getMigrationCurrentName($name) {
        $base = database_path('migrations/****_**_**_******_'.$name.'.php');
        $source = File::glob($base);
        if ($source) {
            return basename($source[0], ".php");
        }

        return null;
    }

    /**
     * Get the full path name to the migration.
     *
     * @param  string  $name
     * @param  string  $path
     * @return string
     */
    protected function getTimePath($name, $path)
    {
        if ($this->getMigrationCurrentName($name)) {
            $txt = $this->getMigrationCurrentName($name);
        }
        else {
            $txt = $this->getDatePrefix().'_'.$name;
        }

        return  $path.'/'.$txt.'.php';
    }
    
}<file_sep>/app/Http/Controllers/DataVoiceController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\DataVoice;
use Yajra\Datatables\Datatables;
use Validator;
use Rinvex\Country\Country;

class DataVoiceController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
       $empdata = DataVoice::all();
       return view('emp.index', compact('empdata'));

    }

    public function getUsers(){
        return Datatables::of(DataVoice::query())
            ->addColumn('action', function($row){
                $btn = '<a href="javascript:void(0)" class="edit btn btn-primary btn-sm">View</a>';
                return $btn;
            })
            ->rawColumns(['action'])
            ->make(true);

    }

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

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $request->validate([
            'emp_id'=>'required|numeric',
            'emp_name'=>'required',
            'country_code'=>'required',
            'mobile'=>'required',
            'email'=>'required',
            'dob'=>'required',
            'profile'=>'mimes:jpg,png|required|max:10000'
        ]);

        $data = new DataVoice([
            'emp_id' => $request->get('emp_id'),
            'emp_name' => $request->get('emp_name'),
            'country_code' => $request->get('country_code'),
            'mobile' => $request->get('mobile'),
            'email' => $request->get('email'),
            'dob' => $request->get('dob'),
        ]);

        $image = $request->file('profile');
        $new_name = rand() . '.' . $image->getClientOriginalExtension();
        $image->move(public_path('images'), $new_name);
        $filename = $image;
        $data->profile = $filename;
        $data->save();
        return redirect('/home')->with('success', 'Contact saved!');
    }

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

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $emp = DataVoice::find($id);
        return view('emp.edit', compact('emp'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $request->validate([
            'emp_id'=>'required',
            'emp_name'=>'required',
            'country_code'=>'required',
            'mobile'=>'required',
            'email'=>'required',
            'dob'=>'required',
            'profile'=>'required'
        ]);

        $data = DataVoice::find($id);
        $data->emp_id = $request->get('emp_id');
        $data->emp_name = $request->get('emp_name');
        $data->country_code = $request->get('country_code');
        $data->mobile = $request->get('mobile');
        $data->email = $request->get('email');
        $data->dob = $request->get('dob');
        $data->profile = $request->get('profile');

        $data->save();
        return redirect('/home')->with('success', 'Data Updated!');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $empdata = DataVoice::find($id);
        $empdata->delete();
        return redirect('/home')->with('success', 'Data Deleted !');;
    }
}
<file_sep>/vendor/ernysans/laraworld/src/Database/seeds/LanguagesTableSeeder.php
<?php

use Illuminate\Database\Seeder;
use ErnySans\Laraworld\Models\Languages;

class LanguagesTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return  void
     */
    public function run()
    {
        // Empty the table
        Languages::truncate();

        // Get all from the JSON file
        $JSON_languages = Languages::allJSON();

        foreach ($JSON_languages as $language) {
            Languages::create([
                'alpha3'    => ((isset($language['alpha3'])) ? $language['alpha3'] : null),
                'alpha2'    => ((isset($language['alpha2'])) ? $language['alpha2'] : null),
                'english'   => ((isset($language['english'])) ? $language['english'] : null),
            ]);
        }
    }
}
<file_sep>/vendor/ernysans/laraworld/src/Facades/Languages.php
<?php

namespace ErnySans\Laraworld\Facades;

use Illuminate\Support\Facades\Facade;

class Languages extends Facade
{
    protected static function getFacadeAccessor() {
        return 'Languages';
    }
}<file_sep>/vendor/ernysans/laraworld/src/Models/Languages.php
<?php

namespace ErnySans\Laraworld\Models;

use Illuminate\Database\Eloquent\Model;

class Languages extends Model
{
    
	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'languages';

	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	protected $hidden = [
		'id',
		'created_at',
		'updated_at'
	];

	/**
	 * Protect $dates
	 *
	 * @var array
	 */
	protected $dates = [
		'created_at',
		'updated_at'
	];

	/**
	 * he attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected $fillable = [
		'alpha3',
		'alpha2',
		'english',
	];

	/**
	 * Get all the countries from the JSON file.
	 *
	 * @return array
	 */
	public static function allJSON()
	{
		$route = dirname(dirname(__FILE__)) . '/Database/data/languages.json';

		return json_decode(file_get_contents($route), true);
	}

}
<file_sep>/vendor/ernysans/laraworld/tests/AppTestCase.php
<?php

use ErnySans\Laraworld\LaraworldServiceProvider;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Console\Command;
use Symfony\Component\Console\Output\ConsoleOutputInterface;


class AppTestCase extends Illuminate\Foundation\Testing\TestCase
{

	use WithoutMiddleware, DatabaseMigrations;


	/**
	 * Creates the application.
	 *
	 * @return \Illuminate\Foundation\Application
	 */
	public function createApplication()
	{
		$app = require __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php';
		$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
		return $app;
	}

	/**
	 * Run before every test
	 */
	public function setUp()
	{
		parent::setUp();
	}

	/**
	 * Run after every test
	 */
	public function tearDown()
	{
		//Artisan::call('migrate:reset');
		parent::tearDown();
	}

}<file_sep>/vendor/ernysans/laraworld/README.md
[![Build Status](https://travis-ci.org/ernysans/laraworld.svg?branch=master)](https://travis-ci.org/ernysans/laraworld) [![Latest Stable Version](https://poser.pugx.org/ernysans/laraworld/v/stable?format=flat)](https://packagist.org/packages/ernysans/laraworld) [![Total Downloads](https://poser.pugx.org/ernysans/laraworld/downloads?format=flat)](https://packagist.org/packages/ernysans/laraworld) [![Latest Unstable Version](https://poser.pugx.org/ernysans/laraworld/v/unstable?format=flat)](https://packagist.org/packages/ernysans/laraworld) [![License](https://poser.pugx.org/ernysans/laraworld/license?format=flat)](https://packagist.org/packages/ernysans/laraworld)

# Laraworld
Countries, Languages and Time Zones Package for Laravel and Lumen 5.*

Please check the [Known Issues](https://github.com/ernysans/laraworld/issues) section before reporting a new one.

![ScreenShot](../master/src/img/screenshot.jpg?raw=true)

## Installation
This package can be installed through Composer.

```bash
$ composer require ernysans/laraworld
```

When using Laravel there is a service provider that you can make use of.

```php
// app/config/app.php

'providers' => [
    '...',
    ErnySans\Laraworld\LaraworldServiceProvider::class,
];
```

Configure the aliases to make use of the Facades.

```php
// app/config/app.php

'aliases' => [
    '...',
    'Countries' => ErnySans\Laraworld\Facades\Countries::class,
    'TimeZones' => ErnySans\Laraworld\Facades\TimeZones::class,
    'Languages' => ErnySans\Laraworld\Facades\Languages::class,
];
```

> If you are using Laravel 5.5 it's not required to manually add the service provider and aliases.

Publish Migrations and Seeds.

```bash
$ php artisan vendor:publish --provider="ErnySans\Laraworld\LaraworldServiceProvider"
```

Prepare Seeds.

```php
// database/seeds/DatabaseSeeder.php

class DatabaseSeeder extends Seeder
{

    public function run()
    {
        // Seed the countries
        $this->call(CountriesTableSeeder::class);
    
        // Seed the Time Zones
        $this->call(TimeZonesTableSeeder::class);
    
        // Seed the Languages
        $this->call(LanguagesTableSeeder::class);
    }
}
```

Run Migrations and Seed the tables

```bash
$ php artisan migrate
$ php artisan db:seed
```
## Use
These methods are provided:

### Collection Methods
When using Laravel you can work with the [Collection Available Methods](https://laravel.com/docs/master/collections).

### JSON file (Optional)
Use this methods If you want to get all the data from the JSON file:

* `Countries::allJSON()`: Get all the countries from the JSON file.
* `Languages::allJSON()`: Get all the languages from the JSON file.
* `TimeZones::allJSON()`: Get all the time zones from the JSON file.

## Contributing
Thank you for considering contributing to the Laraworld package!. Remember to run PHPUnit tests before sending a new pull request.

## License
This package is open-sourced licensed under the [MIT license](http://opensource.org/licenses/MIT).
<file_sep>/database/seeds/CountriesTableSeeder.php
<?php

use Illuminate\Database\Seeder;
use ErnySans\Laraworld\Models\Countries;

class CountriesTableSeeder extends Seeder
{

    /**
     * Run the database seeds.
     *
     * @return  void
     */
    public function run()
    {
        // Empty the table
        Countries::truncate();

        // Get all from the JSON file
        $JSON_countries = Countries::allJSON();

        foreach ($JSON_countries as $country) {
            Countries::create([
                'capital'           => ((isset($country['capital'])) ? $country['capital'] : null),
                'citizenship'       => ((isset($country['citizenship'])) ? $country['citizenship'] : null),
                'country_code'      => ((isset($country['country_code'])) ? $country['country_code'] : null),
                'currency'          => ((isset($country['currency'])) ? $country['currency'] : null),
                'currency_code'     => ((isset($country['currency_code'])) ? $country['currency_code'] : null),
                'currency_sub_unit' => ((isset($country['currency_sub_unit'])) ? $country['currency_sub_unit'] : null),
                'full_name'         => ((isset($country['full_name'])) ? $country['full_name'] : null),
                'iso_3166_2'        => ((isset($country['iso_3166_2'])) ? $country['iso_3166_2'] : null),
                'iso_3166_3'        => ((isset($country['iso_3166_3'])) ? $country['iso_3166_3'] : null),
                'name'              => ((isset($country['name'])) ? $country['name'] : null),
                'region_code'       => ((isset($country['region_code'])) ? $country['region_code'] : null),
                'sub_region_code'   => ((isset($country['sub_region_code'])) ? $country['sub_region_code'] : null),
                'eea'               => (bool)$country['eea'],
                'calling_code'      => ((isset($country['calling_code'])) ? $country['calling_code'] : null),
                'currency_symbol'   => ((isset($country['currency_symbol'])) ? $country['currency_symbol'] : null),
            ]);
        }
    }
}
<file_sep>/vendor/ernysans/laraworld/src/Facades/TimeZones.php
<?php

namespace ErnySans\Laraworld\Facades;

use Illuminate\Support\Facades\Facade;

class TimeZones extends Facade
{
    protected static function getFacadeAccessor() {
        return 'TimeZones';
    }
}<file_sep>/vendor/ernysans/laraworld/src/Models/Countries.php
<?php

namespace ErnySans\Laraworld\Models;

use Illuminate\Database\Eloquent\Model;

class Countries extends Model
{

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'countries';

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [
        'id',
        'created_at',
        'updated_at'
    ];

    /**
     * Protect $dates
     *
     * @var array
     */
    protected $dates = [
        'created_at',
        'updated_at'
    ];

    /**
     * he attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'full_name',
        'capital',
        'citizenship',
        'currency',
        'currency_code',
        'currency_sub_unit',
        'currency_symbol',
        'country_code',
        'region_code',
        'sub_region_code',
        'eea',
        'calling_code',
        'iso_3166_2',
        'iso_3166_3',
    ];

    /**
     * Get all the countries from the JSON file.
     *
     * @return array
     */
    public static function allJSON()
    {
        $route = dirname(dirname(__FILE__)) . '/Database/data/countries.json';

        return json_decode(file_get_contents($route), true);
    }

}<file_sep>/database/seeds/DatabaseSeeder.php
<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        // Seed the countries
        $this->call(CountriesTableSeeder::class);
    
        // Seed the Time Zones
        $this->call(TimeZonesTableSeeder::class);
    
        // Seed the Languages
        $this->call(LanguagesTableSeeder::class);
    }
}
<file_sep>/app/DataVoice.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class DataVoice extends Model
{
    protected $fillable = [
        'emp_id', 'emp_name', 'country_code','mobile','email','dob','profile',
    ];
}
