public function __construct($structure, $rows, $searchTerm, $pagination) { // @todo: find a way to get rid of this dummy hack fix $laravel = app(); if (0 === strpos($laravel::VERSION, '5.')) { \URL::setRootControllerNamespace(''); } $this->structure = $structure; $this->rows = $rows; $currentPage = $pagination->currentPage(); $paginationCount = $pagination->perPage(); $totalPaginations = $pagination->lastPage(); $pagination = ['total' => $totalPaginations, 'current' => $currentPage, 'count' => $paginationCount]; $this->index_prefix($searchTerm); $this->index_content($rows, $pagination); $this->index_postfix($pagination, $searchTerm); return $this->html; }
public function __construct($structure, $apiController = null, $oldData = null, $id = null) { // @todo: find a way to get rid of this dummy hack fix $laravel = app(); if (0 === strpos($laravel::VERSION, '5.')) { \URL::setRootControllerNamespace(''); } $this->structure = $structure; $this->apiController = $apiController; $this->oldData = $oldData; $this->isDeleted = isset($oldData['deleted_at']) ? true : false; $this->id = $id; $this->formPrefix(); if (isset($structure['self'])) { $this->formContent($structure['self']); } if (isset($structure['relations'])) { $this->formContent($structure['relations']); } $this->formPostfix(); }
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ URL::setRootControllerNamespace('App\\Http\\Controllers'); Route::get('/', function () { return view('welcome'); }); Route::resource('exercise', 'ExerciseController'); Route::resource('muscle', 'MuscleController'); Route::resource('workoutPlan', 'WorkoutPlanController'); Route::resource('workout', 'WorkoutController'); Route::resource('muscleGroup', 'MuscleGroupController'); Route::post('workoutPlan/{id}/addWorkouts', 'WorkoutPlanController@addWorkouts'); Route::get('workoutPlan/{id}/createNewWorkout', 'WorkoutPlanController@createNewWorkout'); Route::post('workout/{id}/addExercises', 'WorkoutController@addExercises'); Route::get('exerciseWithInfo', 'ExerciseController@getAllWithInfo'); Route::get('workout/{id}/deleteWorkout', 'WorkoutController@deleteWorkout');
/** * Remove the specified resource from storage. * * @param int $id * @return Redirect */ public function destroy($id) { // @todo: find a way to get rid of this dummy hack fix $laravel = app(); if (0 === strpos($laravel::VERSION, '5.')) { \URL::setRootControllerNamespace(''); } $model = call_user_func([$this->structure['model'], 'find'], $id); $model->delete(); $url = action($this->structure['controller'] . "@index"); return \Redirect::to($url); }