Click here to Skip to main content
15,891,657 members

stevic - Professional Profile



Summary

Follow on Twitter LinkedIn      Blog RSS
40
Author
70
Authority
31
Debator
4
Editor
1
Enquirer
9
Organiser
331
Participant
Freelance Web developer, Artificial Intelligence and Science enthusiast

 

Reputation

Weekly Data. Recent events may not appear immediately. For information on Reputation please see the FAQ.

Privileges

Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Have the ability to send direct emails to members in the forumsProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

Actions with a green tick can be performed by this member.


 
GeneralExample of 'Advance Where' in Laravel Pin
stevic6-Nov-14 16:45
professionalstevic6-Nov-14 16:45 
Suppose you have 'article' table in your database, and you're going to conduct a Search action WHERE your article is published AND your Title contains your keyword OR your Content contains your keyword. some may do code like this
PHP
//MyModel.php
public static function getSearch($search=null){
    
    //is_publish : 0 = pending, 1 = published
    $result = DB::table('article')
        ->where('article.is_publish','1')
        ->where('article.title','LIKE','%'.$search.'%')
        ->orWhere('article.content', 'LIKE','%'.$search.'%')
        ->select('*')
        ->orderBy('article.id', 'desc')->paginate(10);

    return $result;
}


The above code will result a raw Query like below :
SQL
SELECT * FROM `article` WHERE `article`.`is_publish` = '1' AND `article`.`title` LIKE '%search%' OR `article`.`content` LIKE '%search%'...


That's a correct Query but will give you wrong result as your Published and unPublished article will be showing. We can fix it Using Advance Where of Query Builder in Laravel .
PHP
public static function getSearch($search=null){
    
    //is_publish : 0 = pending, 1 = published
    $result = DB::table('article')
        ->where('article.is_publish','1')
        ->where(function($query) use ($search){

            $query->where('article.title','LIKE','%'.$search.'%')
                  ->orWhere('article.content', 'LIKE','%'.$search.'%');
        })
        ->select('*')
        ->orderBy('article.id', 'desc')->paginate(10);

    return $result;
}


Code above will result Query string as follow :
SQL
SELECT * FROM `article` WHERE `article`.`is_publish` = '1' AND (`article`.`title` LIKE '%search%' OR `article`.`content` LIKE '%search%')...

This will give you the correct result. CMIIW

Reference
Freelance makes perfect | Sains & Teknologi


modified 6-Nov-14 22:52pm.

GeneralInstall Node.js, NPM and Express in Ubuntu 12.04 Pin
stevic9-Apr-14 7:21
professionalstevic9-Apr-14 7:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.