2021-12-06 11:07:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\Models\Office;
|
|
|
|
|
use Illuminate\Http\Request;
|
2025-05-11 09:47:13 +09:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2021-12-06 11:07:06 +02:00
|
|
|
|
|
|
|
|
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]
|
2025-05-11 09:47:13 +09:00
|
|
|
$request->file('photo')->storeAs('offices', $filename, 'public');
|
2021-12-06 11:07:06 +02:00
|
|
|
|
|
|
|
|
Office::create([
|
|
|
|
|
'name' => $request->name,
|
|
|
|
|
'photo' => $filename,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return 'Success';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function show(Office $office)
|
|
|
|
|
{
|
|
|
|
|
return view('offices.show', compact('office'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|