Commit 3a4a9153 authored by Kittisak Maneewong's avatar Kittisak Maneewong

make upload picture

parent 1e88a684
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
//
}
<?php
namespace App\Http\Controllers;
use App\Company;
use Illuminate\Http\Request;
class CompanyController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* 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)
{
$image = $request->get('image');
$name = time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1];
\Image::make($request->get('image'))->save(storage_path('uploads/').$name);
$company = new Company();
$company->imageCompany = 'Company'.$name;
$company->save();
return response()->json(['success' => 'You have successfully uploaded an image'], 200);
}
/**
* 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)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
......@@ -10,6 +10,7 @@
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"intervention/image": "^2.4",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"tymon/jwt-auth": "dev-develop"
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2b6d62e3328e2ddda234560841055aab",
"content-hash": "49050b2b63bc2ace2ee8e18f917b02c9",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
......@@ -366,6 +366,143 @@
],
"time": "2019-01-10T14:06:47+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "1.5.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "9f83dded91781a01c63574e387eaa769be769115"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115",
"reference": "9f83dded91781a01c63574e387eaa769be769115",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0",
"ralouphie/getallheaders": "^2.0.5"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5-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",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"time": "2018-12-04T20:46:45+00:00"
},
{
"name": "intervention/image",
"version": "2.4.2",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "e82d274f786e3d4b866a59b173f42e716f0783eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/e82d274f786e3d4b866a59b173f42e716f0783eb",
"reference": "e82d274f786e3d4b866a59b173f42e716f0783eb",
"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.4-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": "2018-05-29T14:19:03+00:00"
},
{
"name": "jakub-onderka/php-console-color",
"version": "v0.2",
......@@ -1263,6 +1400,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.1.0",
......@@ -1432,6 +1619,46 @@
],
"time": "2018-10-13T15:16:03+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "2.0.5",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
"reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "~3.7.0",
"satooshi/php-coveralls": ">=1.0"
},
"type": "library",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"time": "2016-02-11T07:05:27+00:00"
},
{
"name": "ramsey/uuid",
"version": "3.8.0",
......
......@@ -175,6 +175,7 @@ return [
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
],
......@@ -228,6 +229,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,
],
......
<?php
return [
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports "GD Library" and "Imagick" to process images
| internally. You may choose one of them according to your PHP
| configuration. By default PHP's "GD Library" implementation is used.
|
| Supported: "gd", "imagick"
|
*/
'driver' => 'gd'
];
......@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCompanysTable extends Migration
class CreateCompaniesTable extends Migration
{
/**
* Run the migrations.
......@@ -13,17 +13,29 @@ class CreateCompanysTable extends Migration
*/
public function up()
{
Schema::create('companys', function (Blueprint $table) {
Schema::create('companies', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('imageCompany')->nullable();
$table->string('company_name');
$table->string('company_owner');
$table->string('phone_no');
$table->string('email');
$table->string('fax')->nullable();
$table->string('website')->nullable();
$table->string('addr');
$table->string('tambon');
$table->string('amphoe');
$table->string('province');
$table->string('zipcode');
$table->string('imageMap')->nullable();
$table->string('about')->nullable();
$table->string('bts')->nullable();
$table->string('mrt')->nullable();
$table->string('arl')->nullable();
$table->string('bus')->nullable();
$table->string('another')->nullable();
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
}
......@@ -35,6 +47,6 @@ class CreateCompanysTable extends Migration
*/
public function down()
{
Schema::dropIfExists('companys');
Schema::dropIfExists('companies');
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -177,7 +177,7 @@
<span >เพื่อความสะดวกในการเดินทางของผู้สมัครงาน กรุณาระบุสถานีรถไฟฟ้าที่ใกล้กับสถานที่ปฏิบัติงาน (ถ้ามี) หรือระบุสายรถเมล์ที่ผ่านสถานที่ประกอบการ และระบุการเดินทางเพิ่มเติม เพื่อให้เข้าใจในการเดินทางมากยิ่งขึ้น</span>
</v-flex>
</v-layout>
<v-layout row wrap class="borderbottom">
<!-- <v-layout row wrap class="borderbottom">
<v-flex sm6 xs12 class="pa-3">
<h2 class="font-weight-bold my-2"><span class="red--text">&nbsp;รายละเอียดงาน</span></h2>
<v-flex sm12 xs12 class="pa-3">
......@@ -242,13 +242,6 @@
<label class="font-weight-bold my-2">เวลาทำงาน <span class="red--text">&nbsp;*</span></label>
<v-layout align-center justify-center row fill-height wrap>
<v-flex sm6 xs12 class="px-2">
<!-- <v-text-field
outline
label="จาก"
type="time"
:rules="[rules.required]"
class="my-job"
></v-text-field> -->
<v-menu
ref="time1"
v-model="showTimeFrom"
......@@ -341,7 +334,7 @@
<v-layout justify-center>
<v-btn color="success" type="submit">บันทึกข้อมูล</v-btn>
</v-layout>
</v-layout>
</v-layout> -->
</v-flex>
</v-form>
</v-layout>
......@@ -370,24 +363,11 @@ export default {
if (!file.length) {
return
}
this.status = file[0].name
this.showImage(file[0])
this.getBlob(file[0], file[0].type)
},
showImage (file) {
const reader = new FileReader()
reader.onload = e => {
const fileReader = new FileReader()
fileReader.readAsDataURL(file[0])
fileReader.onload = e => {
this.srcImage = e.target.result
}
reader.readAsDataURL(file)
},
getBlob (file, type) {
const reader = new FileReader()
reader.onloadend = e => {
let imgBlob = new Blob([e.target.result], { type: type })
console.log(imgBlob)
}
reader.readAsArrayBuffer(file)
},
createJob () {
if (this.$refs.create.validate()) {
......
......@@ -11,4 +11,6 @@
|
*/
Route::get('/{any}', 'AppController@index')->where('any', '.*');
\ No newline at end of file
Route::get('/{any}', 'AppController@index')->where('any', '.*');
Route::resource('/companys', 'CompanyController');
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment