public function massUpdate(ArticlesRequest $request)
    {
        $this->authorize('otherUpdate', $this->model);

        $articles = $this->model->whereIn('id', $request->articles);
        $messages = [];

        switch ($request->mass_action) {
            case 'published':
                if (! $articles->update(['state' => 'published'])) {
                    $messages[] = 'unable to published';
                }
                break;
            case 'unpublished':
                if (! $articles->update(['state' => 'unpublished'])) {
                    $messages[] = 'unable to unpublished';
                }
                break;
            case 'draft':
                if (! $articles->update(['state' => 'draft'])) {
                    $messages[] = 'unable to draft';
                }
                break;
            case 'on_mainpage':
                if (! $articles->update(['on_mainpage' => 1])) {
                    $messages[] = 'unable to mainpage';
                }
                break;
            case 'not_on_mainpage':
                if (! $articles->update(['on_mainpage' => 0])) {
                    $messages[] = 'unable to not_on_mainpage';
                }
                break;
            case 'allow_com':
                if (! $articles->update(['allow_com' => 1])) {
                    $messages[] = 'unable to allow_com';
                }
                break;
            case 'disallow_com':
                if (! $articles->update(['allow_com' => 0])) {
                    $messages[] = 'unable to disallow_com';
                }
                break;
            case 'currdate':
                $articles->timestamps = false;
                if (! $articles->update(['created_at' => date('Y-m-d H:i:s'), 'updated_at' => null])) {
                    $messages[] = 'unable to currdate';
                }
                $articles->timestamps = true;
                break;
            case 'delete':
                if (! $articles->get()->each->delete()) {
                    $messages[] = 'unable to delete';
                }
                break;
            case 'delete_drafts':
                if (! $articles->where('state', 'draft')->get()->each->delete()) {
                    $messages[] = 'unable to delete_drafts';
                }
                break;
        }

        $message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';

        return $this->makeRedirect(true, 'admin.articles.index', $message);
    }
public function massUpdate(ArticlesRequest $request)
    {
        $this->authorize('otherUpdate', $this->model);

        $articles = $this->model->whereIn('id', $request->articles);
        $messages = [];

        switch ($request->mass_action) {
            case 'published':
                if (! $articles->update(['state' => 'published'])) {
                    $messages[] = 'unable to published';
                }
                break;
            case 'unpublished':
                if (! $articles->update(['state' => 'unpublished'])) {
                    $messages[] = 'unable to unpublished';
                }
                break;
            case 'draft':
                if (! $articles->update(['state' => 'draft'])) {
                    $messages[] = 'unable to draft';
                }
                break;
            case 'on_mainpage':
                if (! $articles->update(['on_mainpage' => 1])) {
                    $messages[] = 'unable to mainpage';
                }
                break;
            case 'not_on_mainpage':
                if (! $articles->update(['on_mainpage' => 0])) {
                    $messages[] = 'unable to not_on_mainpage';
                }
                break;
            case 'allow_com':
                if (! $articles->update(['allow_com' => 1])) {
                    $messages[] = 'unable to allow_com';
                }
                break;
            case 'disallow_com':
                if (! $articles->update(['allow_com' => 0])) {
                    $messages[] = 'unable to disallow_com';
                }
                break;
            case 'currdate':
                $articles->timestamps = false;
                if (! $articles->update(['created_at' => date('Y-m-d H:i:s'), 'updated_at' => null])) {
                    $messages[] = 'unable to currdate';
                }
                $articles->timestamps = true;
                break;
            case 'delete':
                if (! $articles->get()->each->delete()) {
                    $messages[] = 'unable to delete';
                }
                break;
            case 'delete_drafts':
                if (! $articles->where('state', 'draft')->get()->each->delete()) {
                    $messages[] = 'unable to delete_drafts';
                }
                break;
        }

        $message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';

        return $this->makeRedirect(true, 'admin.articles.index', $message);
    }
public function massUpdate ( ArticlesRequest $ request ) { $ this -> authorize ( 'otherUpdate' , $ this -> model ) ; $ articles = $ this -> model -> whereIn ( 'id' , $ request -> articles ) ; $ messages = [ ] ; switch ( $ request -> mass_action ) { case 'published' : if ( ! $ articles -> update ( [ 'state' => 'published' ] ) ) { $ messages [ ] = 'unable to published' ; } break ; case 'unpublished' : if ( ! $ articles -> update ( [ 'state' => 'unpublished' ] ) ) { $ messages [ ] = 'unable to unpublished' ; } break ; case 'draft' : if ( ! $ articles -> update ( [ 'state' => 'draft' ] ) ) { $ messages [ ] = 'unable to draft' ; } break ; case 'on_mainpage' : if ( ! $ articles -> update ( [ 'on_mainpage' => 1 ] ) ) { $ messages [ ] = 'unable to mainpage' ; } break ; case 'not_on_mainpage' : if ( ! $ articles -> update ( [ 'on_mainpage' => 0 ] ) ) { $ messages [ ] = 'unable to not_on_mainpage' ; } break ; case 'allow_com' : if ( ! $ articles -> update ( [ 'allow_com' => 1 ] ) ) { $ messages [ ] = 'unable to allow_com' ; } break ; case 'disallow_com' : if ( ! $ articles -> update ( [ 'allow_com' => 0 ] ) ) { $ messages [ ] = 'unable to disallow_com' ; } break ; case 'currdate' : $ articles -> timestamps = false ; if ( ! $ articles -> update ( [ 'created_at' => date ( 'Y-m-d H:i:s' ) , 'updated_at' => null ] ) ) { $ messages [ ] = 'unable to currdate' ; } $ articles -> timestamps = true ; break ; case 'delete' : if ( ! $ articles -> get ( ) -> each -> delete ( ) ) { $ messages [ ] = 'unable to delete' ; } break ; case 'delete_drafts' : if ( ! $ articles -> where ( 'state' , 'draft' ) -> get ( ) -> each -> delete ( ) ) { $ messages [ ] = 'unable to delete_drafts' ; } break ; } $ message = empty ( $ messages ) ? 'msg.complete' : 'msg.complete_but_null' ; return $ this -> makeRedirect ( true , 'admin.articles.index' , $ message ) ; }
Mass updates to Article.

@param  \BBCMS\Http\Requests\Admin\ArticlesRequest  $request
@param  \BBCMS\Models\Article  $articles
@return \Illuminate\Http\Response
Mass updates to Article .