Пример #1
0
 public function assignApple($appleId, $employeeId)
 {
     $apple = Apple::find($appleId);
     $sim = Apple::find($appleId)->sim;
     $apple->employee_id = $employeeId;
     $apple->save();
     $sim->employee_id = $employeeId;
     $sim->save();
     \Session::flash('applesuccess', 'Apple device successfully assigned');
     return redirect('employee/' . $employeeId);
 }
Пример #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     # First, create an array of all the apple types we want to associate users with
     # The *key* will be the apple type, and the *value* will be an array of users.
     $apples = ['fuji' => ['Jill'], 'golden_delicious' => ['Jill', 'Jamal'], 'red_delicious' => ['Jill', 'Jamal']];
     foreach ($apples as $type => $users) {
         $apple = \App\Apple::where('type', 'LIKE', $type)->first();
         if ($apple != null) {
             foreach ($users as $name) {
                 $user = \App\User::where('name', 'LIKE', $name)->first();
                 if ($user != null) {
                     $apple->users()->save($user);
                 }
             }
         }
     }
 }
Пример #3
0
 public function assignApple($id)
 {
     $apple = Apple::find($id);
     \Session::flash('apple', $apple);
     return redirect('sim');
 }