本文整理汇总了PHP中Photo::updateAvatar方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::updateAvatar方法的具体用法?PHP Photo::updateAvatar怎么用?PHP Photo::updateAvatar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photo
的用法示例。
在下文中一共展示了Photo::updateAvatar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateEvent
public static function UpdateEvent($input)
{
$id = $input['id'];
$rules = array('event_category_id' => 'required', 'city_id' => 'required', 'name' => 'required', 'stewardship' => 'required|min:5', 'description' => 'required|min:5', 'location' => 'required', 'started_at' => 'required', 'ended_at' => 'required');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return $validator->errors()->all();
} else {
$started_at = empty($input['started_at']) ? 'no' : preg_split("/([\\/: ])/", $input['started_at']);
$ended_at = empty($input['ended_at']) ? 'no' : preg_split("/([\\/: ])/", $input['ended_at']);
$input = array('event_category_id' => $input['event_category_id'], 'city_id' => $input['city_id'], 'email' => $input['email'], 'name' => $input['name'], 'user_id' => Auth::check() ? Auth::user()->id : '', 'stewardship' => $input['stewardship'], 'description' => $input['description'], 'location' => $input['location'], 'website_url' => $input['website_url'], 'social_media_urls' => $input['social_media_urls'], 'status' => $input['status'], 'started_at' => mktime((int) $started_at[3], (int) $started_at[4], 0, (int) $started_at[0], (int) $started_at[1], (int) $started_at[2]), 'ended_at' => mktime((int) $ended_at[3], (int) $ended_at[4], 0, (int) $ended_at[0], (int) $ended_at[1], (int) $ended_at[2]), 'created_at' => time(), 'updated_at' => time());
$getSlug = Events::where('id', $id)->first();
$slug = Str::slug($input['name']);
// jika input tidak sama dengan slug di database
if (strcmp($input['name'], $getSlug['name']) != 0) {
$checkSlug = Events::where('slug', $slug)->where('id', '!=', $id)->count();
if ($checkSlug > 0) {
$input['slug'] = $slug . "-" . $id;
} else {
$input['slug'] = $slug;
}
}
$photo = Photo::updateAvatar($getSlug['cover_photo_id'], 'events', $getSlug->id);
$input['cover_photo_id'] = $photo['cover_photo_id'];
$event = Events::find($id);
$event->fill($input);
$event->save();
return "ok";
}
}
示例2: UpdateSocialTarget
public static function UpdateSocialTarget($input)
{
$id = $input['id'];
$rules = array('name' => 'required', 'stewardship' => 'required|min:5', 'description' => 'required|min:5', 'address' => 'required', 'phone_number' => 'required');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return $validator->errors()->all();
} else {
$getSlug = SocialTarget::where('id', $id)->first();
$slug = Str::slug($input['name']);
// jika input tidak sama dengan slug di database
if (strcmp($input['name'], $getSlug['name']) != 0) {
$checkSlug = SocialTarget::where('slug', $slug)->where('id', '!=', $id)->count();
if ($checkSlug > 0) {
$input['slug'] = $slug . "-" . $id;
} else {
$input['slug'] = $slug;
}
}
$photo = Photo::updateAvatar($getSlug['cover_photo_id'], 'social_targets', $getSlug->id);
$input['cover_photo_id'] = $photo['cover_photo_id'];
$SocialTarget = SocialTarget::find($id);
$SocialTarget->fill($input);
$SocialTarget->save();
return "ok";
}
}
示例3: UpdateSocialAction
public static function UpdateSocialAction($input)
{
$rules = array('name' => 'required', 'description' => 'required|min:5', 'stewardship' => 'required|min:5', 'bank_account_description' => 'required|min:5', 'currency' => 'required', 'total_donation_target' => 'required', 'expired_at' => 'required');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return $validator->errors()->all();
} else {
$id = $input['id'];
unset($input['id']);
if (!empty($input['expired_at'])) {
$started_at = preg_split("/([\\/: ])/", $input['expired_at']);
$input['expired_at'] = mktime((int) $started_at[3], (int) $started_at[4], 0, (int) $started_at[0], (int) $started_at[1], (int) $started_at[2]);
} else {
$input['expired_at'] = '';
}
$getSlug = SocialAction::where('id', $id)->first();
$slug = Str::slug($input['name']);
// jika input tidak sama dengan slug di database
if (strcmp($input['name'], $getSlug['name']) != 0) {
$checkSlug = SocialAction::where('slug', $slug)->where('id', '!=', $id)->count();
if ($checkSlug > 0) {
$input['slug'] = $slug . "-" . $id;
} else {
$input['slug'] = $slug;
}
}
$photo = Photo::updateAvatar($getSlug['cover_photo_id'], 'social_actions', $getSlug->id);
$input['cover_photo_id'] = $photo['cover_photo_id'];
$SocialAction = SocialAction::find($id);
$SocialAction->fill($input);
$SocialAction->save();
return "ok";
}
}