added the image upload for company profile

This commit is contained in:
Aqeeb Imtiaz Harun
2018-05-02 16:34:39 +08:00
parent c6b5c0d3f2
commit 6c5e0b6e0e
8 changed files with 237 additions and 8 deletions
+1 -1
View File
@@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
//
protected $fillable = ['company_name', 'registration_no', 'tax_no', 'tel_no', 'fax', 'address', 'city', 'postcode', 'state', 'country', 'contact_person'];
protected $fillable = ['company_profile', 'company_name', 'registration_no', 'tax_no', 'tel_no', 'fax', 'address', 'city', 'postcode', 'state', 'country', 'contact_person'];
//protected $guarded = [];
}
+44 -3
View File
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Company;
use Image;
class CompanyController extends Controller
{
@@ -38,9 +39,32 @@ class CompanyController extends Controller
{
//
//$company = new Company;
Company::create(request()->all());
// 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();
if($file = $request->file('company_profile'))
{
$name = $file->getClientOriginalName();
$img_file = $request->file('company_profile');
Image::make($img_file)->resize(300,300)->save(public_path('uploads\company_profile\hello.jpg'));
return $img_file;
// $file->move('uploads/company_profile/', $img_file);
$input['company_profile'] = $name;
}
Company::create($input);
//Company::create(request()->all());
//dd(request()->all());
return redirect('/');
// return redirect('/');
}
/**
@@ -80,6 +104,13 @@ class CompanyController extends Controller
return response()->json(['message'=>'Document not found'],200);
}
//$warehouse->address='juhgfd';
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));
}
$company->company_name=$request->input('company_name');
$company->registration_no=$request->input('registration_no');
$company->tax_no=$request->input('tax_no');
@@ -111,4 +142,14 @@ class CompanyController extends Controller
{
//
}
}
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));
// }
}
}
+1
View File
@@ -8,6 +8,7 @@
"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
+186 -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": "da90d5fb2239697082944d7ce2a406b4",
"content-hash": "ad4497779e1657228811439be2faf961",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
@@ -723,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",
@@ -1496,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",
+2 -2
View File
@@ -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
],
];
@@ -15,7 +15,7 @@ class CreateCompaniesTable extends Migration
{
Schema::create('companies', function (Blueprint $table) {
$table->increments('id');
//$table->string('company-profile'); //need to check about storage type
$table->string('company_profile');//->default('default.jpg'); //need to check about storage type
$table->string('company-name');
$table->string('registration-no');
$table->string('tax-no');
Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+2
View File
@@ -30,6 +30,8 @@ Route::group(['middleware' => ['jwt.auth']], function() {
Route::post('/company', 'CompanyController@store');
Route::put('/company/{company}', 'CompanyController@update');
//Route::post('/company', 'CompanyController@uploadImage');
// Route::put('company/{company}', function(Request $request, $productId) {
// $product = Company::findOrFail($productId);
// $product->update($request->all());