public function postUpdateemp()
 {
     $inputs = Input::all();
     $employee = Employee::find($inputs['id']);
     if (is_object($employee)) {
         $photoNewName = $employee->emp_image;
         // upload photo
         if (Input::hasFile('photo')) {
             $photo = Input::file('photo');
             $photoNewName = date('YmdHis') . '.' . $photo->getClientOriginalExtension();
             if (file_exists('image/employee/' . $employee->emp_image)) {
                 File::delete('image/employee/' . $employee->emp_image);
             }
             $photo->move('image/employee', $photoNewName);
         }
         $employee->emp_name = $inputs['fullname'];
         $employee->emp_idcard = $inputs['cardid'];
         $employee->emp_address = $inputs['address'];
         $employee->emp_tel = $inputs['tel'];
         $employee->emp_lineid = $inputs['lineid'];
         $employee->emp_email = $inputs['email'];
         $employee->emp_image = $photoNewName;
         $employee->emp_username = $inputs['username'];
         $employee->emp_password = Hash::Make($inputs['password']);
         $employee->save();
         return Redirect::to('admin/employee/showallemployee')->with('alert', 'แก้ไขข้อมูลเรียบร้อยแล้ว');
     }
 }
 public function postUpdate()
 {
     $inputs = Input::all();
     $user = User::find($inputs['id']);
     //หา Data ก่อน คำสั่ง find ใช้กับ id
     if (is_object($user)) {
         $user->username = $inputs['username'];
         $user->password = !empty($inputs['password']) ? Hash::Make($inputs['password']) : $user->password;
         $user->fullname = $inputs['fullname'];
         $user->user_group = $inputs['group'];
         $user->save();
         return Redirect::to('admin/user')->with('message', 'Update Completed');
     }
 }
Exemple #3
0
 public function run()
 {
     /**
      * Checks if the `comments` table exists.
      * If it exists, delete it.
      */
     if (Schema::hasTable('comments')) {
         $this->command->info('Old table comments detected!');
         Schema::drop('comments');
         $this->command->info('Old table comments deleted!');
         /**
          * If after deletion the table still exists, then I'm f****d.
          */
         if (Schema::hasTable('comments')) {
             $this->command->info('Im f****d');
         }
     }
     /**
      * Checks if the `articles` table exists.
      * If it exists, delete it.
      */
     if (Schema::hasTable('articles')) {
         $this->command->info('Old table articles detected!');
         //            DB::table('articles')->delete();
         Schema::drop('articles');
         $this->command->info('Old table articles deleted!');
         /**
          * If after deletion the table still exists, then I'm f****d.
          */
         if (Schema::hasTable('articles')) {
             $this->command->info('Im f****d');
         }
     }
     /**
      * Checks if the `users` table exists.
      * If it exists, delete it.
      */
     if (Schema::hasTable('users')) {
         $this->command->info('Old table users detected!');
         //            DB::table('articles')->delete();
         Schema::drop('users');
         $this->command->info('Old table users deleted!');
         /**
          * If after deletion the table still exists, then I'm f****d.
          */
         if (Schema::hasTable('users')) {
             $this->command->info('Im f****d');
         }
     }
     /**
      * Recreate the articles table
      */
     Schema::create('users', function ($table) {
         $table->increments('id');
         //            $table->foreign('article_id')->references('id')->on('articles')->onDelete('cascade');
         $table->string('name');
         $table->string('email');
         $table->string('password');
         $table->string('remember_token');
         $table->timestamps();
     });
     $this->command->info('Recreation of users succeeded!');
     /**
      * Recreate the articles table
      */
     Schema::create('articles', function ($table) {
         $table->increments('id');
         $table->integer('user_id')->unsigned();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
         $table->string('title');
         $table->string('content');
         $table->timestamps();
     });
     $this->command->info('Recreation of articles succeeded!');
     /**
      * Recreate the comments table
      */
     Schema::create('comments', function ($table) {
         $table->increments('id');
         $table->integer('article_id')->unsigned();
         $table->foreign('article_id')->references('id')->on('articles')->onDelete('cascade');
         $table->string('content');
         $table->integer('user_id')->unsigned();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
         $table->timestamps();
     });
     $this->command->info('Recreation of comments succeeded!');
     /**
      * Insert columns into the table.
      */
     //        Schema::table('articles', function($table)
     //        {
     //
     //        });
     User::create(['email' => '*****@*****.**', 'name' => 'Hu Zheng', 'password' => Hash::Make('password')]);
     User::create(['email' => '*****@*****.**', 'name' => 'Your Daddy', 'password' => Hash::Make('password')]);
     Article::create(['title' => 'Hi!', 'user_id' => 1, 'content' => 'This is the very first article']);
     Article::create(['title' => 'Hi!', 'user_id' => 2, 'content' => 'This is the very second article']);
     Comment::create(['article_id' => 1, 'content' => 'This is the very first comment', 'user_id' => 1]);
     Comment::create(['article_id' => 1, 'content' => 'This is the very second comment', 'user_id' => 2]);
     Comment::create(['article_id' => 2, 'content' => 'This is the very third comment', 'user_id' => 2]);
     Comment::create(['article_id' => 1, 'content' => 'This is the very fourth comment', 'user_id' => 2]);
     Comment::create(['article_id' => 2, 'content' => 'This is the very fifth comment', 'user_id' => 1]);
 }
 public static function generateHash()
 {
     return Hash::Make(md5(openssl_random_pseudo_bytes(10)));
 }