Upload user registration image to s3.
This commit is contained in:
parent
2428bd0284
commit
b3f7fdb324
@ -12,6 +12,7 @@ use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
@ -19,7 +20,9 @@ class UserController extends Controller
|
||||
|
||||
public function __construct(
|
||||
protected UserContractInterface $user
|
||||
){}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
@ -51,11 +54,15 @@ class UserController extends Controller
|
||||
$user = $request->all();
|
||||
$user['password'] = bcrypt($request->password);
|
||||
|
||||
if ($request->hasFile('profile_picture'))
|
||||
{
|
||||
$user['profile_picture'] = url('storage') . '/' . $request->file('profile_picture')->store('users');
|
||||
if (!$request->hasFile('profile_picture')) {
|
||||
return $this->errorResponse(false, '', 500);
|
||||
}
|
||||
|
||||
$file = $request->file('profile_picture');
|
||||
|
||||
$path = $file->storeAs('avatars', $file->hashName(),'s3');
|
||||
|
||||
$user['profile_picture'] = Storage::disk('s3')->url($path);
|
||||
$response = $this->user->create($user);
|
||||
return (new UserResource($response))
|
||||
->response()
|
||||
|
||||
@ -60,14 +60,18 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
||||
"economia.dad_estimado"
|
||||
];
|
||||
|
||||
return $this->execute($params, $field)
|
||||
$test = $this->execute($params, $field)
|
||||
->where(DB::raw("TO_DATE(economia.mes, 'YYMM')"),
|
||||
">=",
|
||||
DB::raw("TO_DATE(TO_CHAR(current_date , 'YYYY-01-01'), 'YYYY-MM-DD') - interval '1' year"))
|
||||
->groupBy(['mes', 'dad_estimado'])
|
||||
->orderBy('mes', 'desc')
|
||||
->orderBy('dad_estimado', 'desc')
|
||||
->orderBy('mes')
|
||||
->orderBy('dad_estimado')
|
||||
->get();
|
||||
|
||||
$t = $this->array_sort_by_column($test, 'mes');
|
||||
|
||||
dd($t);
|
||||
}
|
||||
|
||||
public function getCaptiveMonthlyEconomy($params)
|
||||
@ -158,4 +162,15 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
|
||||
}
|
||||
|
||||
|
||||
public function array_sort_by_column(&$array, $column, $direction = SORT_ASC) {
|
||||
$reference_array = array();
|
||||
|
||||
foreach($array as $key => $row) {
|
||||
$reference_array[$key] = $row[$column];
|
||||
}
|
||||
|
||||
return array_multisort($reference_array, $direction, $array);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -27,13 +27,13 @@ Route::middleware(['auth:sanctum', 'verified'])->group(function () {
|
||||
Route::get('faq/{faq}', [\App\Http\Controllers\FaqController::class, 'show']);
|
||||
|
||||
Route::post('pld', [\App\Http\Controllers\PldController::class, 'index']);
|
||||
|
||||
Route::post('units', [\App\Http\Controllers\ClientController::class, 'index']);
|
||||
});
|
||||
|
||||
Route::middleware(['auth:sanctum', 'ability:Admin'])->group(function () {
|
||||
Route::apiResource('user', \App\Http\Controllers\UserController::class);
|
||||
|
||||
Route::post('units', [\App\Http\Controllers\ClientController::class, 'index']);
|
||||
|
||||
Route::put('notification/{notification}', [\App\Http\Controllers\NotificationController::class, 'update']);
|
||||
Route::post('notification', [\App\Http\Controllers\NotificationController::class, 'store']);
|
||||
Route::delete('notification/{notification}', [\App\Http\Controllers\NotificationController::class, 'destroy']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user