本文整理汇总了PHP中Photo::saveAvatar方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::saveAvatar方法的具体用法?PHP Photo::saveAvatar怎么用?PHP Photo::saveAvatar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photo
的用法示例。
在下文中一共展示了Photo::saveAvatar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: StoreEvent
public static function StoreEvent($input)
{
$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 {
try {
$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'], '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());
$event = new Events();
$event->fill($input);
$event->save();
$slug = Str::slug($input['name']);
$checkSlug = Events::where('slug', $slug)->where('id', '!=', $event->id)->count();
if ($checkSlug > 0) {
$updateInsert['slug'] = $slug . "-" . $event->id;
} else {
$updateInsert['slug'] = $slug;
}
$photo = Photo::saveAvatar('events', $event->id);
$updateInsert['cover_photo_id'] = $photo['cover_photo_id'];
$update = Events::find($event->id);
$update->fill($updateInsert);
$update->save();
$hasil = array('id' => $event->id, 'msg' => 'ok');
return $hasil;
} catch (Exception $e) {
return "no";
}
}
}
示例2: StoreSocialTarget
public static function StoreSocialTarget($input)
{
unset($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 {
$SocialTarget = new SocialTarget();
$SocialTarget->fill($input);
$SocialTarget->save();
// update
$slug = Str::slug($input['name']);
$checkSlug = SocialTarget::where('slug', $slug)->where('id', '!=', $SocialTarget->id)->count();
if ($checkSlug > 0) {
$updateInsert['slug'] = $slug . "-" . $SocialTarget->id;
} else {
$updateInsert['slug'] = $slug;
}
// $updateInsert['slug'] = SocialAction::checkSlugName(Str::slug($input['name'])) > 0 ?
// strtolower(Str::slug($input['name'])).$SocialTarget->id :
// strtolower(Str::slug($input['name']));
$photo = Photo::saveAvatar('social_targets', $SocialTarget->id);
$updateInsert['cover_photo_id'] = $photo['cover_photo_id'];
$update = SocialTarget::find($SocialTarget->id);
$update->fill($updateInsert);
$update->save();
$hasil = array('id' => $SocialTarget->id, 'msg' => 'ok');
return $hasil;
}
}
示例3: StoreEvent
public static function StoreEvent($input)
{
$rules = array('event_category_id' => 'required', 'city_id' => 'required', 'name' => 'required', 'creator_fname' => 'required', 'creator_lname' => 'required', 'creator_email' => 'required|email', 'email' => 'required|email', '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 {
try {
$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'], 'creator_fname' => 'required', 'creator_lname' => 'required', 'creator_email' => 'required|email', 'name' => $input['name'], 'stewardship' => $input['stewardship'], 'description' => $input['description'], 'location' => $input['location'], 'website_url' => $input['website_url'], 'social_media_urls' => $input['social_media_urls'], '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());
// Mencatat pembuat target sosial
if (Auth::check()) {
$input['user_id'] = Auth::user()->id;
} else {
// Check apakah user ada di database
$check_user = User::where('email', $input['creator_email']);
if ($check_user->count() > 0) {
$input['user_id'] = $check_user->pluck('id');
} else {
// Membuat user baru dengan status draft (status:2)
$post = new User();
$post->firstname = $input['creator_fname'];
$post->lastname = $input['creator_lname'];
$post->email = $input['creator_email'];
$post->status = 2;
$post->save();
$input['user_id'] = $post->id;
}
}
unset($input['creator_fname']);
unset($input['creator_lname']);
unset($input['creator_email']);
$event = new Events();
$event->fill($input);
$event->save();
$slug = Str::slug($input['name']);
$checkSlug = Events::where('slug', $slug)->where('id', '!=', $event->id)->count();
if ($checkSlug > 0) {
$updateInsert['slug'] = $slug . "-" . $event->id;
} else {
$updateInsert['slug'] = $slug;
}
$photo = Photo::saveAvatar('events', $event->id);
$updateInsert['cover_photo_id'] = $photo['cover_photo_id'];
$update = Events::find($event->id);
$update->fill($updateInsert);
$update->save();
$hasil = array('id' => $event->id, 'msg' => 'ok');
return $hasil;
} catch (Exception $e) {
return "no";
}
}
}
示例4: StoreSocialActionFront
public static function StoreSocialActionFront($input)
{
unset($input['id']);
$started_at = '';
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'] = '';
}
$rules = array('name' => 'required', 'description' => 'required|min:5', 'stewardship' => 'required|min:5', 'creator_fname' => 'required', 'creator_lname' => 'required', 'creator_email' => 'required|email', 'bank_account_description' => 'required|min:5', 'currency' => 'required', 'total_donation_target' => 'required', 'expired_at' => 'required');
// Mencatat pembuat aksi sosial
if (Auth::check()) {
$input['user_id'] = Auth::user()->id;
} else {
// Check apakah user ada di database
$check_user = User::where('email', $input['creator_email']);
if ($check_user->count() > 0) {
$input['user_id'] = $check_user->pluck('id');
} else {
// Membuat user baru dengan status draft (status:2)
$post = new User();
$post->firstname = $input['creator_fname'];
$post->lastname = $input['creator_lname'];
$post->email = $input['creator_email'];
$post->status = 2;
$post->save();
$input['user_id'] = $post->id;
}
}
unset($input['default_photo_id']);
unset($input['cover_photo_id']);
$validator = Validator::make($input, $rules);
unset($input['creator_fname']);
unset($input['creator_lname']);
unset($input['creator_email']);
if ($validator->fails()) {
return $validator->errors()->all();
} else {
$SocialAction = new SocialAction();
$SocialAction->fill($input);
$SocialAction->save();
// update
$photo = Photo::saveAvatar('social_actions', $SocialAction->id, $input['user_id']);
$update = SocialAction::find($SocialAction->id);
$update->fill(array('slug' => SocialAction::checkSlugName(Str::slug($input['name'])) > 0 ? strtolower(Str::slug($input['name'])) . $SocialAction->id : strtolower(Str::slug($input['name'])), 'cover_photo_id' => $photo['cover_photo_id'], 'default_photo_id' => $photo['default_photo_id']));
$update->save();
return "ok";
}
}
示例5: StoreSocialActionFront
public static function StoreSocialActionFront($input)
{
unset($input['id']);
$started_at = '';
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'] = '';
}
// unset($input['expired_at']);
$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');
unset($input['default_photo_id']);
unset($input['cover_photo_id']);
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return $validator->errors()->all();
} else {
$SocialAction = new SocialAction();
$SocialAction->fill($input);
$SocialAction->save();
// update
$photo = Photo::saveAvatar('social_actions', $SocialAction->id);
$update = SocialAction::find($SocialAction->id);
$update->fill(array('slug' => SocialAction::checkSlugName(Str::slug($input['name'])) > 0 ? strtolower(Str::slug($input['name'])) . $SocialAction->id : strtolower(Str::slug($input['name'])), 'cover_photo_id' => $photo['cover_photo_id'], 'default_photo_id' => $photo['default_photo_id']));
$update->save();
return "ok";
}
}