Laravel Eloquent Query Using WHERE with OR AND OR?
How do I say WHERE (a = 1 OR b =1 ) AND (c = 1 OR d = 1) For more complicated queries am I supposed to use raw SQL? 14 Answers 14
How do I say WHERE (a = 1 OR b =1 ) AND (c = 1 OR d = 1) For more complicated queries am I supposed to use raw SQL? 14 Answers 14
I am new to Laravel. How do I find if a record exists? $user = User::where(’email’, ‘=’, Input::get(’email’)); What can I do here to see if $user has a record? 31 Answers 31 It depends if you want to work with the user afterwards or only check if one exists. If you want to use … Read more
I’m currently using the below code to insert data in a table: <?php public function saveDetailsCompany() { $post = Input::All(); $data = new Company; $data->nombre = $post[‘name’]; $data->direccion = $post[‘address’]; $data->telefono = $post[‘phone’]; $data->email = $post[’email’]; $data->giro = $post[‘type’]; $data->fecha_registro = date(“Y-m-d H:i:s”); $data->fecha_modificacion = date(“Y-m-d H:i:s”); if ($data->save()) { return Response::json(array(‘success’ => true), 200); … Read more
I’m using the Laravel Eloquent query builder and I have a query where I want a WHERE clause on multiple conditions. It works, but it’s not elegant. Example: $results = User::where(‘this’, ‘=’, 1) ->where(‘that’, ‘=’, 1) ->where(‘this_too’, ‘=’, 1) ->where(‘that_too’, ‘=’, 1) ->where(‘this_as_well’, ‘=’, 1) ->where(‘that_as_well’, ‘=’, 1) ->where(‘this_one_too’, ‘=’, 1) ->where(‘that_one_too’, ‘=’, 1) ->where(‘this_one_as_well’, … Read more
Given the following code: DB::table(‘users’)->get(); I want to get the raw SQL query string that the database query builder above will generate. In this example, it would be SELECT * FROM users. How do I do this? 39 s 39