laravel

Laravel - LIKE operator to search for encrypted values

喜欢而已 提交于 2021-01-27 23:03:44
问题 I am trying to implement a search module in my Laravel app that could filter users by name. In order to protect users, the 'name' column rows are encrypted on DB. The problem that I am facing is that query below always returns 0 results. I am encrypting the search input value before searching into DB. $patients = DB::select( DB::raw("SELECT * FROM patient WHERE name LIKE '%".Crypt::encrypt($searchText)."%';")); What am I doing wrong here ? 回答1: Crypt::encrypt("Text") The above will rarely

How to send form containing files via jQuery ajax using PATCH method to Laravel 5?

旧街凉风 提交于 2021-01-27 22:51:50
问题 This is my code: //routes.php Route::match(['post', 'patch'],'/slide/{id}', function() { dd(request()->all()); }); //form <form id="form" enctype="multipart/form-data"> <input type="text" name="title"> <input type="file" name="image"> </form> //js $('#form').on('submit',(function(e) { $.ajax({ type: "PATCH", url:'/slide/' + id, data: new FormData(this), cache: false, contentType: false, processData: false }).done(function(r) { console.log(r); }); })); When I use POST method everything is fine

htmlspecialchars() expects parameter 1 to be string, array given in Laravel

陌路散爱 提交于 2021-01-27 22:05:00
问题 I have got this error in my Laravel blade template htmlspecialchars() expects parameter 1 to be string, array given I have tried to convert the array into string in blade template. Here is the code <script> var value = {{ $sliderImageDataArray }}.toString() window.MedicPressSliderCaptions = value; </script> Where $silderImageDataArray is the variable and value stored here. Here is the $silderImageDataArray value [{"title":"First title","text":"<p><span id=\"hs_cos_wrapper_module

How to render partial using AJAX? Laravel 5.2

99封情书 提交于 2021-01-27 22:02:17
问题 I am in a situation where I want to list information about parking spots that are stored in a MYSQL database. I am using AJAX to make calls to API endpoint (/api/spots) and return a list of spots. I have created a partial view using blade syntax for the layout of the information(partials/Spot.blade.php). I am wondering if there is a way to create a controller method that will return a partial view and render it to part of the page, without making a trip back to the server. Is this possible

Override single message for required_without_all laravel

左心房为你撑大大i 提交于 2021-01-27 21:59:39
问题 I have been using required_without_all for at least one field required in laravel. Here is my code for rule 'rental_company_id' => 'required_without_all:camper_id,take_over_station_id,returnable_station_id', 'camper_id' => 'required_without_all:rental_company_id,take_over_station_id,returnable_station_id', 'take_over_station_id' => 'required_without_all:rental_company_id,camper_id,returnable_station_id', 'returnable_station_id' => 'required_without_all:rental_company_id,camper_id,take_over

Laravel - LIKE operator to search for encrypted values

ぃ、小莉子 提交于 2021-01-27 21:36:33
问题 I am trying to implement a search module in my Laravel app that could filter users by name. In order to protect users, the 'name' column rows are encrypted on DB. The problem that I am facing is that query below always returns 0 results. I am encrypting the search input value before searching into DB. $patients = DB::select( DB::raw("SELECT * FROM patient WHERE name LIKE '%".Crypt::encrypt($searchText)."%';")); What am I doing wrong here ? 回答1: Crypt::encrypt("Text") The above will rarely

group by date in laravel mongodb

China☆狼群 提交于 2021-01-27 21:31:50
问题 I'm using mongo and laravel. I'm getting data in periods of time, usually 30 days. I want to group the data by day. I've tried $project $dayOfMonth and group by day but it grouping them in order of days in month and I want to be ordered in days in the period. is there a way? [ '$match' => [ "created_at" => [ '$gte' => new \MongoDB\BSON\UTCDateTime($thisMonth), ] ], ], [ '$project' => [ 'day' => [ '$dayOfMonth' => [ 'date' => '$created_at', ] ], ] ], [ '$group' => [ '_id' => '$day', 'count' =>

react.js with laravel relationship

牧云@^-^@ 提交于 2021-01-27 21:08:50
问题 this error happend when I add company name to client {client.company.name} in view Uncaught TypeError: Cannot read property 'name' of null what can I do to solve this error in CompanyController public function index(request $request) { $clients = $this->client->with('company')->orderBy('date_created','DESC'); if($request->search){ $clients = $clients->where(function($query) use($request){ $query->where('client_id', $request->search); $query->orWhere('first_name', 'LIKE', '%' . $request-

Delete related models in Laravel 6/7

时光总嘲笑我的痴心妄想 提交于 2021-01-27 21:00:17
问题 There are many related questions but unfortunately I can't find working solution I have Laravel model and when this model is deleted I want to delete some related models run custom SQL query when deleting model My Laravel's model class looks like (as you can see models can have different relation types) class ModelA extends Model { public functions modelsB() { return $this->hasMany(ModelB:class); } public functions modelsC() { return $this->belongsToMany(ModelC:class); } // other related

Insert row in parents and childs table laravel

。_饼干妹妹 提交于 2021-01-27 20:29:20
问题 Im so lost. I have table, model and controller named Navbar. Here I create navbar buttons. I made child table called "type_1". So "navbar" id goes to table "type_1" and its column called "navbar_id". $form_data = array( 'tipas' => $tipas, 'p_id' => $p_id, 'name' => $request->title, 'text' => $request->text, 'img' => $name ); navbar::create($form_data); //created parent row Here navbar button is created. How can I create childs empty row with parent (navbar) id? Should I use models or I can do