本文整理匯總了PHP中Vote::whereObj方法的典型用法代碼示例。如果您正苦於以下問題:PHP Vote::whereObj方法的具體用法?PHP Vote::whereObj怎麽用?PHP Vote::whereObj使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Vote
的用法示例。
在下文中一共展示了Vote::whereObj方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: destroy
public function destroy($id)
{
Cache::flush();
if (Auth::check()) {
$mp3 = MP3::find($id);
if (Auth::user()->id == $mp3->user_id || User::is_admin()) {
if ($mp3) {
Vote::whereObj('MP3')->whereObjId($mp3->id)->whereUserId(Auth::user()->id)->delete();
$mp3->delete();
File::delete(Config::get('site.mp3_upload_path') . '/' . $mp3->mp3name);
File::delete(Config::get('site.image_upload_path') . '/' . $mp3->image);
File::delete(Config::get('site.image_upload_path') . '/thumbs/' . $mp3->image);
File::delete(Config::get('site.image_upload_path') . '/tiny/' . $mp3->image);
File::delete(Config::get('site.image_upload_path') . '/show/' . $mp3->image);
if (Auth::user()->is_admin()) {
return Redirect::to('/admin/mp3');
}
return Redirect::to('/mp3');
} else {
return Redirect::to('/mp3')->withMessage('Nou regrèt men nou pa reyisi efase mizik la.');
}
}
}
return Redirect::to('/mp3')->withMessage('Ou pa gen dwa pou efase mizik la.');
}
示例2: deleteUser
public function deleteUser($id = null)
{
$del = Input::get('del');
if (!empty($id) && Auth::user()->is_admin()) {
$admin = Auth::user();
$user = User::find($id);
$mp3s = $user->mp3s()->get();
$mp4s = $user->mp4s()->get();
foreach ($mp3s as $mp3) {
$mp3->user_id = $admin->id;
$mp3->save();
Vote::whereObj('MP3')->whereObjId($mp3->id)->whereUserId($user->id)->delete();
}
foreach ($mp4s as $mp4) {
$mp4->user_id = $admin->id;
$mp4->save();
Vote::whereObj('MP4')->whereObjId($mp4->id)->whereUserId($user->id)->delete();
}
$user->delete();
return Redirect::back();
}
$user = Auth::user();
$admin = User::whereAdmin(1)->first();
$mp3s = $user->mp3s()->get();
$mp4s = $user->mp4s()->get();
foreach ($mp3s as $mp3) {
Vote::whereObj('MP3')->whereObjId($mp3->id)->whereUserId($user->id)->delete();
if ($del) {
$mp3->delete();
File::delete(Config::get('site.mp3_upload_path') . '/' . $mp3->mp3name);
File::delete(Config::get('site.image_upload_path') . '/' . $mp3->image);
File::delete(Config::get('site.image_upload_path') . '/thumbs/' . $mp3->image);
File::delete(Config::get('site.image_upload_path') . '/tiny/' . $mp3->image);
} else {
$mp3->user_id = $admin->id;
$mp3->save();
}
}
foreach ($mp4s as $mp4) {
Vote::whereObj('MP4')->whereObjId($mp4->id)->whereUserId($user->id)->delete();
if ($del) {
$mp4->delete();
} else {
$mp4->user_id = $admin->id;
$mp4->save();
}
}
Auth::logout();
$user->delete();
Cache::flush();
$aff = '';
if ($del) {
$aff = 'Mizik ak Videyo ou yo efase tou avèk siskè. Ou ka <a href="/register">kreye yon nouvo kont</a> nenpòt lè ou vle.';
}
return Redirect::to('/')->withMessage('Kont ou an efase avèk sikè. ' . $aff);
}