public function customModelAction($modelName)
	{
		$config = app('itemconfig');
		$actionFactory = app('admin_action_factory');
		$actionName = $this->request->input('action_name', false);
		$dataTable = app('admin_datatable');

		//get the sort options and filters
		$page = $this->request->input('page', 1);
		$sortOptions = $this->request->input('sortOptions', array());
		$filters = $this->request->input('filters', array());

		//get the prepared query options
		$prepared = $dataTable->prepareQuery(app('db'), $page, $sortOptions, $filters);

		//get the action and perform the custom action
		$action = $actionFactory->getByName($actionName, true);
		$result = $action->perform($prepared['query']);

		//if the result is a string, return that as an error.
		if (is_string($result))
		{
			return response()->json(array('success' => false, 'error' => $result));
		}
		//if it's falsy, return the standard error message
		else if (!$result)
		{
			$messages = $action->getOption('messages');

			return response()->json(array('success' => false, 'error' => $messages['error']));
		}
		else
		{
			$response = array('success' => true);

			//if it's a download response, flash the response to the session and return the download link
			if (is_a($result, 'Symfony\Component\HttpFoundation\BinaryFileResponse'))
			{
				$file = $result->getFile()->getRealPath();
				$headers = $result->headers->all();
				$this->session->put('administrator_download_response', array('file' => $file, 'headers' => $headers));

				$response['download'] = route('admin_file_download');
			}
			//if it's a redirect, put the url into the redirect key so that javascript can transfer the user
			else if (is_a($result, '\Illuminate\Http\RedirectResponse'))
			{
				$response['redirect'] = $result->getTargetUrl();
			}

			return response()->json($response);
		}
	}
public function customModelAction($modelName)
	{
		$config = app('itemconfig');
		$actionFactory = app('admin_action_factory');
		$actionName = $this->request->input('action_name', false);
		$dataTable = app('admin_datatable');

		//get the sort options and filters
		$page = $this->request->input('page', 1);
		$sortOptions = $this->request->input('sortOptions', array());
		$filters = $this->request->input('filters', array());

		//get the prepared query options
		$prepared = $dataTable->prepareQuery(app('db'), $page, $sortOptions, $filters);

		//get the action and perform the custom action
		$action = $actionFactory->getByName($actionName, true);
		$result = $action->perform($prepared['query']);

		//if the result is a string, return that as an error.
		if (is_string($result))
		{
			return response()->json(array('success' => false, 'error' => $result));
		}
		//if it's falsy, return the standard error message
		else if (!$result)
		{
			$messages = $action->getOption('messages');

			return response()->json(array('success' => false, 'error' => $messages['error']));
		}
		else
		{
			$response = array('success' => true);

			//if it's a download response, flash the response to the session and return the download link
			if (is_a($result, 'Symfony\Component\HttpFoundation\BinaryFileResponse'))
			{
				$file = $result->getFile()->getRealPath();
				$headers = $result->headers->all();
				$this->session->put('administrator_download_response', array('file' => $file, 'headers' => $headers));

				$response['download'] = route('admin_file_download');
			}
			//if it's a redirect, put the url into the redirect key so that javascript can transfer the user
			else if (is_a($result, '\Illuminate\Http\RedirectResponse'))
			{
				$response['redirect'] = $result->getTargetUrl();
			}

			return response()->json($response);
		}
	}
public function customModelAction ( $ modelName ) { $ config = app ( 'itemconfig' ) ; $ actionFactory = app ( 'admin_action_factory' ) ; $ actionName = $ this -> request -> input ( 'action_name' , false ) ; $ dataTable = app ( 'admin_datatable' ) ; //get the sort options and filters $ page = $ this -> request -> input ( 'page' , 1 ) ; $ sortOptions = $ this -> request -> input ( 'sortOptions' , array ( ) ) ; $ filters = $ this -> request -> input ( 'filters' , array ( ) ) ; //get the prepared query options $ prepared = $ dataTable -> prepareQuery ( app ( 'db' ) , $ page , $ sortOptions , $ filters ) ; //get the action and perform the custom action $ action = $ actionFactory -> getByName ( $ actionName , true ) ; $ result = $ action -> perform ( $ prepared [ 'query' ] ) ; //if the result is a string, return that as an error. if ( is_string ( $ result ) ) { return response ( ) -> json ( array ( 'success' => false , 'error' => $ result ) ) ; } //if it's falsy, return the standard error message else if ( ! $ result ) { $ messages = $ action -> getOption ( 'messages' ) ; return response ( ) -> json ( array ( 'success' => false , 'error' => $ messages [ 'error' ] ) ) ; } else { $ response = array ( 'success' => true ) ; //if it's a download response, flash the response to the session and return the download link if ( is_a ( $ result , 'Symfony\Component\HttpFoundation\BinaryFileResponse' ) ) { $ file = $ result -> getFile ( ) -> getRealPath ( ) ; $ headers = $ result -> headers -> all ( ) ; $ this -> session -> put ( 'administrator_download_response' , array ( 'file' => $ file , 'headers' => $ headers ) ) ; $ response [ 'download' ] = route ( 'admin_file_download' ) ; } //if it's a redirect, put the url into the redirect key so that javascript can transfer the user else if ( is_a ( $ result , '\Illuminate\Http\RedirectResponse' ) ) { $ response [ 'redirect' ] = $ result -> getTargetUrl ( ) ; } return response ( ) -> json ( $ response ) ; } }
POST method for handling custom model actions

@param string		$modelName

@return JSON
POST method for handling custom model actions