Skip to content

Commit bfe8ba1

Browse files
committed
fix(control): model
1 parent 6fae2a8 commit bfe8ba1

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

laravel/app/Http/Controllers/Bus/AutoController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ public function baiduOCR($img, $imgUrl)
109109
}
110110

111111
// 3. 保存到数据库
112-
ToolRepository::getInstance()->saveUploadData($imgUrl, $words);
112+
$upload = new \App\Models\Upload();
113+
$upload->img_url = $imgUrl;
114+
$upload->content = $words;
115+
return $upload->save();
113116
}
114117
return $words;
115118
}

laravel/app/Models/Upload.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Upload extends Model
8+
{
9+
//
10+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateUploadsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('uploads', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->string('img_url', 255)->default('')->comment('图片路径');
19+
$table->text('content')->comment('OCR内容');
20+
$table->timestamps();
21+
});
22+
}
23+
24+
/**
25+
* Reverse the migrations.
26+
*
27+
* @return void
28+
*/
29+
public function down()
30+
{
31+
Schema::dropIfExists('uploads');
32+
}
33+
}

0 commit comments

Comments
 (0)