本文整理汇总了PHP中Build::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Build::find方法的具体用法?PHP Build::find怎么用?PHP Build::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Build
的用法示例。
在下文中一共展示了Build::find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBuildDeletePost
public function testBuildDeletePost()
{
$build = Build::find(2);
$data = array('confirm-delete' => '1');
$response = $this->call('POST', '/modpack/build/' . $build->id . '?action=delete', $data);
$this->assertRedirectedTo('modpack/view/' . $build->modpack->id);
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
//$this->call('UserTableSeeder');
$this->call('ModpackTableTestSeeder');
$this->call('ModTableTestSeeder');
$this->call('ClientTableTestSeeder');
$this->call('KeyTableTestSeeder');
DB::table('build_modversion')->delete();
$testbuild = Build::find(1);
//Add testmodversion to testbuild
$testbuild->modversions()->attach(1);
}
示例3: action_modify
/**
* AJAX Methods for Modpack Manager
**/
public function action_modify($action = null)
{
if (empty($action)) {
return Response::error('500');
}
switch ($action) {
case "version":
$affected = DB::table('build_modversion')->where('id', '=', Input::get('pivot_id'))->update(array('modversion_id' => Input::get('version')));
return Response::json(array('success' => 'Rows Affected: ' . $affected));
break;
case "delete":
$affected = DB::table('build_modversion')->where('id', '=', Input::get('pivot_id'))->delete();
return Response::json(array('success' => 'Rows Affected: ' . $affected));
break;
case "add":
$build = Build::find(Input::get('build'));
$mod = Mod::where('name', '=', Input::get('mod-name'))->first();
$ver = ModVersion::where('mod_id', '=', $mod->id)->where('version', '=', Input::get('mod-version'))->first();
$build->modversions()->attach($ver->id);
return Response::json(array('pretty_name' => $mod->pretty_name, 'version' => $ver->version));
break;
case "recommended":
$modpack = Modpack::find(Input::get('modpack'));
$new_version = Input::get('recommended');
$modpack->recommended = $new_version;
$modpack->save();
return Response::json(array("success" => "Updated " . $modpack->name . "'s recommended build to " . $new_version, "version" => $new_version));
break;
case "latest":
$modpack = Modpack::find(Input::get('modpack'));
$new_version = Input::get('latest');
$modpack->latest = $new_version;
$modpack->save();
return Response::json(array("success" => "Updated " . $modpack->name . "'s latest build to " . $new_version, "version" => $new_version));
break;
case "published":
$build = Build::find(Input::get('build'));
$published = Input::get('published');
$build->is_published = $published ? true : false;
$build->save();
return Response::json(array("success" => "Updated build " . $build->version . "'s published status."));
}
}
示例4: function
}
});
Route::filter('auth', function () {
if (Auth::guest()) {
return Redirect::to('login');
}
});
Route::filter('perm', function ($check) {
$perm = (array) Auth::user()->permission;
$perm = $perm['attributes'];
if (!$perm['solder_full'] && !$perm[$check]) {
return Redirect::to('dashboard')->with('permission', 'You do not have permission to access this area.');
}
});
Route::filter('modpack', function ($modpack) {
$perm = Auth::user()->permission;
if (!$perm->solder_full && !in_array($modpack, $perm->modpacks)) {
return Redirect::to('dashboard')->with('permission', 'You do not have permission to access this area.');
}
});
Route::filter('build', function ($build) {
$perm = Auth::user()->permission;
$build = Build::find($build);
if (empty($build)) {
return Redirect::to('dashboard');
}
$modpack = $build->modpack;
if (!$perm->solder_full && !in_array($modpack->id, $perm->modpacks)) {
return Redirect::to('dashboard')->with('permission', 'You do not have permission to access this area.');
}
});
示例5: anyModify
/**
* AJAX Methods for Modpack Manager
**/
public function anyModify($action = null)
{
if (!Request::ajax()) {
return Response::view('errors.missing', array(), 404);
}
if (empty($action)) {
return Response::view('errors.500', array(), 500);
}
switch ($action) {
case "version":
$version_id = Input::get('version');
$modversion_id = Input::get('modversion_id');
$affected = DB::table('build_modversion')->where('build_id', '=', Input::get('build_id'))->where('modversion_id', '=', $modversion_id)->update(array('modversion_id' => $version_id));
if ($affected == 0) {
if ($modversion_id != $version_id) {
$status = 'failed';
} else {
$status = 'aborted';
}
} else {
$status = 'success';
}
return Response::json(array('status' => $status, 'reason' => 'Rows Affected: ' . $affected));
break;
case "delete":
$affected = DB::table('build_modversion')->where('build_id', '=', Input::get('build_id'))->where('modversion_id', '=', Input::get('modversion_id'))->delete();
$status = 'success';
if ($affected == 0) {
$status = 'failed';
}
return Response::json(array('status' => $status, 'reason' => 'Rows Affected: ' . $affected));
break;
case "add":
$build = Build::find(Input::get('build'));
$mod = Mod::where('name', '=', Input::get('mod-name'))->first();
$ver = Modversion::where('mod_id', '=', $mod->id)->where('version', '=', Input::get('mod-version'))->first();
$affected = DB::table('build_modversion')->where('build_id', '=', $build->id)->where('modversion_id', '=', $ver->id)->get();
$duplicate = !empty($affected);
if ($duplicate) {
return Response::json(array('status' => 'failed', 'reason' => 'Duplicate Modversion found'));
} else {
$build->modversions()->attach($ver->id);
return Response::json(array('status' => 'success', 'pretty_name' => $mod->pretty_name, 'version' => $ver->version));
}
break;
case "recommended":
$modpack = Modpack::find(Input::get('modpack'));
$new_version = Input::get('recommended');
$modpack->recommended = $new_version;
$modpack->save();
Cache::forget('modpack.' . $modpack->slug);
return Response::json(array("success" => "Updated " . $modpack->name . "'s recommended build to " . $new_version, "version" => $new_version));
break;
case "latest":
$modpack = Modpack::find(Input::get('modpack'));
$new_version = Input::get('latest');
$modpack->latest = $new_version;
$modpack->save();
Cache::forget('modpack.' . $modpack->slug);
return Response::json(array("success" => "Updated " . $modpack->name . "'s latest build to " . $new_version, "version" => $new_version));
break;
case "published":
$build = Build::find(Input::get('build'));
$published = Input::get('published');
$build->is_published = $published ? true : false;
$build->save();
return Response::json(array("success" => "Updated build " . $build->version . "'s published status."));
case "private":
$build = Build::find(Input::get('build'));
$private = Input::get('private');
$build->private = $private ? true : false;
$build->save();
return Response::json(array("success" => "Updated build " . $build->version . "'s private status."));
}
}