contact migration

This commit is contained in:
Asif
2018-05-14 16:23:56 +08:00
19 changed files with 933 additions and 24 deletions
+4 -2
View File
@@ -1,9 +1,11 @@
FROM php:7
WORKDIR /app
COPY . /app
RUN apt-get update -y && apt-get install -y openssl zip unzip git
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo pdo_mysql
WORKDIR /app
COPY . /app
RUN composer install
CMD php artisan serve --host=0.0.0.0 --port=8000
EXPOSE 8000
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
//
protected $fillable = ['company_profile', 'reg_cert', 'company_name', 'registration_no', 'tax_no', 'tel_no', 'fax', 'address', 'city', 'postcode', 'state', 'country', 'contact_person'];
//protected $guarded = [];
}
+1 -1
View File
@@ -6,5 +6,5 @@ use Illuminate\Database\Eloquent\Model;
class Contact extends Model
{
protected $fillable = ['ff_id'];
protected $fillable = ['user_id','company_id'];
}
+228
View File
@@ -0,0 +1,228 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Company;
use Image;
use Illuminate\Support\Facades\Storage;
class CompanyController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
return view ('home');
}
public function search($company_name)
{
$matchedTerm = Company::where('company_name', 'LIKE','%'. $company_name . '%')->get();
return response()->json($matchedTerm);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
//$company = new Company;
// if($request->hasFile('avatar'))
// {
// $avatar = $request->file('avatar');
// $filename = time() . '.' . $avatar->getClientOriginalExtension();
// Image::make($avatar)->resize(300,300)->save(public_path('/uploads/company_profile/'.$filename));
// }
// else
// {
// return response()->json(['message'=>'Document not found']);
// }
$input = $request->all();
//validating uploaded files
// $this->validate(request(),[
// 'company_profile' => 'required|image|mimes:jpg,jpeg,bmp,png',
// 'reg_cerf' => 'required|mimes:jpg,jpeg,bmp,png,gif,svg,pdf'
// ]);
if($file = $request->file('company_profile')) //company profile picture
{
$company_profile = $request->file('company_profile');
$filename = $company_profile->getClientOriginalName();
//$destinationPath = config('app.fileDestinationPath').'/'.$filename;
$file = $request->file('company_profile');
$ext = $file->getClientOriginalExtension();
Storage::putFileAs(
'company_profile',/*folder name*/ $file, $filename. '.' .$ext
);
// $name = $file->getClientOriginalName();
// $img_file = $request->file('company_profile');
// Image::make($img_file)->resize(300,300)->save(public_path('\company_profile'));
// //return $img_file;
// // $file->move('uploads/company_profile/', $img_file);
// $input['company_profile'] = $name;
}
if($request->hasFile('reg_cert')) //Registration Certificate upload
{
$reg_cert = $request->file('reg_cert');
$filename = $reg_cert->getClientOriginalName();
//$destinationPath = config('app.fileDestinationPath').'/'.$filename;
$file = $request->file('reg_cert');
$ext = $file->getClientOriginalExtension();
Storage::putFileAs(
'reg_cert',/*folder name*/ $file, $filename. '.' .$ext
);
// $uploaded = Storage::put($destinationPath, file_get_contents($reg_cert->getRealPath()));
// $name = $file->getClientOriginalName();
// $img_file = $request->file('reg_cert');
// Image::make($img_file)->save(public_path('uploads\reg_cert'));
// $input['company_profile'] = $name;
// $request->file('req_cert');
// //$request->image->store('\uploads\reg_cert');
// Storage::putFile('uploads\reg_cert', $request->file('reg_cert'));
}
// else{
// return "failed";
// }
Company::create($input);
//Company::create(request()->all());
//dd(request()->all());
return redirect('/');
}
/**
* 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)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$company = Company::find($id);
if (!$company)
{
return response()->json(['message'=>'Document not found'],200);
}
//updating company profile picture
if($file = $request->file('company_profile')) //company profile picture
{
$company_profile = $request->file('company_profile');
$filename = $company_profile->getClientOriginalName();
//$destinationPath = config('app.fileDestinationPath').'/'.$filename;
$file = $request->file('company_profile');
$ext = $file->getClientOriginalExtension();
Storage::putFileAs(
'company_profile',/*folder name*/ $file, $filename. '.' .$ext
);
}
//updating registration certificate
if($request->hasFile('reg_cert')) //Registration Certificate upload
{
$reg_cert = $request->file('reg_cert');
$filename = $reg_cert->getClientOriginalName();
//$destinationPath = config('app.fileDestinationPath').'/'.$filename;
$file = $request->file('reg_cert');
$ext = $file->getClientOriginalExtension();
Storage::putFileAs(
'reg_cert',/*folder name*/ $file, $filename. '.' .$ext
);
}
$company->company_name=$request->input('company_name');
$company->registration_no=$request->input('registration_no');
$company->tax_no=$request->input('tax_no');
$company->tel_no=$request->input('tel_no');
$company->fax=$request->input('fax');
$company->address=$request->input('address');
$company->city=$request->input('city');
$company->postcode=$request->input('postcode');
$company->state=$request->input('state');
$company->country=$request->input('country');
$company->contact_person=$request->input('contact_person');
$company->save();
return response()->json(['warehouse'=>$company],200);
// $product = Company::findOrFail($productId);
// $product->update($request->all());
// $product->company_name = 'imagepath';
// $product->save();
//return response()->json($product, 200);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
public function uploadImage($request)
{
// if($request->hasFile('avatar'))
// {
// $avatar = $request->file('avatar');
// $filename = time() . '.' . $avatar->getClientOriginalExtension();
// Image::make($avatar)->resize(300,300)->save(public_path('/uploads/company_profile/'.$filename));
// }
}
}
+15 -9
View File
@@ -32,16 +32,9 @@ class ContactController extends Controller
{
//
}
public function searchContact($id)
{
$matchedTerm = Breed::where('ff_id', 'LIKE', $id . '%')->get();
return response()->json($matchedTerm);
}
/**
* Store a newly created resource in storage.
*
@@ -50,8 +43,21 @@ class ContactController extends Controller
*/
public function store(Request $request)
{
$contact = Contact::create($request->all());
// $contact->created=true;
// get company id from request ex: $request->input('company_id')
// $company_id = $request->input('company_id'))
// query to find company asisng to $company
// $company = Comapny::find($company_id)
// get user from session $request->user();
// $user = $request->user();
// prepare query
// insert into database
return response()->json($contact, 201);
}
+2
View File
@@ -6,7 +6,9 @@
"type": "project",
"require": {
"php": "^7.1.3",
"doctrine/dbal": "^2.7",
"fideloper/proxy": "^4.0",
"intervention/image": "^2.4",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"tymon/jwt-auth": "dev-develop"
Generated
+543 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "f2d9e6ec1c09918f1f3130aa31e04472",
"content-hash": "ad4497779e1657228811439be2faf961",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
@@ -39,6 +39,363 @@
"description": "implementation of xdg base directory specification for php",
"time": "2014-10-24T07:27:01+00:00"
},
{
"name": "doctrine/annotations",
"version": "v1.6.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5",
"reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": "^7.1"
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "^6.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Docblock Annotations Parser",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"docblock",
"parser"
],
"time": "2017-12-06T07:11:42+00:00"
},
{
"name": "doctrine/cache",
"version": "v1.7.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/b3217d58609e9c8e661cd41357a54d926c4a2a1a",
"reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a",
"shasum": ""
},
"require": {
"php": "~7.1"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
},
"require-dev": {
"alcaeus/mongo-php-adapter": "^1.1",
"mongodb/mongodb": "^1.1",
"phpunit/phpunit": "^5.7",
"predis/predis": "~1.0"
},
"suggest": {
"alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Caching library offering an object-oriented API for many cache backends",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"cache",
"caching"
],
"time": "2017-08-25T07:02:50+00:00"
},
{
"name": "doctrine/collections",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/collections.git",
"reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/collections/zipball/a01ee38fcd999f34d9bfbcee59dbda5105449cbf",
"reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"doctrine/coding-standard": "~0.1@dev",
"phpunit/phpunit": "^5.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Common\\Collections\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Collections Abstraction library",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"array",
"collections",
"iterator"
],
"time": "2017-07-22T10:37:32+00:00"
},
{
"name": "doctrine/common",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common.git",
"reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/f68c297ce6455e8fd794aa8ffaf9fa458f6ade66",
"reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66",
"shasum": ""
},
"require": {
"doctrine/annotations": "1.*",
"doctrine/cache": "1.*",
"doctrine/collections": "1.*",
"doctrine/inflector": "1.*",
"doctrine/lexer": "1.*",
"php": "~7.1"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\": "lib/Doctrine/Common"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Common Library for Doctrine projects",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"collections",
"eventmanager",
"persistence",
"spl"
],
"time": "2017-08-31T08:43:38+00:00"
},
{
"name": "doctrine/dbal",
"version": "v2.7.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "11037b4352c008373561dc6fc836834eed80c3b5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/11037b4352c008373561dc6fc836834eed80c3b5",
"reference": "11037b4352c008373561dc6fc836834eed80c3b5",
"shasum": ""
},
"require": {
"doctrine/common": "^2.7.1",
"ext-pdo": "*",
"php": "^7.1"
},
"require-dev": {
"doctrine/coding-standard": "^4.0",
"phpunit/phpunit": "^7.0",
"phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5",
"symfony/console": "^2.0.5||^3.0",
"symfony/phpunit-bridge": "^3.4.5|^4.0.5"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
},
"bin": [
"bin/doctrine-dbal"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\DBAL\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
}
],
"description": "Database Abstraction Layer",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"database",
"dbal",
"persistence",
"queryobject"
],
"time": "2018-04-07T18:44:18+00:00"
},
{
"name": "doctrine/inflector",
"version": "v1.3.0",
@@ -366,6 +723,141 @@
],
"time": "2018-02-07T20:20:57+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "1.4.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"request",
"response",
"stream",
"uri",
"url"
],
"time": "2017-03-20T17:10:46+00:00"
},
{
"name": "intervention/image",
"version": "2.4.1",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "3603dbcc9a17d307533473246a6c58c31cf17919"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/3603dbcc9a17d307533473246a6c58c31cf17919",
"reference": "3603dbcc9a17d307533473246a6c58c31cf17919",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp/psr7": "~1.1",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9.2",
"phpunit/phpunit": "^4.8 || ^5.7"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention/imagecache": "Caching extension for the Intervention Image library"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
},
"laravel": {
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"autoload": {
"psr-4": {
"Intervention\\Image\\": "src/Intervention/Image"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@olivervogel.com",
"homepage": "http://olivervogel.com/"
}
],
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http://image.intervention.io/",
"keywords": [
"gd",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
],
"time": "2017-09-21T16:29:17+00:00"
},
{
"name": "jakub-onderka/php-console-color",
"version": "0.1",
@@ -1139,6 +1631,56 @@
],
"time": "2017-02-14T16:28:37+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "psr/log",
"version": "1.0.2",
+3 -3
View File
@@ -1,7 +1,7 @@
<?php
return [
//'fileDestinationPath' => 'uploads',
/*
|--------------------------------------------------------------------------
| Application Name
@@ -159,7 +159,7 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Intervention\Image\ImageServiceProvider::class
],
/*
@@ -210,7 +210,7 @@ return [
'View' => Illuminate\Support\Facades\View::class,
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
'Image' => Intervention\Image\Facades\Image::class
],
];
+1 -1
View File
@@ -43,7 +43,7 @@ return [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'database' => env('DB_DATABASE', 'forgzze'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
@@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCompaniesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('companies', function (Blueprint $table) {
$table->increments('id');
$table->string('company_profile');//->default('default.jpg'); //need to check about storage type
$table->string('reg_cert');
$table->string('company-name');
$table->string('registration-no');
$table->string('tax-no');
$table->integer('tel-no');
$table->integer('fax');
$table->string('address');
$table->string('city');
$table->string('postcode');
$table->string('state');
$table->string('country');
$table->string('contact-person');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('companies');
}
}
@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RenameColumnInCompany extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('companies', function (Blueprint $table) {
// $table->renameColumn('company-profile', 'company_profile');
$table->renameColumn('"company-name"', 'company_name');
$table->renameColumn('"registration-no"', 'registration_no');
$table->renameColumn('"tax-no"', 'tax_no');
$table->renameColumn('"tel-no"', 'tel_no');
$table->renameColumn('"contact-person"', 'contact_person');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -15,7 +15,19 @@ class CreateContactsTable extends Migration
{
Schema::create('contacts', function (Blueprint $table) {
$table->increments('id');
$table->integer('ff_id')->unique();
$table->integer('user_id')->unsigned();
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
//$table->unsignedInteger('user_id');
// $table->foreign('user_id')->references('id')->on('users');
$table->integer('company_id')->unsigned();
$table->foreign('company_id')
->references('id')->on('companies')
->onDelete('cascade');
$table->Integer('status')->default('0');
$table->timestamps();
});
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File
+30 -4
View File
@@ -1,7 +1,7 @@
<?php
use Illuminate\Http\Request;
use App\Company;
/*
|--------------------------------------------------------------------------
| API Routes
@@ -17,8 +17,8 @@ use Illuminate\Http\Request;
// return $request->user();
//});
//Route::post('register', 'AuthController@register');
//Route::post('login', 'AuthController@login');
Route::post('register', 'AuthController@register');
Route::post('login', 'AuthController@login');
//Route::post('recover', 'AuthController@recover');
//
//Route::group(['middleware' => ['jwt.auth']], function() {
@@ -34,7 +34,33 @@ Route :: put('/warehouse/{war_id}','WarehouseController@update');
Route :: get('/warehouse','WarehouseController@index');
Route :: delete('/contacts/{ff_id}','ContactController@destroy');
Route :: get('/contacts','ContactController@index');
Route :: post('/contacts','ContactController@store');
Route::get('/company/search/{name}', 'CompanyController@searchContact');
Route::group(['middleware' => ['jwt.auth']], function() {
Route::get('logout', 'AuthController@logout');
Route::get('test', function(){
return response()->json(['foo'=>'bar']);
});
});
Route::post('/company', 'CompanyController@store'); //store company information
Route::put('/company/{company}', 'CompanyController@update'); //update company information
Route::get('/company/search/{company_name}', 'CompanyController@search');
//Route::post('/company', 'CompanyController@uploadImage');
// Route::put('company/{}', function(Request $request, $productId) {
// $product = Company::findOrFail($productId);
// $product->update($request->all());
// return $product;
// });
// Route::put('company/{}', function(Request $request, $companyId) {
// $company = Product::findOrFail($companyId);
// $company->update($request->all());
// return $company;
// });
+2
View File
@@ -17,3 +17,5 @@ Route::get('/', function () {
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.request');
Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset');
Route::get('/company', 'CompanyController@index');
-2
View File
@@ -1,2 +0,0 @@
*
!.gitignore