当前位置: 首页>>代码示例>>PHP>>正文


PHP Photo::create方法代码示例

本文整理汇总了PHP中Photo::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::create方法的具体用法?PHP Photo::create怎么用?PHP Photo::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Photo的用法示例。


在下文中一共展示了Photo::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Photo::create([]);
     }
 }
开发者ID:Defoncesko,项目名称:iamhungry,代码行数:7,代码来源:PhotosTableSeeder.php

示例2: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 500) as $index) {
         Photo::create(array('title' => $faker->sentence($nbwords = 5), 'image' => $faker->imageUrl($width = 640, $height = 480), 'gallery_id' => $faker->numberBetween(1, 50)));
     }
 }
开发者ID:arbuuuud,项目名称:gnt-aops,代码行数:7,代码来源:PhotosTableSeeder.php

示例3: postNewAdmin

 public function postNewAdmin()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Identity_No' => 'required', 'Email' => 'required|email', 'Phone_Number' => 'required', 'First_Name' => 'required', 'Last_Name' => 'required', 'Photo_1' => 'image|required', 'Photo_2' => 'image|required', 'Photo_3' => 'image|required'));
     if ($validator->fails()) {
         return Redirect::route('super-admin-new-admin-get')->withErrors($validator)->withInput()->with('globalerror', 'Sorry!! The Data was not Saved, please retry');
     } else {
         $identitynumber = Input::get('Identity_No');
         $email = Input::get('Email');
         $phonenumber = Input::get('Phone Numer');
         $firstname = Input::get('First_Name');
         $lastname = Input::get('Last_Name');
         $photo_1 = Input::file('Photo_1');
         $photo_2 = Input::file('Photo_2');
         $photo_3 = Input::file('Photo_3');
         //register the new user
         $newuser = User::create(array('Identity_No' => $identitynumber, 'First_Name' => $firstname, 'Last_Name' => $lastname, 'Password' => Hash::make($identitynumber), 'Active' => TRUE));
         //register the new user contact
         $newcontact = Contact::create(array('Email' => $email, 'Phone_Number' => $phonenumber));
         //Save the three Photos
         $photo1 = $this->postPhoto($photo_1);
         $photo2 = $this->postPhoto($photo_2);
         $photo3 = $this->postPhoto($photo_3);
         $newphotos = Photo::create(array('photo_1' => $photo1, 'photo_2' => $photo2, 'photo_3' => $photo3));
         //save the details to the students table
         $newadmin = Admin::create(array('Users_Id' => $newuser->id, 'Contacts_Id' => $newcontact->id, 'Photos_Id' => $newphotos->id));
         if ($newuser && $newcontact && $newphotos && $newadmin) {
             return Redirect::route('super-admin-new-admin-get')->with('globalsuccess', 'New Admin Details Have been Added');
         }
     }
 }
开发者ID:franqq,项目名称:Secure-Evoting-With-Face-Recognition,代码行数:31,代码来源:SuperAdminNavigationController.php

示例4: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 1) as $index) {
         Photo::create(['user_id' => 1, 'path' => 'img/image1.jpg', 'caption' => 'caption 1.']);
         Photo::create(['user_id' => 2, 'path' => 'img/image2.jpg', 'caption' => 'caption 2.']);
     }
 }
开发者ID:jbrown25,项目名称:PhotoSharing-PHP-backend,代码行数:8,代码来源:PhotosTableSeeder.php

示例5: run

 public function run()
 {
     $faker = Faker::create();
     $usersId = DB::table('users')->lists('id');
     $albumsId = DB::table('albums')->lists('id');
     $imgNames = ['test.png', 'sample.jpg', 'default.jpg', 'preview.png'];
     for ($i = 0; $i < 100; $i++) {
         Photo::create(['title' => $faker->word(), 'img_name' => $imgNames[rand(0, sizeof($imgNames) - 1)], 'author_id' => $usersId[rand(0, sizeof($usersId) - 1)], 'album_id' => $albumsId[rand(0, sizeof($albumsId) - 1)]]);
     }
 }
开发者ID:renankabal,项目名称:image-manager-system,代码行数:10,代码来源:PhotosTableSeeder.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     if ($this->photo->isValid($input)) {
         $mime = $input['file']->getMimeType();
         $fileName = time() . "." . strtolower($input['file']->getClientOriginalExtension());
         $image = Image::make($input['file']->getRealPath());
         $this->upload_s3($image, $fileName, $mime, "high");
         $image->resize(400, 300);
         $this->upload_s3($image, $fileName, $mime, "low");
         Photo::create(['title' => Input::get('title'), 'file' => $fileName]);
         Session::flash('exito', 'La foto se ha subido con éxito');
         return Redirect::route('photo.index');
     } else {
         Session::flash('error', 'Se ha producido un error al subir la imagen');
         return Redirect::back()->withInput()->withErrors($this->photo->messages);
     }
 }
开发者ID:antonrodin,项目名称:amazon-s3-laravel,代码行数:23,代码来源:PhotoController.php

示例7: testMorph

 public function testMorph()
 {
     $user = User::create(array('name' => 'John Doe'));
     $client = Client::create(array('name' => 'Jane Doe'));
     $photo = Photo::create(array('url' => 'http://graph.facebook.com/john.doe/picture'));
     $photo = $user->photos()->save($photo);
     $this->assertEquals(1, $user->photos->count());
     $this->assertEquals($photo->id, $user->photos->first()->id);
     $user = User::find($user->_id);
     $this->assertEquals(1, $user->photos->count());
     $this->assertEquals($photo->id, $user->photos->first()->id);
     $photo = Photo::create(array('url' => 'http://graph.facebook.com/jane.doe/picture'));
     $client->photo()->save($photo);
     $this->assertNotNull($client->photo);
     $this->assertEquals($photo->id, $client->photo->id);
     $client = Client::find($client->_id);
     $this->assertNotNull($client->photo);
     $this->assertEquals($photo->id, $client->photo->id);
     $photo = Photo::first();
     $this->assertEquals($photo->imageable->name, $user->name);
     $user = User::with('photos')->find($user->_id);
     $relations = $user->getRelations();
     $this->assertTrue(array_key_exists('photos', $relations));
     $this->assertEquals(1, $relations['photos']->count());
     $photos = Photo::with('imageable')->get();
     $relations = $photos[0]->getRelations();
     $this->assertTrue(array_key_exists('imageable', $relations));
     $this->assertInstanceOf('User', $relations['imageable']);
     $relations = $photos[1]->getRelations();
     $this->assertTrue(array_key_exists('imageable', $relations));
     $this->assertInstanceOf('Client', $relations['imageable']);
 }
开发者ID:danielheyman,项目名称:TechDimeProjects,代码行数:32,代码来源:RelationsTest.php

示例8: postEditEvent

 public function postEditEvent()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Id' => 'required', 'Title' => 'required|max:200', 'Description' => 'required', 'Date' => 'required', 'First_Name' => 'required|max:120', 'Last_Name' => 'required|max:120', 'Pic' => 'image|max:3000', 'Room' => 'required'));
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput()->with('global', 'Sorry!! Your Event was not edited, please retry.');
     } else {
         $id = Input::get('Id');
         $title = Input::get('Title');
         $description = Input::get('Description');
         $firstname = Input::get('First_Name');
         $lastname = Input::get('Last_Name');
         $date = Input::get('Date');
         $file = Input::file('Pic');
         $roomid = Input::get('Room');
         if (Auth::user()) {
             $organiserid = Auth::user()->id;
         } else {
             $organiserid = 0;
         }
         $eventedit = Lecture::where('id', '=', $id);
         $pic_id = 0;
         //post photo
         if ($file != null) {
             //photos validation
             $destinationPath = 'pics';
             $ext = $file->guessClientExtension();
             // Get real extension according to mime type
             $fullname = $file->getClientOriginalName();
             // Client file name, including the extension of the client
             $hashname = date('H.i.s') . '-' . md5($fullname) . '.' . $ext;
             // Hash processed file name, including the real extension
             $upload_success = $file->move($destinationPath, $hashname);
             //Set the photo path name to hashname
             $pic = Photo::create(array('path' => 'pics/' . $hashname));
             if ($pic) {
                 $pic_id = $pic->id;
             }
         }
         if ($eventedit->count()) {
             $eventedit = $eventedit->first();
             //edit the details
             $eventedit->organiser_id = $organiserid;
             $eventedit->room_id = $roomid;
             $eventedit->pic_id = $pic_id;
             $eventedit->title = $title;
             $eventedit->overview = $description;
             $eventedit->date = $date;
             $presenter_edit = Presenter::where('id', '=', $eventedit->presenter_id);
             if ($presenter_edit->count()) {
                 $presenter_edit = $presenter_edit->first();
             }
             $presenter_edit->firstname = $firstname;
             $presenter_edit->lastname = $lastname;
             $saved1 = $presenter_edit->save();
             $saved2 = $eventedit->save();
             return View::make('organiser.success');
         }
     }
     return Redirect::back()->withInput()->with('global', 'Sorry!! Your Event was not edited, please retry.');
 }
开发者ID:franqq,项目名称:plmas,代码行数:61,代码来源:PostLectureController.php

示例9: postSingleupload

 public function postSingleupload($param_name = 'file', $return = 'ajax')
 {
     ## Upload gallery image
     $result = $this->uploadImage($param_name);
     ## Check response
     if ($result['result'] == 'error') {
         if (Request::ajax()) {
             return Response::json($result, 400);
         } else {
             return false;
         }
     }
     ## Make photo object
     $photo = Photo::create(array('name' => $result['filename'], 'gallery_id' => 0, 'title' => ''));
     ## All OK, return result
     $result['result'] = 'success';
     $result['image_id'] = $photo->id;
     $result['gallery_id'] = -1;
     $result['thumb'] = $photo->thumb();
     $result['full'] = $photo->full();
     if (Request::ajax() && $return == 'ajax') {
         return Response::json($result, 200);
     } else {
         return $photo;
     }
 }
开发者ID:Grapheme,项目名称:amway,代码行数:26,代码来源:admin_galleries.controller.php

示例10: add

 /**
  * undocumented function
  *
  * @return void
  * @author 
  **/
 public static function add(array $input)
 {
     return Photo::create($input);
 }
开发者ID:whiterun,项目名称:bagikasih-v2,代码行数:10,代码来源:Photo.php

示例11: create

 public function create($data, $filename, $visibility)
 {
     if ($data == '') {
         // attempt to overcome PHP bug that causes
         // the HTTP POST value to be empty
         // it seems that PHP is trying to urldecode the
         // raw HTTP POST string, but for big enough values
         // this causes a memory overflow and the data
         // item remains unset
         // Here we process the php://input stream directly.
         $vars = explode('&', file_get_contents('php://input'));
         foreach ($vars as $var) {
             $vardata = explode('=', $var);
             $key = $vardata[0];
             $value = $vardata[1];
             if ($key == 'data') {
                 $data = urldecode($value);
                 break;
             }
         }
     }
     if (!isset($_SESSION['user'])) {
         throw new Exception('Not authorized.');
     }
     if ($data == '') {
         echo "Data provided is empty. Dumping {$_POST} variable.\n";
         var_dump($_POST);
         throw new Exception('Data provided is empty.');
     }
     $filename = strtolower($filename);
     $extension = substr($filename, strrpos($filename, '.') + 1);
     switch ($extension) {
         case 'jpg':
         case 'gif':
         case 'png':
             break;
         default:
             throw new Exception('Unrecognized image type. Expected "jpg", "gif", or "png", but got "' . $extension . '".');
     }
     switch ($visibility) {
         case 'public':
         case 'private':
             break;
         default:
             throw new Exception('Invalid visibility; expected "public" or "private", but got "' . $visibility . '"');
     }
     $data = base64_decode($data);
     if ($data === false) {
         throw new Exception('Invalid data supplied: data is not base64-encoded.');
     }
     $im = @imagecreatefromstring($data);
     if ($im !== false) {
         $width = imagesx($im);
         $height = imagesy($im);
     } else {
         echo 'Warning: We believe this is not a valid image file, but we\'re uploading it anyway.';
         $width = 0;
         $height = 0;
     }
     $result = Photo::create($filename, $extension, strlen($data), $_SESSION['user']['id'], $width, $height);
     $id = $result['id'];
     $filename = $result['filename'];
     $uploadfile = 'uploads/' . $filename;
     if (file_exists($uploadfile)) {
         throw new Exception('File already exists.');
     }
     file_put_contents($uploadfile, $data);
     $taken = Photo::timeFromFile($uploadfile);
     Photo::update($id, $taken);
     echo 'File uploaded successfully.';
     Post::create($filename, $_SESSION['user']['id'], 'photo', $visibility, $taken);
 }
开发者ID:natureday1,项目名称:Life,代码行数:72,代码来源:photo.php

示例12: Photo

<div id="page-wrapper">
    <div class="container-fluid">
        <!-- Page Heading -->
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">
                    Blank Page
                    <small>Subheading</small>
                </h1>

                <?php 
$photo = new Photo();
$photo->photo_title = "fsdfsd";
$photo->create();
?>
                <ol class="breadcrumb">
                    <li>
                        <i class="fa fa-dashboard"></i>  <a href="index.html">Dashboard</a>
                    </li>
                    <li class="active">
                        <i class="fa fa-file"></i> Blank Page
                    </li>
                </ol>
            </div>
        </div>
        <!-- /.row -->
    </div>
    <!-- /.container-fluid -->
</div>
开发者ID:Frosty92,项目名称:PhotoGallery,代码行数:29,代码来源:admin_content.php

示例13: upload

 public static function upload($url, $gallery = NULL, $title = '')
 {
     $img_data = @file_get_contents($url);
     if (!$img_data) {
         return false;
     }
     $tmp_path = storage_path(md5($url));
     try {
         file_put_contents($tmp_path, $img_data);
     } catch (Exception $e) {
         echo 'Error #' . $e->getCode() . ':' . $e->getMessage() . "<br/>\n";
         echo 'In file: ' . $e->getFile() . ' (' . $e->getLine() . ')';
         die;
     }
     $file = new \Symfony\Component\HttpFoundation\File\UploadedFile($tmp_path, basename($url));
     ## Check upload & thumb dir
     $uploadPath = Config::get('site.galleries_photo_dir');
     $thumbsPath = Config::get('site.galleries_thumb_dir');
     if (!File::exists($uploadPath)) {
         File::makeDirectory($uploadPath, 0777, TRUE);
     }
     if (!File::exists($thumbsPath)) {
         File::makeDirectory($thumbsPath, 0777, TRUE);
     }
     ## Generate filename
     $fileName = time() . "_" . rand(1000, 1999) . '.' . $file->getClientOriginalExtension();
     #echo $fileName;
     ## Get images resize parameters from config
     $thumb_size = Config::get('site.galleries_thumb_size');
     $photo_size = Config::get('site.galleries_photo_size');
     ## Get image width & height
     $image = ImageManipulation::make($file->getRealPath());
     $w = $image->width();
     $h = $image->height();
     if ($thumb_size > 0) {
         ## Normal resize
         $thumb_resize_w = $thumb_size;
         $thumb_resize_h = $thumb_size;
     } else {
         ## Resize "by the smaller side"
         $thumb_size = abs($thumb_size);
         ## Resize thumb & full-size images "by the smaller side".
         ## Declared size will always be a minimum.
         $thumb_resize_w = $w > $h ? null : $thumb_size;
         $thumb_resize_h = $w > $h ? $thumb_size : null;
     }
     ## Resize thumb image
     $thumb_upload_success = ImageManipulation::make($file->getRealPath())->resize($thumb_resize_w, $thumb_resize_h, function ($constraint) {
         $constraint->aspectRatio();
         $constraint->upsize();
     })->save($thumbsPath . '/' . $fileName);
     if ($photo_size > 0) {
         ## Normal resize
         $image_resize_w = $photo_size;
         $image_resize_h = $photo_size;
     } else {
         ## Resize "by the smaller side"
         $photo_size = abs($photo_size);
         ## Resize full-size images "by the smaller side".
         ## Declared size will always be a minimum.
         $image_resize_w = $w > $h ? null : $photo_size;
         $image_resize_h = $w > $h ? $photo_size : null;
     }
     ## Resize full-size image
     $image_upload_success = ImageManipulation::make($file->getRealPath())->resize($image_resize_w, $image_resize_h, function ($constraint) {
         $constraint->aspectRatio();
         $constraint->upsize();
     })->save($uploadPath . '/' . $fileName);
     ## Delete original file
     unlink($file->getRealPath());
     ## Gallery - none, existed, new
     $gallery_id = 0;
     if (is_int($gallery) && $gallery > 0) {
         $gallery_id = $gallery;
     } elseif (is_string($gallery)) {
         $gal = Gallery::create(['name' => $gallery]);
         $gallery_id = $gal->id;
     }
     ## Create MySQL record
     $photo = Photo::create(array('name' => $fileName, 'gallery_id' => $gallery_id, 'title' => $title));
     return $photo;
 }
开发者ID:Grapheme,项目名称:amway,代码行数:82,代码来源:Photo.php

示例14: postNewVoter

 public function postNewVoter()
 {
     //verify the user input and create account
     $validator = Validator::make(Input::all(), array('Identity_No' => 'required', 'Email' => 'required|email', 'Phone_Number' => 'required', 'First_Name' => 'required', 'Last_Name' => 'required', 'Faculty' => 'required', 'Residence' => 'required', 'Photo_1' => 'image|required|mimes:jpeg,bmp,png', 'Photo_2' => 'image|required|mimes:jpeg,bmp,png', 'Photo_3' => 'image|required|mimes:jpeg,bmp,png'));
     if ($validator->fails()) {
         return Redirect::route('admin-new-voter-get')->withErrors($validator)->withInput()->with('globalerror', 'Sorry!! The Data was not Saved, please retry');
     } else {
         $identitynumber = Input::get('Identity_No');
         $email = Input::get('Email');
         $phonenumber = Input::get('Phone Numer');
         $firstname = Input::get('First_Name');
         $lastname = Input::get('Last_Name');
         $faculty_id = Input::get('Faculty');
         $residence_id = Input::get('Residence');
         $photo_1 = Input::file('Photo_1');
         $photo_2 = Input::file('Photo_2');
         $photo_3 = Input::file('Photo_3');
         //register the new user
         $newuser = User::create(array('Identity_No' => $identitynumber, 'First_Name' => $firstname, 'Last_Name' => $lastname, 'Password' => Hash::make($identitynumber), 'Active' => TRUE, 'User_Level' => 'voter'));
         //register the new user contact
         $newcontact = Contact::create(array('Email' => $email, 'Phone_Number' => $phonenumber));
         //Save the three Photos
         $photo1 = $this->postPhoto($photo_1, $newuser->id);
         $photo2 = $this->postPhoto($photo_2, $newuser->id);
         $photo3 = $this->postPhoto($photo_3, $newuser->id);
         $newphotos = Photo::create(array('photo_1' => $photo1, 'photo_2' => $photo2, 'photo_3' => $photo3));
         //save the details to the students table
         $newstudent = Student::create(array('Users_Id' => $newuser->id, 'Faculties_Id' => $faculty_id, 'Residences_Id' => $residence_id, 'Contacts_Id' => $newcontact->id, 'Photos_Id' => $newphotos->id, 'Active' => TRUE));
         if ($newuser && $newcontact && $newphotos && $newstudent) {
             //update the eigenfaces model with to include the new facedata
             putenv("PYTHONPATH=/usr/lib/python2.7");
             putenv("LD_LIBRARY_PATH=/usr/local/lib");
             //call python class to create the eigenfaces models from the existing photos
             exec("python /opt/lampp/htdocs/jkuatvs/eigensave.py /opt/lampp/htdocs/jkuatvs/photos");
             return Redirect::route('admin-new-voter-get')->with('globalsuccess', 'New Voter Details Have been Added');
         }
     }
 }
开发者ID:franqq,项目名称:Secure-Evoting-With-Face-Recognition,代码行数:38,代码来源:AdminNavigationController.php

示例15: addPhoto

 public function addPhoto($fname, $data)
 {
     $photo_path = $this->getPhotoPath();
     $photo = new Photo();
     $new_name = mktime() . rand(0, 1000);
     //rename(PHOTOS_TMP_PATH.$fname,$photo_path.$new_name);
     rename(PHOTOS_TMP_PATH . $fname . '_prev', $photo_path . $new_name . '_prev');
     $img = imagecreatefromjpeg(PHOTOS_TMP_PATH . $fname);
     //$im=Photo::createWatermark($img,WATERMARK,"arial.ttf",255,255,255,100);
     imagejpeg($img, $photo_path . $new_name);
     $tag = clearTextData($data['photo_type_' . $fname]);
     $title = clearTextData($data['photo_title_' . $fname]);
     $description = clearTextData($data['photo_desc_' . $fname]);
     $values = array('kind_id' => $this->_kind, 'object_id' => $this->id, 'tag' => $tag, 'name' => $new_name, 'title' => $title, 'description' => $description, 'created_on' => date("Y-m-d H:i:s"), 'status' => 0);
     $photo->create($values);
 }
开发者ID:alex731,项目名称:m12private,代码行数:16,代码来源:Realty.php


注:本文中的Photo::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。