예제 #1
0
 public function testShouldNotResizeWhenImageIsSmallerThanBoxAndStretchIsFalse()
 {
     $resource = $this->getMockBuilder('Imanee\\ImageResource\\GDResource')->setMethods(['resize'])->getMock();
     $resource->expects($this->never())->method('resize');
     $this->model->setResource($resource);
     $this->model->resize(1200, 1200, true, false);
 }
예제 #2
0
 public function testShouldResize()
 {
     $resource = $this->getMockBuilder('Imanee\\ImageResource\\GDResource')->setMethods(['resize'])->getMock();
     $resource->expects($this->once())->method('resize')->with(200, 200);
     $this->model->setResource($resource);
     $this->model->resize(200, 200);
 }
예제 #3
0
 public function run()
 {
     //user id of 1
     $roger = new User();
     $roger->email = '*****@*****.**';
     $roger->password = '******';
     $roger->password_confirmation = 'password';
     $roger->first_name = 'Roger';
     $roger->last_name = 'Chin';
     $roger->birthday = '1991-01-11';
     $roger->zip = '78230';
     $roger->gender = 'M';
     $image = new Imanee(__DIR__ . '/../../../public/images/users/roger_headshot.jpg');
     $image->resize(200, 150)->write(__DIR__ . '/../../../public/images/users/roger_headshot.jpg');
     $roger->image = 'roger_headshot.jpg';
     $roger->confirmation_code = md5(uniqid(mt_rand(), true));
     $roger->confirmed = 1;
     $roger->save();
     //user id of 2
     $jerald = new User();
     $jerald->email = '*****@*****.**';
     $jerald->password = '******';
     $jerald->password_confirmation = 'password';
     $jerald->first_name = 'Jerald';
     $jerald->last_name = 'Saenz';
     $jerald->birthday = '1971-01-18';
     $jerald->zip = '78258';
     $jerald->gender = 'M';
     $image = new Imanee(__DIR__ . '/../../../public/images/users/jerald_headshot.jpg');
     $image->resize(200, 150)->write(__DIR__ . '/../../../public/images/users/jerald_headshot.jpg');
     $jerald->image = 'jerald_headshot.jpg';
     $jerald->confirmation_code = md5(uniqid(mt_rand(), true));
     $jerald->confirmed = 1;
     $jerald->save();
     //user id of 3
     $sakib = new User();
     $sakib->email = '*****@*****.**';
     $sakib->password = '******';
     $sakib->password_confirmation = 'password';
     $sakib->first_name = 'Sakib';
     $sakib->last_name = 'Shaikh';
     $sakib->birthday = '1984-09-02';
     $sakib->zip = '78015';
     $sakib->gender = 'M';
     $image = new Imanee(__DIR__ . '/../../../public/images/users/sakib_headshot.jpg');
     $image->resize(200, 150)->write(__DIR__ . '/../../../public/images/users/sakib_headshot.jpg');
     $sakib->image = 'sakib_headshot.jpg';
     $sakib->confirmation_code = md5(uniqid(mt_rand(), true));
     $sakib->confirmed = 1;
     $sakib->save();
 }
 public function validateAndSave($organization)
 {
     $validator = Validator::make(Input::all(), Organization::$rules);
     if ($validator->fails()) {
         $messages = $validator->errors();
         return Redirect::back()->withInput()->withErrors($messages);
     } else {
         $organization->name = Input::get('name');
         $organization->description = Input::get('description');
         if (Input::hasfile('image')) {
             Input::file('image')->move(__DIR__ . '/../../public/images/organizations', Input::file('image')->getClientOriginalName());
             $image = new Imanee(__DIR__ . '/../../public/images/organizations/' . Input::file('image')->getClientOriginalName());
             $image->resize(200, 150)->write(__DIR__ . '/../../public/images/organizations/' . Input::file('image')->getClientOriginalName());
             $organization->image = Input::file('image')->getClientOriginalName();
         }
         $organization->website = Input::get('website');
         $organization->user_id = Input::get('user_id');
         $result = $organization->save();
         $userRole = Role::where('name', 'admin')->first();
         Auth::user()->attachRole($userRole->id);
         Auth::user()->Roles()->sync(array(2));
         if ($result) {
             return Redirect::action('OrganizationsController@show', $organization->id);
         } else {
             return Redirect::back()->withInput();
         }
     }
 }
예제 #5
0
 public function validateAndSave($user)
 {
     $validator = Validator::make(Input::all(), User::$updateRules);
     if ($validator->fails()) {
         var_dump($validator->messages());
         die;
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         //$user = new User();
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->zip = Input::get('zip');
         $user->birthday = Input::get('birthday');
         $user->gender = Input::get('gender');
         $user->quote = Input::get('quote');
         $user->about = Input::get('about');
         $image = Input::file('image');
         // $user->image = $image->getClientOriginalName();
         // $image->move(__DIR__ . '/../../public/img');
         if (Input::hasfile('image')) {
             Input::file('image')->move(__DIR__ . '/../../public/images/users', Input::file('image')->getClientOriginalName());
             $image = new Imanee(__DIR__ . '/../../public/images/users/' . Input::file('image')->getClientOriginalName());
             $image->resize(200, 150)->write(__DIR__ . '/../../public/images/users/' . Input::file('image')->getClientOriginalName());
             $user->image = Input::file('image')->getClientOriginalName();
         }
         $result = $user->save();
         //dd($result,$user);
         if ($result) {
             return Redirect::action('UsersController@index');
         } else {
             return Redirect::back()->withInput();
         }
     }
 }