key={'manager_badge_'+this.props.member.name}
{this.state.members.map( (member) => <MemberComponent key={'member_'+member.name} member={member} links={links} canDelete={this.authCanDelete} detachUser={this.detachUser.bind(this)}/> )}
MemberComponent:
MemberControlPanel:
DeleteButton
CreatorBadge
ManagerBadge
class UserService extends UserServiceContract
{
protected $user;
protected $uploadService;
//Конструктор с определением $user b $uploadService вшит в абстрактный класс UserServiceContract вот так:
/*
public function __construct(User $user, FileUploadContract $uploadService)
{
$this->user = $user;
$this->uploadService = $uploadService;
}
*/
public function updateUserImage(UploadedFile $image): void
{
$oldImageName = $this->user->profile_image;
$newImageName = uniqid("", false) . '.png';
$this->user->profile_image = $newImageName;
try {
DB::transaction(function(){
$this->user->update();
});
$this->uploadService->upload($image, $newImageName, $oldImageName);
} catch (Exception $e) {
abort(503, $e->getMessage());
}
}
}
app()->bind(UserServiceContract::class, function($app, $parameters) {
return app()->makeWith(UserService::class, $parameters);
});
app()->when(UserService::class)->needs(FileUploadContract::class)
->give(function() {
return new AvatarUploadService(config('images.user_avatar_dir'));
});
public function postUserProfileImage(UserUpdateImageForm $request)
{
$userService = app()->makeWith(UserServiceContract::class, ['user'=>auth()->user()]);
$userService->updateUserImage( $request->file('profile_image') );
return redirect()->back();
}
protected $uploadService;
public function __construct(User $user, FileUploadContract $uploadService)
{
$this->user = $user;
$this->uploadService = $uploadService;
}
public function updateUserImage(UploadedFile $image)
{
$oldImageName = $this->user->profile_image;
$newImageName = uniqid("", false) . '.png';
$this->user->profile_image = $newImageName;
try {
DB::transaction(function() {
$this->user->update();
});
$this->uploadService->upload($image, $newImageName, $oldImageName);
} catch (Exception $e) {
abort(503, $e->getMessage());
}
}