mirror of
https://github.com/10h30/Test-Laravel-File-Upload.git
synced 2026-06-05 15:07:47 +09:00
31 lines
641 B
PHP
31 lines
641 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers;
|
||
|
|
|
||
|
|
use App\Models\Office;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
|
||
|
|
class OfficeController extends Controller
|
||
|
|
{
|
||
|
|
public function store(Request $request)
|
||
|
|
{
|
||
|
|
$filename = $request->file('photo')->getClientOriginalName();
|
||
|
|
|
||
|
|
// TASK: Upload the file "photo" so it would be written as
|
||
|
|
// storage/app/public/offices/[original_filename]
|
||
|
|
|
||
|
|
Office::create([
|
||
|
|
'name' => $request->name,
|
||
|
|
'photo' => $filename,
|
||
|
|
]);
|
||
|
|
|
||
|
|
return 'Success';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function show(Office $office)
|
||
|
|
{
|
||
|
|
return view('offices.show', compact('office'));
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|