app/Http/Controllers/AppController.php
/**
     *
     * Find enterprise and user thanks based in keywords given by the user.
     *
     * @param Request $request
     *
     * @return Response
     * 
     */
Find enterprise and user thanks based in keywords given by the user.
@param Request $request

@return Response
Find enterprise and user thanks based in keywords given by the user . @param Request $request @return Response
public function findThanks(Request $request)
    {
        $usersThanks = DB::table('user_thanks')->join('users', 'users.id', '=', 'user_thanks.user_id')->select('receiptName AS name', 'content', DB::raw("'people' AS logo"), 'hash', DB::raw('DATE_FORMAT(thanksDateTime, "%d/%m/%Y") as date'))->where([['user_id', '=', Auth::user()->id], ['content', 'LIKE', "%{$request->search}%"]])->orderBy('thanksDateTime', 'desc')->get();
        $enterprisesThanks = DB::table('enterprise_thanks')->join('enterprises', 'enterprises.id', '=', 'enterprise_thanks.enterprise_id')->select('name', 'content', 'logo', 'hash', DB::raw('DATE_FORMAT(thanksDateTime, "%d/%m/%Y") as date'))->where([['user_id', '=', Auth::user()->id], ['content', 'LIKE', "%{$request->search}%"]])->orderBy('thanksDateTime', 'desc')->get();
        $allThanks = $usersThanks->merge($enterprisesThanks);
        $data = array(
            'enterprises' => Enterprise::all(),
            'allThanks' => $allThanks,
            'user' => User::select('registerType')->where('id', '=', Auth::user()->id)->get()            
        );
        return view('app.index')->with('data', $data);        
    }
public function findThanks ( Request $ request ) { $ usersThanks = DB :: table ( 'user_thanks' ) -> join ( 'users' , 'users.id' , '=' , 'user_thanks.user_id' ) -> select ( 'receiptName AS name' , 'content' , DB :: raw ( " 'people' AS logo " ) , 'hash' , DB :: raw ( 'DATE_FORMAT(thanksDateTime, "%d/%m/%Y") as date' ) ) -> where ( [ [ 'user_id' , '=' , Auth :: user ( ) -> id ] , [ 'content' , 'LIKE' , " % { $ request -> search } % " ] ] ) -> orderBy ( 'thanksDateTime' , 'desc' ) -> get ( ) ; $ enterprisesThanks = DB :: table ( 'enterprise_thanks' ) -> join ( 'enterprises' , 'enterprises.id' , '=' , 'enterprise_thanks.enterprise_id' ) -> select ( 'name' , 'content' , 'logo' , 'hash' , DB :: raw ( 'DATE_FORMAT(thanksDateTime, "%d/%m/%Y") as date' ) ) -> where ( [ [ 'user_id' , '=' , Auth :: user ( ) -> id ] , [ 'content' , 'LIKE' , " % { $ request -> search } % " ] ] ) -> orderBy ( 'thanksDateTime' , 'desc' ) -> get ( ) ; $ allThanks = $ usersThanks -> merge ( $ enterprisesThanks ) ; $ data = array ( 'enterprises' => Enterprise :: all ( ) , 'allThanks' => $ allThanks , 'user' => User :: select ( 'registerType' ) -> where ( 'id' , '=' , Auth :: user ( ) -> id ) -> get ( ) ) ; return view ( 'app.index' ) -> with ( 'data' , $ data ) ; }
Find enterprise and user thanks based in keywords given by the user.
Find enterprise and user thanks based in keywords given by the user .