Laravel - 选择框

时间:2017-08-29 10:12:33

标签: php laravel

我有以下选择框,其中列出了所有用户。我只需要列表用户哪个groupID = = 3我该怎么做?

提前致谢

<div class="form-group  " >
<label for="Staff" class=" control-label col-md-4 text-left"> Staff </label>
<div class="col-md-7">
<select name='Staff' rows='5' id='Staff' class='select2 '   ></select> 
</div> 
<div class="col-md-1">
</div>
</div> 

控制器

使用App \ Http \ Controllers \ controller;使用App \ Models \ Adminorders;使用Illuminate \ Http \ Request;使用Illuminate \ Pagination \ LengthAwarePaginator作为Paginator;使用Validator,Input,Redirect;

class AdminordersController extends Controller {

    protected $layout = "layouts.main";
    protected $data = array();  
    public $module = 'adminorders';
    static $per_page    = '10';

    public function __construct()
    {

        parent::__construct();
        $this->beforeFilter('csrf', array('on'=>'post'));
        $this->model = new Adminorders();
        $this->modelview = new  \App\Models\Orderdetail();
        $this->info = $this->model->makeInfo( $this->module);
        $this->access = $this->model->validAccess($this->info['id']);

        $this->data = array(
            'pageTitle' =>  $this->info['title'],
            'pageNote'  =>  $this->info['note'],
            'pageModule'=> 'adminorders',
            'return'    => self::returnUrl()

        );

        $this->data['subgrid']  = (isset($this->info['config']['subgrid']) ? $this->info['config']['subgrid'][0] : array()); 
    }

    public function getIndex( Request $request )
    {

        if($this->access['is_view'] ==0) 
            return Redirect::to('dashboard')
                ->with('messagetext', \Lang::get('core.note_restric'))->with('msgstatus','error');

        $sort = (!is_null($request->input('sort')) ? $request->input('sort') : 'SiparisID'); 
        $order = (!is_null($request->input('order')) ? $request->input('order') : 'asc');
        // End Filter sort and order for query 
        // Filter Search for query      
        $filter = '';   
        if(!is_null($request->input('search')))
        {
            $search =   $this->buildSearch('maps');
            $filter = $search['param'];
            $this->data['search_map'] = $search['maps'];
        } 


        $page = $request->input('page', 1);
        $params = array(
            'page'      => $page ,
            'limit'     => (!is_null($request->input('rows')) ? filter_var($request->input('rows'),FILTER_VALIDATE_INT) : static::$per_page ) ,
            'sort'      => $sort ,
            'order'     => $order,
            'params'    => $filter,
            'global'    => (isset($this->access['is_global']) ? $this->access['is_global'] : 0 )
        );
        // Get Query 
        $results = $this->model->getRows( $params );        

        // Build pagination setting
        $page = $page >= 1 && filter_var($page, FILTER_VALIDATE_INT) !== false ? $page : 1; 
        $pagination = new Paginator($results['rows'], $results['total'], $params['limit']); 
        $pagination->setPath('adminorders');

        $this->data['rowData']      = $results['rows'];
        // Build Pagination 
        $this->data['pagination']   = $pagination;
        // Build pager number and append current param GET
        $this->data['pager']        = $this->injectPaginate();  
        // Row grid Number 
        $this->data['i']            = ($page * $params['limit'])- $params['limit']; 
        // Grid Configuration 
        $this->data['tableGrid']    = $this->info['config']['grid'];
        $this->data['tableForm']    = $this->info['config']['forms'];   
        // Group users permission
        $this->data['access']       = $this->access;
        // Detail from master if any

        // Master detail link if any 
        $this->data['subgrid']  = (isset($this->info['config']['subgrid']) ? $this->info['config']['subgrid'] : array()); 
        // Render into template
        return view('adminorders.index',$this->data);
    }   



    function getUpdate(Request $request, $id = null)
    {

        if($id =='')
        {
            if($this->access['is_add'] ==0 )
            return Redirect::to('dashboard')->with('messagetext',\Lang::get('core.note_restric'))->with('msgstatus','error');
        }   

        if($id !='')
        {
            if($this->access['is_edit'] ==0 )
            return Redirect::to('dashboard')->with('messagetext',\Lang::get('core.note_restric'))->with('msgstatus','error');
        }               

        $row = $this->model->find($id);
        if($row)
        {
            $this->data['row'] =  $row;
        } else {
            $this->data['row'] = $this->model->getColumnTable('tb_orders'); 
        }
        $this->data['fields']       =  \SiteHelpers::fieldLang($this->info['config']['forms']);

        $relation_key = $this->modelview->makeInfo($this->info['config']['subform']['module']);
        $this->data['accesschild'] = $this->modelview->validAccess($relation_key['id']);    
        $this->data['relation_key'] = $relation_key['key'];
        $this->data['subform'] = $this->detailview($this->modelview ,  $this->info['config']['subform'] ,$id );
        $this->data['id'] = $id;
        return view('adminorders.form',$this->data);
    }   

    public function getShow( Request $request, $id = null)
    {

        if($this->access['is_detail'] ==0) 
        return Redirect::to('dashboard')
            ->with('messagetext', \Lang::get('core.note_restric'))->with('msgstatus','error');

        $row = $this->model->getRow($id);
        if($row)
        {
            $this->data['row'] =  $row;
            $this->data['fields']       =  \SiteHelpers::fieldLang($this->info['config']['grid']);
            $this->data['id'] = $id;
            $this->data['access']       = $this->access;
            $this->data['subgrid']  = (isset($this->info['config']['subgrid']) ? $this->info['config']['subgrid'] : array()); 
            $this->data['prevnext'] = $this->model->prevNext($id);
            return view('adminorders.view',$this->data);
        } else {
            return Redirect::to('adminorders')->with('messagetext','Record Not Found !')->with('msgstatus','error');                    
        }
    }   

    function postSave( Request $request)
    {

        $rules = $this->validateForm();
        $validator = Validator::make($request->all(), $rules);  
        if ($validator->passes()) {
            $data = $this->validatePost('tb_adminorders');

            $id = $this->model->insertRow($data , $request->input('SiparisID'));
            $this->detailviewsave( $this->modelview , $request->all() ,$this->info['config']['subform'] , $id) ;
            if(!is_null($request->input('apply')))
            {
                $return = 'adminorders/update/'.$id.'?return='.self::returnUrl();
            } else {
                $return = 'adminorders?return='.self::returnUrl();
            }

            // Insert logs into database
            if($request->input('SiparisID') =='')
            {
                \SiteHelpers::auditTrail( $request , 'New Data with ID '.$id.' Has been Inserted !');
            } else {
                \SiteHelpers::auditTrail($request ,'Data with ID '.$id.' Has been Updated !');
            }

            return Redirect::to($return)->with('messagetext',\Lang::get('core.note_success'))->with('msgstatus','success');

        } else {

            return Redirect::to('adminorders/update/'.$request->input('SiparisID'))->with('messagetext',\Lang::get('core.note_error'))->with('msgstatus','error')
            ->withErrors($validator)->withInput();
        }   

    }   

    public function postDelete( Request $request)
    {

        if($this->access['is_remove'] ==0) 
            return Redirect::to('dashboard')
                ->with('messagetext', \Lang::get('core.note_restric'))->with('msgstatus','error');
        // delete multipe rows 
        if(count($request->input('ids')) >=1)
        {
            $this->model->destroy($request->input('ids'));
            \DB::table('tb_orderdetail')->whereIn('SiparisID',$request->input('ids'))->delete();
            \SiteHelpers::auditTrail( $request , "ID : ".implode(",",$request->input('ids'))."  , Has Been Removed Successfull");
            // redirect
            return Redirect::to('adminorders?return='.self::returnUrl())
                ->with('messagetext', \Lang::get('core.note_success_delete'))->with('msgstatus','success'); 

        } else {
            return Redirect::to('adminorders?return='.self::returnUrl())
                ->with('messagetext','No Item Deleted')->with('msgstatus','error');             
        }

    }   

    public static function display( )
    {
        $mode  = isset($_GET['view']) ? 'view' : 'default' ;
        $model  = new Adminorders();
        $info = $model::makeInfo('adminorders');

        $data = array(
            'pageTitle' =>  $info['title'],
            'pageNote'  =>  $info['note']

        );

        if($mode == 'view')
        {
            $id = $_GET['view'];
            $row = $model::getRow($id);
            if($row)
            {
                $data['row'] =  $row;
                $data['fields']         =  \SiteHelpers::fieldLang($info['config']['grid']);
                $data['id'] = $id;
                return view('adminorders.public.view',$data);
            } 

        } else {

            $page = isset($_GET['page']) ? $_GET['page'] : 1;
            $params = array(
                'page'      => $page ,
                'limit'     =>  (isset($_GET['rows']) ? filter_var($_GET['rows'],FILTER_VALIDATE_INT) : 10 ) ,
                'sort'      => 'SiparisID' ,
                'order'     => 'asc',
                'params'    => '',
                'global'    => 1 
            );

            $result = $model::getRows( $params );
            $data['tableGrid']  = $info['config']['grid'];
            $data['rowData']    = $result['rows'];  

            $page = $page >= 1 && filter_var($page, FILTER_VALIDATE_INT) !== false ? $page : 1; 
            $pagination = new Paginator($result['rows'], $result['total'], $params['limit']);   
            $pagination->setPath('');
            $data['i']          = ($page * $params['limit'])- $params['limit']; 
            $data['pagination'] = $pagination;
            return view('adminorders.public.index',$data);          
        }


    }

    function postSavepublic( Request $request)
    {

        $rules = $this->validateForm();
        $validator = Validator::make($request->all(), $rules);  
        if ($validator->passes()) {
            $data = $this->validatePost('tb_orders');       
             $this->model->insertRow($data , $request->input('SiparisID'));
            return  Redirect::back()->with('messagetext','<p class="alert alert-success">'.\Lang::get('core.note_success').'</p>')->with('msgstatus','success');
        } else {

            return  Redirect::back()->with('messagetext','<p class="alert alert-danger">'.\Lang::get('core.note_error').'</p>')->with('msgstatus','error')
            ->withErrors($validator)->withInput();

        }   

    }   




}

0 个答案:

没有答案