本文整理汇总了PHP中Dog::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Dog::where方法的具体用法?PHP Dog::where怎么用?PHP Dog::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dog
的用法示例。
在下文中一共展示了Dog::where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_thing
public function update_thing()
{
if (Request::isMethod('post')) {
$name = Input::get('name');
$age = Input::get('age');
$breed = Input::get('type');
$likes = Input::get('notes');
$token = Input::get('token');
$owner_id = Input::get('id');
$picture = Input::file('picture');
$validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id, 'age' => $age, 'picture' => $picture), array('token' => 'required', 'owner_id' => 'required|integer', 'age' => 'integer', 'picture' => 'mimes:jpeg,bmp,png'));
if ($validator->fails()) {
$error_messages = $validator->messages()->all();
$response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
$response_code = 200;
} else {
$is_admin = $this->isAdmin($token);
if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
// check for token validity
if (is_token_active($owner_data->token_expiry) || $is_admin) {
$dog_data = Dog::where('owner_id', $owner_id)->first();
if ($dog_data) {
$dog = Dog::find($dog_data->id);
if ($name) {
$dog->name = $name;
}
if ($age) {
$dog->age = $age;
}
if ($breed) {
$dog->breed = $breed;
}
if ($likes) {
$dog->likes = $likes;
}
if (Input::hasFile('picture')) {
// upload image
$file_name = time();
$file_name .= rand();
$file_name = sha1($file_name);
$ext = Input::file('picture')->getClientOriginalExtension();
Input::file('picture')->move(public_path() . "/uploads", $file_name . "." . $ext);
$local_url = $file_name . "." . $ext;
// Upload to S3
if (Config::get('app.s3_bucket') != "") {
$s3 = App::make('aws')->get('s3');
$pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
$s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
$s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
} else {
$s3_url = asset_url() . '/uploads/' . $local_url;
}
$dog->image_url = $s3_url;
}
$dog->save();
$response_array = array('success' => true);
$response_code = 200;
} else {
$response_array = array('success' => false, 'error' => 'No Dog Found', 'error_code' => 405);
$response_code = 200;
}
} else {
$response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
$response_code = 200;
}
} else {
if ($is_admin) {
$response_array = array('success' => false, 'error' => 'Owner ID not Found', 'error_code' => 410);
} else {
$response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
}
$response_code = 200;
}
}
}
$response = Response::json($response_array, $response_code);
return $response;
}
示例2: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$singleDog = Dog::find($id);
$dogs = Dog::where('retired', '0')->where('banner', '1')->where('puppy', '0')->get();
$dads[''] = 'select';
$moms[''] = 'select';
foreach ($dogs as $dog) {
if ($dog->gender == 'Male') {
$dads[$dog->name] = $dog->name;
} else {
$moms[$dog->name] = $dog->name;
}
}
$data = ['moms' => $moms, 'dads' => $dads, 'singleDog' => $singleDog];
return View::make('dogs.edit')->with($data);
}