mardi 22 septembre 2020

Searching for UTF-8 channels without UTF-8 letters in query

What is the best way to get non-utf8 results when slug contains UTF8 letters? (For example: When I type the slug "Zaidimai", select all from the database where like "Žaidimai" and "Zaidimai").

Current code:

$results = DB::table('channels') -> where([['name', 'like', '%' . $slug . '%'], ['status', '=', 'OK']]) -> orWhere([['slug', 'like', '%' . $slug . '%'], ['status', '=', 'OK']]) -> limit(3) -> get();

It works fine, but when I try to search for a channel by entering "Zaidimai" in the search bar, it doesn't show the channel I want (Žaidimai).



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2FVX9Hd
via IFTTT

lundi 21 septembre 2020

get correct data from array

i am trying to decode array. this is my array

array:4 [▼
  "_token" => "tgPAddbrf3hI5tBIQIGyFYe9Y5RpwCj3rpZG5uVf"
  "resident_id" => array:4 [▼
    117 => "117"
    114 => "114"
    116 => "116"
    118 => "118"
  ]
  "available" => array:1 [▼
    116 => "2020-09-22"
  ]
  "out_of_community" => array:1 [▼
    118 => "2020-09-22"
  ]
]

i am using foeach to get answer like

resident_id  available    out_of_community
116         "2020-09-22"  null
118           null        "2020-09-22"

is it possible from foreach. my code for it

foreach ($data as $key => $value) {
            $data['resident_id'] = $key;
            
            # code...
        }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZXZqZD
via IFTTT

Laravel 5.7.5 API Request Json

I am using laravel API Authentication it is authenticating with api_token successfully as form-data. When I pass a data as Content_Type application/json. I am not receiving the Json data it shows empty array. How do I receive a JSON Request in the API? enter image description here

    public function create_invoice(Request $request) {       
    
    $data = $request->json()->all();
    }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/33R1d3P
via IFTTT

Laravel DB:raw with Union

I have the following querys which I need to unoin them but I'm getting the following error:

"message": "Method Illuminate\Support\Collection::getBindings does not exist."

The idea is that first query returns records grouped by month and the last query to union to first one, has the total values for each column grouped per month.

This is my expected output which is working correct the query in mysql:

enter image description here

SELECT USERS.ID AS ID, PROPERTIES.PROP_TYPE AS TIPO
,SUM(IF(MONTH(PROPERTIES.created_at) = 1, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as ENE
,SUM(IF(month(PROPERTIES.created_at) = 2, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) AS FEB
,SUM(IF(month(PROPERTIES.created_at) = 3, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as MAR
,SUM(IF(month(PROPERTIES.created_at) = 4, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) AS ABR
,SUM(IF(month(PROPERTIES.created_at) = 5, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) AS MAY
,SUM(IF(month(PROPERTIES.created_at) = 6, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as JUN
,SUM(IF(month(PROPERTIES.created_at) = 7, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as JUL
,SUM(IF(month(PROPERTIES.created_at) = 8, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) AS AGO
,SUM(IF(month(PROPERTIES.created_at) = 9, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as SEP
,SUM(IF(month(PROPERTIES.created_at) = 10, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as OCT
,SUM(IF(month(PROPERTIES.created_at) = 11, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as NOV
,SUM(IF(month(PROPERTIES.created_at) = 12, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as DIC
FROM PROPERTIES
LEFT JOIN USERS ON PROPERTIES.PROP_CAPPER_EMAIL = USERS.EMAIL_LOCAL_CRM
WHERE   USERS.ID = 755
GROUP BY PROPERTIES.PROP_TYPE, USERS.ID
UNION
SELECT USERS.ID AS ID, 'Total'
,SUM(IF(MONTH(PROPERTIES.created_at) = 1, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as ENE
,SUM(IF(month(PROPERTIES.created_at) = 2, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) AS FEB
,SUM(IF(month(PROPERTIES.created_at) = 3, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as MAR
,SUM(IF(month(PROPERTIES.created_at) = 4, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) AS ABR
,SUM(IF(month(PROPERTIES.created_at) = 5, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) AS MAY
,SUM(IF(month(PROPERTIES.created_at) = 6, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as JUN
,SUM(IF(month(PROPERTIES.created_at) = 7, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as JUL
,SUM(IF(month(PROPERTIES.created_at) = 8, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) AS AGO
,SUM(IF(month(PROPERTIES.created_at) = 9, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as SEP
,SUM(IF(month(PROPERTIES.created_at) = 10, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as OCT
,SUM(IF(month(PROPERTIES.created_at) = 11, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as NOV
,SUM(IF(month(PROPERTIES.created_at) = 12, PROPERTIES.PROP_EXCLUSIVE = 'Exclusiva',0)) as DIC
FROM PROPERTIES
LEFT JOIN USERS ON PROPERTIES.PROP_CAPPER_EMAIL = USERS.EMAIL_LOCAL_CRM
WHERE   USERS.ID = 755
GROUP BY USERS.ID

This is the code:

public function exclusive_details (Request $request) {
        $exclusive_details = DB::table('properties')
                            ->leftjoin('users', 'properties.prop_capper_email', '=', 'users.email_local_crm')
                            ->select(DB::raw("users.id
                            ,properties.prop_type
                            ,SUM(IF(MONTH(properties.created_at) = 1, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as ENE
                            ,SUM(IF(month(properties.created_at) = 2, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) AS FEB
                            ,SUM(IF(month(properties.created_at) = 3, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as MAR
                            ,SUM(IF(month(properties.created_at) = 4, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) AS ABR
                            ,SUM(IF(month(properties.created_at) = 5, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) AS MAY
                            ,SUM(IF(month(properties.created_at) = 6, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as JUN
                            ,SUM(IF(month(properties.created_at) = 7, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as JUL
                            ,SUM(IF(month(properties.created_at) = 8, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) AS AGO
                            ,SUM(IF(month(properties.created_at) = 9, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as SEP
                            ,SUM(IF(month(properties.created_at) = 10, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as OCT
                            ,SUM(IF(month(properties.created_at) = 11, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as NOV
                            ,SUM(IF(month(properties.created_at) = 12, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as DIC
                            "))
                            ->where('users.id', $request['query']['id'])
                            ->groupBy('properties.prop_type', 'users.id')
                            ->orderBy('properties.prop_type', 'asc');

        $exclusive_details_total = DB::table('properties')
                            ->leftjoin('users', 'properties.prop_capper_email', '=', 'users.email_local_crm')
                            ->select(DB::raw("users.id
                            ,'TOTAL'
                            ,SUM(IF(MONTH(properties.created_at) = 1, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as ENE
                            ,SUM(IF(month(properties.created_at) = 2, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) AS FEB
                            ,SUM(IF(month(properties.created_at) = 3, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as MAR
                            ,SUM(IF(month(properties.created_at) = 4, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) AS ABR
                            ,SUM(IF(month(properties.created_at) = 5, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) AS MAY
                            ,SUM(IF(month(properties.created_at) = 6, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as JUN
                            ,SUM(IF(month(properties.created_at) = 7, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as JUL
                            ,SUM(IF(month(properties.created_at) = 8, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) AS AGO
                            ,SUM(IF(month(properties.created_at) = 9, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as SEP
                            ,SUM(IF(month(properties.created_at) = 10, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as OCT
                            ,SUM(IF(month(properties.created_at) = 11, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as NOV
                            ,SUM(IF(month(properties.created_at) = 12, properties.PROP_EXCLUSIVE = 'Exclusiva',0)) as DIC
                            "))
                            ->where('users.id', $request['query']['id'])
                            ->union($exclusive_details)
                            ->groupBy('users.id')
                            ->get();
        dump($exclusive_details);
        return response()->json($exclusive_details);
    }

How can I fix the union issue?

Regards



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3cht00Q
via IFTTT

1 Salut, j'essaye de télécharger une image avec Laravel 5

I can't upload a file in laravel, it gives me the Method Illuminate \ Validation \ Validator :: validateAvatar does not exist error. so say that everything is well done

I created a validator function which return the validates



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2RLRshA
via IFTTT

Laravel 5.4 - Get logged user info with other table (contests) information

Showing right now on PageController

 public function getBlazeTalent() {
    $contestars = DB::table('contests')->where('user_id', Auth::id())->get();
    return view('blazetalent')->withContestars($contestars);
 }

But I want to show current user information with other contestars (users) information.

Contest Model

public function user() {
  return $this->belongsTo('BlazeChannel\User');
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3mE1vU4
via IFTTT

Laravel strange behavior in 1 to Many relationship

Very strange situation in Laravel 1 to Many relationships, My User model

public function reminder(){

        return $this->hasMany(Reminder::class);
    }

Reminder Model

public function user(){

        return $this->belongsTo(User::class);
    }

When I try to get

dd(auth()->user()->reminder) -> null
$user_id = auth()->user()->id;
$user = User::findOrFail($user_id);
dd($user->reminder) -> success I got results.

Question is why I can't get relationship result using auth()->user()->reminder???



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3hIzbMI
via IFTTT