/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Unit IDs
     $poundID = Unit::where('name', 'pound')->first()->id;
     $meterID = Unit::where('name', 'meter')->first()->id;
     $mileID = Unit::where('name', 'mile')->first()->id;
     /*************
      *** SQUAT ***
      *************/
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 1, 'set_order' => 1, 'weight_unit_id' => $poundID, 'weight' => 300, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 1, 'set_order' => 2, 'weight_unit_id' => $poundID, 'weight' => 300, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 1, 'set_order' => 3, 'weight_unit_id' => $poundID, 'weight' => 300, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 1, 'set_order' => 4, 'weight_unit_id' => $poundID, 'weight' => 300, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 1, 'set_order' => 5, 'weight_unit_id' => $poundID, 'weight' => 300, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     /**********************
      *** OVERHEAD PRESS ***
      **********************/
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 2, 'set_order' => 1, 'weight_unit_id' => $poundID, 'weight' => 130, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 2, 'set_order' => 2, 'weight_unit_id' => $poundID, 'weight' => 130, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 2, 'set_order' => 3, 'weight_unit_id' => $poundID, 'weight' => 130, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 2, 'set_order' => 4, 'weight_unit_id' => $poundID, 'weight' => 130, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 2, 'set_order' => 5, 'weight_unit_id' => $poundID, 'weight' => 130, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     /****************
      *** DEADLIFT ***
      ****************/
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 3, 'set_order' => 1, 'weight_unit_id' => $poundID, 'weight' => 345, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 5]);
     /****************
      *** PULL-UPS ***
      ****************/
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 4, 'set_order' => 1, 'weight_unit_id' => $poundID, 'weight' => null, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 10]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 4, 'set_order' => 2, 'weight_unit_id' => $poundID, 'weight' => null, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 10]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 4, 'set_order' => 3, 'weight_unit_id' => $poundID, 'weight' => null, 'distance_unit_id' => $meterID, 'distance' => null, 'time' => null, 'reps' => 10]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 5, 'set_order' => 1, 'weight_unit_id' => $poundID, 'weight' => null, 'distance_unit_id' => $mileID, 'distance' => 1.5, 'time' => 600, 'reps' => null]);
     DB::table('exercise_measurements')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'exercise_group_id' => 5, 'set_order' => 2, 'weight_unit_id' => $poundID, 'weight' => null, 'distance_unit_id' => $mileID, 'distance' => 1.5, 'time' => 600, 'reps' => null]);
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $types = \App\Models\BodyMeasurementType::orderBy('id')->get();
     $minTypeID = $types->first()->id;
     $maxTypeID = $types->last()->id;
     $unitIDs = \App\Models\Unit::validationIDs($types->find($this->request->get('body_measurement_type_id'))->unit_type);
     return ['body_measurement_type_id' => sprintf('required|integer|min:%d|max:%d', $minTypeID, $maxTypeID), 'value' => 'required|numeric|min:0', 'unit_id' => sprintf('required|integer|in:%s', $unitIDs)];
 }
 public function getAjaxListUnit($value = '')
 {
     $unit = Unit::all();
     return Datatables::of($unit)->addColumn('atasan', function ($unit) {
         return $unit['atasan']['singkatan'];
     })->addColumn('action', function ($unit) {
         return '<a href="' . route('hapus-personil') . '/' . $unit->id . '" class="btn btn-xs btn-danger"><i class="glyphicon glyphicon-trash"></i> Hapus</a>';
     })->make(true);
 }
 public function getPersonilEdit($value = '')
 {
     $unit = Unit::all();
     $jabatan = Jabatan::all();
     $atasan = Personil::all();
     $edit = Personil::where('id', $value)->firstOrFail();
     $url = 'personil/personil-edit';
     return view('personil.tambah', compact('unit', 'jabatan', 'atasan', 'edit', 'url'));
 }
 /**
  * @return mixed
  */
 public function store()
 {
     $input = \Request::all();
     $validator = \Validator::make($input, ['unit_id' => 'required', 'tenant_name' => 'required|max:255']);
     if ($validator->fails()) {
         \App::abort(400, $validator->messages()->first());
     }
     $tenant = new Tenant($input);
     $unit = Unit::find($input['unit_id']);
     $tenant = $unit->Tenants()->save($tenant);
     return \Response::json(['success' => true, 'message' => 'Tenant Created.', 'data' => $tenant]);
 }
 /**
  * Responds to GET::/user/goals/edit.
  *
  * @return body.edit_goal view with a prepopulated form for editing a goal.
  */
 public function getEdit($goalID)
 {
     $goal = \App\Models\Goal::find($goalID);
     if ($goal && $goal->user_id == \Auth::User()->id) {
         $types = \App\Models\BodyMeasurementType::lists('name', 'id');
         $units = \App\Models\Unit::lists('abbreviation', 'id');
         return view('body.edit_goal')->with('types', $types)->with('goal', $goal)->with('units', $units);
     } else {
         \Session::flash('goal_update_error', 'You are not authorized to update this goal');
         return redirect('/goals');
     }
 }
 public function actionOptionunit()
 {
     $id = Yii::$app->request->post('id');
     $count = Unit::find()->where(['id_bahagian' => $id])->count();
     $list = Unit::find()->where(['id_bahagian' => $id])->all();
     if ($count > 0) {
         foreach ($list as $list) {
             echo '<option value="' . $list->id_unit . '">' . $list->nama_unit . '</option>';
         }
     } else {
         echo '<option>Tiada Rekod</option>';
     }
 }
Exemple #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Unit::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 public function search($input)
 {
     $query = Unit::query();
     $columns = Schema::getColumnListing('units');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
Exemple #10
0
 public static function validationIDs($filter = -1)
 {
     $units = Unit::all(['id', 'unit_type']);
     $ids = [];
     foreach ($units as $unit) {
         if ($unit->unit_type & $filter) {
             $ids[] = $unit->id;
         }
     }
     $csv = '';
     for ($i = 0; $i < count($ids); $i++) {
         $csv = $csv . $ids[$i];
         if ($i != count($ids) - 1) {
             $csv .= ',';
         }
     }
     return $csv;
 }
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     \App\Models\Owner::saving(function ($owner) {
         if (empty($owner->owner_name)) {
             $owner->owner_name = null;
         }
         $owner->org_id = \Auth::User()->org_id;
         return $owner;
     });
     \App\Models\Property::saving(function ($property) {
         if (empty($property->property_name)) {
             $property->property_name = null;
         }
         $property->org_id = \Auth::User()->org_id;
         return $property;
     });
     \App\Models\Unit::saving(function ($unit) {
         if (empty($unit->unit_name)) {
             $unit->unit_name = null;
         }
         $unit->org_id = \Auth::User()->org_id;
         return $unit;
     });
     \App\Models\Tenant::saving(function ($tenant) {
         if (empty($tenant->tenant_name)) {
             $tenant->tenant_name = null;
         }
         $tenant->org_id = \Auth::User()->org_id;
         return $tenant;
     });
     \App\Models\Transaction::saving(function ($transaction) {
         $transaction->org_id = \Auth::User()->org_id;
         return $transaction;
     });
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Clear the DB first
     $con = Propel::getWriteConnection(GameTableMap::DATABASE_NAME);
     //$sql = "DELETE FROM game WHERE name<>'test'";
     $queries = array('DELETE FROM game');
     $tables = array('game_match', 'match_state', 'turn', 'empire_order', 'empire', 'territory_template');
     foreach ($tables as $t) {
         $queries[] = "ALTER TABLE {$t} AUTO_INCREMENT = 1";
     }
     foreach ($queries as $q) {
         $stmt = $con->prepare($q);
         $stmt->execute();
     }
     //$config->system->db->useDebug(true);
     // Create or use
     $game = null;
     $games = GameQuery::create()->filterByName('test%', Criteria::LIKE);
     $game_base_name = 'test';
     $game_name = $game_base_name . '_' . $games->count();
     $p_objs = json_decode(file_get_contents(Config::get('paths.games') . "/{$game_base_name}/empires.json"), false);
     $t_objs = json_decode(file_get_contents(Config::get('paths.games') . "/{$game_base_name}/territories.json"), false);
     $game = Game::create($game_name, 1861, 'spring');
     $game->loadEmpires($p_objs);
     $game->loadTerritories($t_objs);
     $game->save();
     // $texas   = Territory::findTerritoryByName($territories, 'Texas');
     // $sequoia = Territory::findTerritoryByName($territories, 'Sequoia');
     // $ohio    = Territory::findTerritoryByName($territories, 'Ohio');
     // print "Texas-Sequoia? " . ($texas->isNeighbour($sequoia) ? 'PASS':'******') . "\n";
     // print "Sequoia-Texas? " . ($sequoia->isNeighbour($texas) ? 'PASS':'******') . "\n";
     // print "Texas-Ohio? "    . ($texas->isNeighbour($ohio) ? 'FAIL':'PASS') . "\n";
     // Empires
     $red = EmpireQuery::create()->filterByGame($game)->filterByAbbr('RED')->findOne();
     $blue = EmpireQuery::create()->filterByGame($game)->filterByAbbr('BLU')->findOne();
     $green = EmpireQuery::create()->filterByGame($game)->filterByAbbr('GRN')->findOne();
     $match = Match::create($game, "Matt Test");
     $turn = $match->getCurrentTurn();
     print "\n" . $match . "\n";
     // Territories
     // Crate the $t_<territory> magic variables.
     $t_names = array('A', 'B', 'C', 'D', 'E');
     foreach ($t_names as $n) {
         $c = new Criteria();
         $c->add(TerritoryTemplateTableMap::COL_NAME, $n);
         $tt = $game->getGameTerritories($c);
         $varname = "t_" . strtolower($n);
         ${$varname} = StateQuery::create()->filterByTerritory($tt)->findOne();
     }
     print "{$t_a} neighbours:\n";
     $neighbours = $t_a->getTerritory()->getNeighbours();
     foreach ($neighbours as $n) {
         print "{$n}\n";
     }
     print "\n" . Unit::printUnitTable($match->getCurrentTurn());
     $case = 3;
     switch ($case) {
         case 1:
             // Test move conflict
             $turn->addOrder(Move::createNS($red, $t_a, $t_b));
             $turn->addOrder(Move::createNS($red, $t_a, $t_c));
             $turn->addOrder(Move::createNS($blue, $t_a, $t_b));
             $turn->addOrder(Move::createNS($green, $t_e, $t_d));
             $turn->save();
             break;
         case 2:
             // Test support
             $turn->addOrder(Move::createNS($red, $t_a, $t_b));
             $turn->addOrder(Move::createNS($blue, $t_b, $t_c));
             $turn->addOrder(Support::createNS($green, $t_a, $t_e, $t_b));
             $turn->save();
             break;
         case 3:
             //$config->system->db->useDebug(true);
             try {
                 $turn->addOrder(Order::interpretText('MOVE "A" "B"', $match, $red));
             } catch (\DiplomacyOrm\InvalidOrderException $e) {
                 print "[" . Config::get('ansi.red') . "Error" . Config::get('ansi.clear') . "]: Red cannot MOVE A-B: " . $e->getMessage() . "\n";
                 exit;
             } catch (DiplomacyOrm\TurnClosedToOrdersException $e) {
                 print "[" . Config::get('ansi.red') . "Error" . Config::get('ansi.clear') . "]: Some how the turn state is empty again: " . $e->getMessage() . "\n";
                 exit;
             }
             $turn->addOrder(Order::interpretText('SUPPORT "E" "A" "B"', $match, $green));
             $turn->save();
             break;
         case 4:
             // Test the case with multiple contendors stalemat. standoff.svg
             $turn->addOrder(Order::interpretText('MOVE "A" "B"', $match, $red));
             $turn->addOrder(Order::interpretText('SUPPORT "A" "F" "B"', $match, $red));
             $turn->addOrder(Order::interpretText('MOVE "I" "B"', $match, $green));
             $turn->addOrder(Order::interpretText('SUPPORT "E" "H" "B"', $match, $green));
             $turn->save();
             // RED and GREEN should loose in statemates, B should belong to BLUE
             break;
         case 5:
             $turn->addOrder(Order::interpretText('MOVE "E" "C"', $match, $green));
             break;
         case 6:
             // No orders
             $result = $match->getCurrentTurn()->processOrders();
             print $match . "\n";
             $result = $match->getCurrentTurn()->processOrders();
             $result = $match->getCurrentTurn()->processOrders();
             $result = $match->getCurrentTurn()->processOrders();
             break;
     }
     $match->getCurrentTurn()->printOrders();
     $result = $match->getCurrentTurn()->processOrders();
     //print "\n" . Unit::printUnitTable($match->getCurrentTurn());
     //$match->getCurrentTurn()->printOrders();
     //print_r($result->__toArray());
     //print json_encode($result->__toArray());
     if ($result->retreatsRequired()) {
         //print $result;
         $retreat = Retreat::createNS($blue, $t_b, $t_c);
         print "Adding retreat order: {$retreat}\n";
         $match->getCurrentTurn()->addOrder($retreat);
         print "----------------------------------------\n";
         print "After adding retreat order..\n";
         $match->getCurrentTurn()->printOrders();
         $result = $match->getCurrentTurn()->processOrders();
         print $result;
     }
     // Show which orders have failed, etc
     print "\n" . $match . "\n";
 }
Exemple #13
0
 public function getUnit()
 {
     return @$this->hasOne(Unit::className(), ['id' => 'category_id']);
 }
 /**
  * Responds to GET::/measurements/edit/{measurementID}. Returns the edit page
  * with existing measurement values already filled in.
  *
  * @param int $id The id of the measurement to edit.
  * @return body.edit_measurement view with measuremenet values already filled in
  */
 public function getEdit($id)
 {
     $measurement = \App\Models\BodyMeasurement::find($id);
     if ($measurement && \Auth::User()->id == $measurement->user_id) {
         $types = \App\Models\BodyMeasurementType::lists('name', 'id');
         $units = \App\Models\Unit::lists('abbreviation', 'id');
         return view('body.edit_measurement')->with('measurement', $measurement)->with('types', $types)->with('units', $units);
     } else {
         \Session::flash('mesaurement_update_error', 'You are not authorized to edit this measurement');
         return redirect('/measurements');
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('goals')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'name' => 'Gain Weight', 'user_id' => 1, 'body_measurement_type_id' => BodyMeasurementType::where('name', 'Weight')->first()->id, 'unit_id' => Unit::where('name', 'pound')->first()->id, 'value' => 90.90900000000001]);
 }
Exemple #16
0
 /**
  *
  * @param $id
  * @return Response
  */
 public function destroy($id)
 {
     $unit = Unit::findOrFail($id);
     $unit->delete();
     return \Response::json(['success' => true, 'message' => 'Unit Deleted.', 'data' => []]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Session::get('level') == '1' || Session::get('level') == '2' && Session::get('fingerprint') == md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'])) {
         $Unit = Unit::find(e($id));
         DB::transaction(function () use($Unit) {
             Unit::find($Unit->id)->delete();
         });
         return Redirect::to('unit');
     } else {
         return Redirect::to('/');
     }
 }
Exemple #18
0
use app\models\Category;
use app\models\Productmain;
use app\models\Unit;
/* @var $this yii\web\View */
/* @var $searchModel app\models\ProductsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Products';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="products-index">

    <h1><?php 
Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('เพิ่มรายการใหม่', ['create'], ['class' => 'btn btn-success fa fa-plus']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'panel' => ['before' => ' '], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => 'หมวดหมู่หลัก', 'format' => 'raw', 'value' => 'productmainname', 'filter' => Html::activeDropDownList($searchModel, 'productmain_id', ArrayHelper::map(Productmain::find()->asArray()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['label' => 'หมวดหมู่รอง', 'format' => 'raw', 'value' => 'Categoryname', 'filter' => Html::activeDropDownList($searchModel, 'category_id', ArrayHelper::map(Category::find()->asArray()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Select Category'])], 'sub_qty', ['label' => 'ชื่อหน่วยนับ', 'format' => 'raw', 'value' => 'unitname', 'filter' => Html::activeDropDownList($searchModel, 'productmain_id', ArrayHelper::map(Unit::find()->asArray()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['label' => 'จำนวนคงเหลือ', 'format' => 'raw', 'value' => 'unitname', 'filter' => \app\models\Inventorydetail::find()->where(['product_id' => $dataProvider->id])->sum('qty')], 'name', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
 public function getUnit()
 {
     return $this->hasOne(Unit::className(), ['id_unit' => 'id_unit']);
 }
 public function getTambahActifity()
 {
     $jenis_dokumen = Jenis_dokumen::all();
     $unit = Unit::all();
     return view('datamaster.tambah_actifity', compact('jenis_dokumen', 'unit'));
 }
Exemple #21
0
    </div>
    <div class="row">
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
        </div>
        <div class="col-md-2">
            <?php 
echo $form->field($model, 'sub_qty')->textInput();
?>
        </div>
        <div class="col-md-2">
           
            <?php 
echo $form->field($model, 'unit_id')->dropdownList(ArrayHelper::map(Unit::find()->all(), 'id', 'name'), ['id' => 'unit_id', 'prompt' => 'เลือกหน่วยนับ', 'required' => '']);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'qty')->textInput();
?>
        </div>
         <div class="col-md-6">
            <?php 
echo $form->field($model, 'price')->textInput();
?>
        </div>
    </div>
 /**
  * Responds to GET::/workouts requests
  *
  * @return workouts.create view with exercises and units data
  */
 public function create()
 {
     $exercises = Exercise::orderBy('name')->get(['id', 'name', 'description', 'exercise_type']);
     $units = Unit::filteredUnits(['weight' => Unit::$unitMassType, 'distance' => Unit::$unitDistanceType]);
     return view('workouts.create')->with('exercises', $exercises)->with('units', $units);
 }
Exemple #23
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $rules = [];
     $rules['exercise_groups'] = 'required|array';
     if (count($this->request->get('exercise_groups'))) {
         foreach ($this->request->get('exercise_groups') as $group_num => $group) {
             $groupName = "exercise_groups." . $group_num;
             $rules[$groupName . ".exercise_id"] = 'required|exists:exercises,id';
             $rules[$groupName . ".exercise_measurements"] = 'required|array';
             $massUnitIDs = Unit::validationIDs(Unit::$unitMassType);
             $distanceUnitIDs = Unit::validationIDs(Unit::$unitDistanceType);
             if (count($this->request->get('exercise_measurements') > 0)) {
                 foreach ($group['exercise_measurements'] as $measurement_num => $exercise_measurement) {
                     $rules = array_merge($rules, $this->exerciseMeasurementRules($group_num, $measurement_num, $massUnitIDs, $distanceUnitIDs));
                 }
             }
         }
     }
     return $rules;
 }
 public function getModalUpload(Request $request)
 {
     $jenis_id = $request->input('jenis');
     $checklist_id = $request->input('checklist');
     $unit_id = $request->input('unit');
     $actifity_id = $request->input('actifity');
     $actifity = Actifity::where('id', $actifity_id)->firstOrFail();
     $unit = unit::where('id', $unit_id)->firstOrFail();
     $jenis = Sub_jenis_dokumen::where('id', $jenis_id)->firstOrFail();
     $unit_tujuan = unit::all();
     $visibility = Visibility::all();
     // dd($unit);
     return view('checklist._upload-dokumen-modal', compact('jenis_id', 'jenis', 'checklist_id', 'actifity', 'unit', 'unit_tujuan', 'visibility'));
 }
Exemple #25
0
 /**
  * Finds the Unit model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Unit the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Unit::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }