Posts

Showing posts from March, 2018

After deleting the file for migration i am left with this message ‘Migration not found’ - development

Image
After deleting the file for migration i am left with this message ‘Migration not found’ I have created by a mistake 2 migrations in my laravel project, using the php artisan make:migration command called 2018_03_30_075929_drop_products_tags_table and 2018_03_30_075242_create_products_tags_table and then i have deleted the files. Now everything i run the command php artisan migrate:refresh I am get this error Migration not found: 2018_03_30_075929_drop_products_tags_table Migration not found: 2018_03_30_075242_create_products_tags_table ... And i tried to run php artisan migrate:reset , but I am getting the same error. How can I fix this, because it is driving me insane from Laravel Questions and Answers https://laravelquestions.com/php/after-deleting-the-file-for-migration-i-am-left-with-this-message-migration-not-found/ via Lzo Media

WordPress blog subdirectory with Laravel on nginx produces 404 error - development

WordPress blog subdirectory with Laravel on nginx produces 404 error I installed a new WordPress blog thru Forge onto the same server as a Laravel 5.4 app. I put the blog in blog.example.com for simplicity sake, but I don’t have any DNS actually pointing to the subdomain. Instead, I want to have example.com/blog pointing to my WordPress installation. I then modified the nginx conf file for the Laravel site to look like this: # FORGE CONFIG (DOT NOT REMOVE!) include forge-conf/example.com/before/*; server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name example.com; root /home/forge/example.com/current/public; # FORGE SSL (DO NOT REMOVE!) ssl_certificate /etc/nginx/ssl/example.com/230815/server.crt; ssl_certificate_key /etc/nginx/ssl/example.com/230815/server.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'SHA-HASH-HERE'; ssl_prefer_server_ciphers on; ssl_dhparam /etc/nginx/dhparams.pem; add_header X-...

Laravel blade with Vue component not show data - development

Laravel blade with Vue component not show data I am using Laravel 5.6 and create model named process and a controller with a function that gets all the records of the model: public function showProcessList(){ return response()->json(Process::all()); } In the web.php routes file also defined the route to retrieve the records, it works well, i tested the endpoint and i can see the data: Route::get('process/list', 'ProcessController@showProcessList'); In a blade file i try to show the list creating a Vue component like this: <!-- Process List --> <div class="row"> <process></process> </div> <script src=''></script> file app.js has this: window.Vue = require('vue'); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */ Vue...

JSON Object returned with error from LARAVEL API not readable in Nodejs - development

JSON Object returned with error from LARAVEL API not readable in Nodejs I am using Laravel apis for my project. The API is working fine when I use curl to access it. curl -H "Content-Type: application/json" -X POST -d '{"username":"xyz","password":"xyz", "filterZip":"123123"}' http://localhost:8080/api/signup {"error":{"message":"User with specified email address already started sign up process, but did not finished it. Please sign in regulary to continue sign up process.","errorCode":"020102"}} However when I call if from nodejs app. I am unable to access the error Json Object from the response. From Nodejs I am calling my laravel API fetch(API_URI + '/signup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(requestBody) }) On the Laravel API ...

"405 Method not allowed" in Laravel 5.6.14 - development

Image
"405 Method not allowed" in Laravel 5.6.14 I am just learning laravel resource methods to build a basic API. Below is the code of my api.php file that shows all the API routes. // List Articles Route::get('articles', 'ArticleController@index'); // List Single Article Route::get('article/{id}', 'ArticleController@show'); // Create New Article Route::post('article', 'ArticleController@store'); // Update Article Route::put('article', 'ArticleController@store'); // Delete Article Route::delete('article/{id}', 'ArticleController@destroy'); This works perfectly on get and delete methods. But for Post method, it is throwing error “405 Method not allowed”. I am using Postman to test the API calls. To be specific, below is the exact error Postman shows Symfony Component HttpKernel Exception MethodNotAllowedHttpException Also attaching screenshot of Postman from Laravel Questions an...

Laravel Spark – Settings views not working - development

Laravel Spark – Settings views not working Upgraded to version 6. Having lots of problems. None of the new views or assets wrote to the folders they were supposed to. Tried deleting what was there and reinstalling and it still didn’t work. I had to copy them over by hand and maybe I missed something because the settings items don’t work properly. The menu on the left doesn’t function properly. Plans are downloaded, but not shown in the subscriptions. Errors occur when I try to look at teams or switch teams. I made a short video to show the problems . Anything would help at this point. I have been slogging through this update for over a week… Could this be an issue with the vue or with bootstrap 4 not loading properly? from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-spark-settings-views-not-working/ via Lzo Media

extract values from a method Laravel - development

extract values from a method Laravel I have to add columns to a collection based on a common key … $usersDatas = $users->each(function ($record) use ($timeData) { $times = array_first($timeData, function ($value, $key) use ($record) { return $value['id'] === $record['id']; }); $record['totalTime'] = $times['totalTime']; $record['spendTime'] = $times['spendTime']; $record['remainingTime'] = $times['remainingTime']; var_dump($record); }); dd($usersDatas); the dd($records) inside gives me the right result … but i can’t extract the results outside… the dd($records) gives me : array:17 [▼ "id" => 1 "ua_id" => 351 "grade_id" => 584 "metier_id" => 18 "nom" => "XXX" "prenom" => "XXX" "matricule" => "XXX" "email" => null "datena...

laravel query whereBetween doesn’t work [duplicate] - development

laravel query whereBetween doesn’t work [duplicate] This question already has an answer here: Laravel 5 using OR condition with BETWEEN 2 answers Here is my Laravel query. $fromdate = '2018-04-09'; $todate = '2018-04-28'; $dt = array($fromdate, $todate); return DB::table('leaves') ->select('leaveId') ->whereBetween('from', [$dt[0], $dt[1]]) ->orWhereBetween('to', [$dt[0], $dt[1]]) ->get(); my db rows '11', 'ckkl;kghhjgkgvjkvvb,,kkkkhhhhh', '2018-03-29', '2018-04-21', '2018-04-22', 'Sam User', NULL, '2018-03-29 10:52:48', '2018-03-29 10:52:48', '2', '8', '1' '10', 'pjp'', '2018-03-29', '2018-04-11', '2018-04-12', 'test user', NULL, '2018-03-29 10:50:28', '2018-03-29 10:50:28', '1', '8', '1' It seems it doesn’t check the whereB...

get data to show in angularjs - development

Image
get data to show in angularjs I will try to do this to show data in page, but it’s not working. Is it wrong with my source below? $scope.confirmCapnhat=function(id){ if($scope.p_id!="" && $scope.dn_taoMoi!="") { // $scope.myVar = !$scope.myVar; $http.get(API+'diennuoc/capnhat/'+id).then(successCallback,errorCallback); function successCallback(response){ console.log(response); $scope.sodauDien=response.data.dn_sodauDien; $scope.diennuoc=response; }; function errorCallback(response){ $scope.sodauDien=0; $scope.sodauNuoc=0; }; } else alert('Chưa chọn phòng hoặc ngày lập!'); } And here is result when ran console.l...

Do you have to update laravel every time laravel version updates? - development

Do you have to update laravel every time laravel version updates? I'm currently on 5.6.11. Do I need to update to latest version? How would I do that? submitted by /u/Vraz_ [link] [comments] from Laravel Questions and Answers https://laravelquestions.com/rlaravel/do-you-have-to-update-laravel-every-time-laravel-version-updates/ via Lzo Media

Laravel 5.4 (1/1) MethodNotAllowedHttpException on DELETE method - development

Image
Laravel 5.4 (1/1) MethodNotAllowedHttpException on DELETE method Before anyone points that is a duplicate I have checked these questions – laravel 5.4 MethodNotAllowedHttpException in RouteCollection.php (line 251) , (1/1) MethodNotAllowedHttpException among others. My problem is that I have done all of the solutions to all of the above posted questions and none have solved my issue. ProfileController <?php namespace AppHttpControllers; use AppUser; use IlluminateHttpRequest; use IlluminateDatabaseEloquentModel; use IlluminateSupportFacadesDB; use Auth; class ProfileController extends Controller { // public function show($name) { $user = User::whereName($name)->first(); if ($user) { // User exists return view('profile')->withUser($user); } else { dd($user); } } public function destroy($id){ DB::table('users')->where('id', '=...

Can’t install plugin NFS on windows 10 (Laravel/Homestead/VirtualBox) - development

Can’t install plugin NFS on windows 10 (Laravel/Homestead/VirtualBox) I’ve been trying to install NFS because Laravel/Homestead/VirtualBox so slow on Windows. I tried to run $ vagrant plugin install vagrant-winnfsd but it responded this C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/win32/registry.rb:185:in `encode!’: code converter not found (UTF-16LE to Windows-1258) (Encoding::ConverterNotFoundError) My Homestead path: C:UsersMyPCHomestead registry.rb:185 I don’t know how to fix this, if you know any clues, please help. Thank you. Full error: MyPC@hangnm MINGW64 ~/Homestead (master) $ vagrant plugin install vagrant-winnfsd Installing the ‘vagrant-winnfsd’ plugin. This can take a few minutes… C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/win32/registry.rb:185:in encode!': code converter not found (UTF-16LE to Windows-1258) (Encoding::ConverterNotFoundError) from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/win32/registry.rb:185:in initiali...

need help for laravel: How i attach my disease table with others - development

need help for laravel: How i attach my disease table with others I an new to Laravel. i want when i store data that is storing correctly in multiple tables. after storing it will also have the id of all three tables on disease_symptoms_medicines table( foreignkeys) i not know how to do it. help me!!! In this code there is no error (if error due to poor english and typing mistakes) here is my migrations <?php use IlluminateSupportFacadesSchema; use IlluminateDatabaseSchemaBlueprint; use IlluminateDatabaseMigrationsMigration; class CreateDiseasesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('diseases', function (Blueprint $table) { $table->increments('id'); $table->string('name')->nullable(); $table->string('slug')->nullable();...

Seeding in laravel for multiple databases - development

Seeding in laravel for multiple databases I am working on a school project with multiyear database built in laravel. My requirement is to feed data for every new academic year in some tables. I have a main(superadmin) db and separate school’s db for every school. I need to connect to school db, n process is i have kept superadmin db details in .env file then it fetches particular school’s db details and makes a connection to that school db through middleware. My question is when i executes migration and seeding command it connects to superadmin db and performs respective operation on same. But i want to execute migration/seeding one by one for every school’s db. Please provide suggestions. Thank you. from Laravel Questions and Answers https://laravelquestions.com/laravel/seeding-in-laravel-for-multiple-databases/ via Lzo Media

Korean characters become "???" after exported using dompdf laravel - development

Korean characters become "???" after exported using dompdf laravel I using dompdf for laravel, the problem is the Korean characters can show properly in html but it’s turn into “???” when exported into pdf. Korean characters in header and footer can show properly using $canvas->page_script() but Korean characters in loadHTML not showing properly. Can someone help me? $pdf->loadHTML($doc_content); $pdf->output(); $dom_pdf = $pdf->getDomPDF(); $options = new Options(); $options->set('isPhpEnabled', true); $options->set('isRemoteEnabled', true); $options->set('defaultFont', 'UnShinmun'); $dom_pdf->setOptions($options); $canvas = $dom_pdf->get_canvas(); //$canvas->page_text(0, 0, "Page {PAGE_NUM} of {PAGE_COUNT}", null, 10, array(0, 0, 0)); $canvas->page_script(' $font = $fontMetric...

Calculated column in Laravel to transform name in slug - development

Calculated column in Laravel to transform name in slug I have a Location Model and Migration. Here I have name . Now I want to add an extra column (calculated), that will be name column with some replacement of special characters, and spaces to - . I will write that replace function by myself. I can’t find a way of introducing calculated columns. Thanks. from Laravel Questions and Answers https://laravelquestions.com/php/calculated-column-in-laravel-to-transform-name-in-slug/ via Lzo Media

Modifying Laravel’s Generated Registration Logic - development

Modifying Laravel’s Generated Registration Logic So, I am still kind of a newbie to Laravel. As part of the application I am working on, I want to modify the registration logic generated by php artisan make:auth to add e-mail verification for newly registered users. I modify the create() method on the generated RegisterController to look like this. protected function create(array $data) { $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]); // generate and store verification token $token = new Token; $token->user_id = $user->id; $token->token = str_randome(40); $token->save(); // send a verification e-mail to the $this->sendVerificationEmail($user->id); return $user; } So, on to my question. Suppose I want to capture the returned user on the verificat...

Want to show name as a parameter instead of id in the URL field in Laravel - development

Want to show name as a parameter instead of id in the URL field in Laravel I don’t want to show /route_name/{id} in the URL field of my Laravel project. Instead of that I want to show /route_name/{name} and also pass the id in the back-end to the controller. Suppose I have a view department.blade.php . Now click on knee pain from the menubar for seeing the details. Here is my view code <a href="> </a>" After click the knee pain a route called. Here is the route Route::get('/home_services_under_department/{id}', 'frontendDepartmentController@home_services_under_department'); Here is the home_services_under_department method format public function home_services_under_department($id){} Here is my URL in browser http://url/home_services_under_department/2 But I don’t want to see the id after home_services_under_department , I want to see the name knee-pain after home_services_under_department as a parameter like http://ur...

one to many relationship laravel - development

one to many relationship laravel I am making a one to many relationship, when I try to save it, it asks me to enter the FK should not I do it automatically? class AlternativesCompetitorsImage extends Model { public function alternativecompetitors() { return $this->belongsTo(AlternativesCompetitor::class,'id'); } } class AlternativesCompetitor extends Model { public function alternativescompetitorsimages(){ return $this->hasMany(AlternativesCompetitorsImage::class,'alter_comp_id'); } } Controller $ci = isset($id_image) ? $step->alternativescompetitorsimages : new AlternativesCompetitorsImage(); if( $request->hasFile('fileImg')){ $fileRequests = request()->file('fileImg'); $count = 0; foreach ($fileRequests as $fileRequest) { $keyCanvas = $c->key; $stepKey = $stepType->key; $public= public_path(); ...

What is the most appropriate way to debug your source code in Laravel? - development

What is the most appropriate way to debug your source code in Laravel? An error message should speak about the cause. Least it should be convenient for the developer to track a the bug with some hints(like the name of file, a function, either in controller or model, or both or the view, etc.) What about Laravel? This is not the first time, there comes an issue almost everyday in the code( of course we love bugs, we’ll learn from it ). What if you spend the whole day tracking a typo err? What if there is only a black board saying: Better luck next time!!* By default, the happiest framework is the ever worse to give accurate errors in the code. May be there is a method, may be that is what this question asks about. php artisan r:l [SymfonyComponentDebugExceptionFatalErrorException] Fatal error: Namespace declaration statement has to be the very first statement .. .. so that says where the error is. Check all the Controllers & Models to find the the exception. That will ...

Webpack outputs wrong image path - development

Webpack outputs wrong image path I’m using Webpack/Laravel Mix. On my original Sass file, a certain path looks like this: .is-gplay { background-image: url(../images/bcg/gplay.png); } Mix and webpack will then find the image and copy it to public/images . It will also rewrite the path within the new css file to .is-gplay { background-image: url(/images/gplay.png?d1b4cc17fbb3149178c9a1a6a47e33f); } Great. Except it copied the picture to public/images and wrote a path to public/css/images , so now the browser won’t find it unless I edit my compiled css and add ../ in front of the image path so it sees the images folder is outside the css folder by default. What am I missing here? Why does it create an images folder outside the css folder and then writes a path to css/images? Sorry if this is something simple I’m not realizing right now. It’s my first time working with webpack. from Laravel Questions and Answers https://laravelquestions.com/laravel/webpack-outputs-wrong...

How do i Insert information to Order-OrderProduct tables MySQL Laravel - development

How do i Insert information to Order-OrderProduct tables MySQL Laravel I am developing simple e commerce website with laravel for learning purposes. There are few things confusing me about database relations and inserting data to order-order_product tables when customer places an order. User Migration: Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('address'); $table->string('phone'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); User Model: class User extends Authenticatable { /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', ...

PHP Laravel Gallery split array into 3 columns - development

PHP Laravel Gallery split array into 3 columns I’m would like to have this effect: <div class="w3-third"> Images tags here </div> <div class="w3-third"> Images tags here </div> <div class="w3-third"> Images tags here </div> I have this php code: $images = Image::where('gallery_id', $id)->get(); $list = []; foreach ($images as $image) { array_push($list, $image->file_path); } $list = array_chunk($list, 3); return view('gallery.gallery') ->with([ 'gallery' => $gallery, 'images' => $list ]); And i want to push images from this list into those 3 columns. from Laravel Questions and Answers https://laravelquestions.com/php/php-laravel-gallery-split-array-into-3-columns/ via Lzo Media

Laravel get array of filenames from folder - development

Laravel get array of filenames from folder I am getting an array of filenames from a folder like this… $files = File::allFiles('myfolder/'); But the resulting array contains pathname as well. Is there a way of just getting an array of filenames? Or do I need to process each array item and extract the filename from it? from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-get-array-of-filenames-from-folder/ via Lzo Media

Laravel seeding via SQL file - development

Laravel seeding via SQL file I’m trying to read data from a .sql file in a seeder to fill 3-4 tables with some data and DatabaseSeeder.php looks like this public function run() { $this->call([ UsersTableSeeder::class, // Bunch of seeders using Eloquent SqlSeeder::class ]); } All other seeders execute and, actually, when trying to throw an exception in SqlSeeder.php I’m able to stop the seeding. However, SqlSeeder.php won’t seed the database via php artisan migrate:fresh --seed , seems like it’s bypassed. I always need to run php artisan db:seed --class SqlSeeder after, in order to make it seed the database. SqlSeeder.php looks like this public function run() { $path = base_path().'/database/seeds/sql/data.sql'; $sql = file_get_contents($path); DB::unprepared($sql); } Why’s that? from Laravel Questions and Answers https://laravelquestions.com/php/laravel-seeding-via-sql-file/ via Lzo Media

Create a Plugin System in Laravel CMS project - development

Create a Plugin System in Laravel CMS project Hello laravel developers, this is first post for me and hope someone help me in my issue. I developing CMS by laravel 5.5 and i have 3 main module as follow: layout (in this module i define my layout [rows + cols] and then inject plugin please have look to below image). layout post/page in this module i choose one of my layout that i have created, also it should call plugin that existing in attached layout. i will store my plugin as blade template Plugin>main-content.balde.php Problem: now when page or post opening i want to load the layout and mapping the plugin and i want to do this automatically without (if or else) statement layout design Idea: one of idea i have to use view composer but as you see the name of plugin will be loaded from database and of course it will be changed regarding to layout. sec idea to use laravel package, design plugin as package third, create helper function and will be loaded in layout and t...

How to get access to relationship in model User Laravel? - development

Image
How to get access to relationship in model User Laravel? I have default User model: class User extends Authenticatable implements HasRoleContract { use Notifiable, HasRole; } With one relationship inside: public function distributor() { return $this->hasOne('AppDistributorContacts', 'distributor_id', 'id'); } So, when user passed authorization I can not see this relation in object: from Laravel Questions and Answers https://laravelquestions.com/laravel/how-to-get-access-to-relationship-in-model-user-laravel/ via Lzo Media

Laravel 5.5 – Transfer file to S3 - development

Laravel 5.5 – Transfer file to S3 I have an array of filenames that looks like this array ( 'file1.jpg', 'file2.jpg', 'file3.jpg' ) I am trying to loop through them and upload them to an S3 bucket like this.. foreach ($filenames as $filename) { Storage::disk('s3')->put( /* S3 */ 's3foldername/' . $foldername . '/' . $filename, /* Local Storage */ storage_path('localfolder/' . $foldername . '/' . $filename), 'public' ); } This isn’t working for some reason, the paths all check out ok. Do I need to read the file contents first? from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-5-5-transfer-file-to-s3/ via Lzo Media

How to install a github repo with composer and user it in laravel ? - development

How to install a github repo with composer and user it in laravel ? https://github.com/abhinayrathore/PHP-IMDb-Scraper I'm looking to use the above package in a project, could someone give me a quick tip on how to install it with composer . thank you submitted by /u/eid-a [link] [comments] from Laravel Questions and Answers https://laravelquestions.com/rlaravel/how-to-install-a-github-repo-with-composer-and-user-it-in-laravel/ via Lzo Media

Laravel or Joomla [on hold] - development

Laravel or Joomla [on hold] I am in the process of building a CRM, I would like to add functionalities like real-time reports, real-time graphs, notifications to customers and admins, API functionality to the CRM so other web services can connect to my app, be able to easily add new features or Modules and the most important thing build it so other developers can easily make changes or adds. thank you all. from Laravel Questions and Answers https://laravelquestions.com/php/laravel-or-joomla-on-hold/ via Lzo Media

Laravel 5 mail not sending… - development

Laravel 5 mail not sending… I've been at this for a few hours now, and I'm giving up. Ruined my Sunday in fact… I've got an app – it sends mail perfectly through Gmail, but I wanted it to send through my domain, so I ordered business email from Namecheap and thought it would be simple enough. It's not. I'm using the same exact info and credentials in my .env file as I am in my desktop mail client. Copied and pasted. My desktop sends. My server reports the email address as having failed. Switch the credentials and point them at Mailtrap, and again, it works fine. I'm not seeing anything about this failure anywhere in any of my log files, so I have no idea where to even start debugging. Oh, and i checked with Namecheaps customer service, but they reported everything is standard on their end. Has anyone got experience with Laravel and Namecheaps email service? I'm to the point now that I just want to use PHPMailer, but that's silly since Laravel has...

First foreach statement in if statement not initiating, skips straight to second one? - development

First foreach statement in if statement not initiating, skips straight to second one? So I am having an issue. I have two if statements that request-> data from the form. However, when I have both checked, it is skipping over the first one and going to the second one. The foreach statements in the first one do not even initiate and I have no idea why. Here is my code: if ($request->location_verification == 'on') { $get_data = []; foreach (array_chunk($results, 50) as $chunk_result) { foreach ($chunk_result as $r) { $client_name = trim($r['first_name'] . ' ' . $r['last_name']); if ($client_name == '') { $check_name = ContactList::where('phone_number', $r['phone_number'])->first(); if ($check_name) { $client_name = trim($check_name->first_name . ' ' . $check_name->last_name); if ($client_name ==...

filter charts with laravel - development

filter charts with laravel I need to develop dashboard with laravel as demo https://jtainslie.github.io/crossfilter-demo/ but I didn’t find chart packages that filters when click on part of chart can you help me please? from Laravel Questions and Answers https://laravelquestions.com/laravel/filter-charts-with-laravel/ via Lzo Media

Laravel Url two levels deep - development

Laravel Url two levels deep Learning Laravel, I have set up a dev area on AWS with an Ubuntu server. I can create pages that are one level deep Route::get('/campgrounds','CampgroundController@index'); these work fine but when I go two levels deep they don’t work. When I try to create a route that is two levels deep I get a “that page your looking for doesn’t exist”. Route::get('/campgrounds/create', function (){ return view('welcome'); }); I don’t see anything in the logging.log file that is erring out. Is there a Laravel setting I need or setting on Apache that needs changing? Maybe something in the .env file? from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-url-two-levels-deep/ via Lzo Media

Laravel Replace Unicode Characters in Database - development

Laravel Replace Unicode Characters in Database I stored some hours from Google Places and little did I know it brought in some longer dashes (u2013) and I’d like to loop through and convert anything in the database that is a unicode string into a normal string, as when I retrieve these hours I can’t explode them via explode(' - ', $hours); What’s the best way to do this in Laravel/MySQL/PHP? from Laravel Questions and Answers https://laravelquestions.com/php/laravel-replace-unicode-characters-in-database/ via Lzo Media

How to use mock objects in php testing - development

How to use mock objects in php testing I’m trying to learn how to test properly and am struggling to get my head around mocks in the scenario below. I don’t seem to be able to mock a class. The main class uses a number of component classes to build a particular activity. I can test the component on it’s own and mock it correctly but when I try to integrate test within the main class it calls the real service not the mock service. This is in a Laravel 5.5 app. I have a base class: class booking { private $calEventCreator public function __construct(CalenderEventCreator $calEventCreator) { $this->calEventCreator = $calEventCreator; } } This is then extended by another class: class EventType extends booking { //do stuff } The CalenderEventCreator relies on an external service which I want to mock. class CalendarEventCreator { public function __construct(ExternalService $externalService) { $this->externalService = $externalService; ...

Laravel – how to send some value of a parameter from a blade view files to a controller? - development

Laravel – how to send some value of a parameter from a blade view files to a controller? How to send value “” to some method in a controller? e.g. show.blade.php – contains the value: "" MyController.php – contains the method: public function results(Request $request){ //and here I want to use the value } from Laravel Questions and Answers https://laravelquestions.com/php/laravel-how-to-send-some-value-of-a-parameter-from-a-blade-view-files-to-a-controller/ via Lzo Media

i can’t access my laravel development server using IP address - development

i can’t access my laravel development server using IP address i’m trying to build an android app that requires interaction with a database server , i’m using my own computer for this purpose , i’m running wampserver 3.1.0 . i installed laravel successfully using composer , however when i type 192.168.1.6:8000/ to test i get a webpage displaying this error : The following error was encountered while trying to retrieve the URL: http://192.168.1.6:8000/ Connection to 192.168.1.6 failed. The system returned: (110) Operation timed out The remote host or network may be down. Please try the request again. Your cache administrator is webmaster. note that i already started the server using the “php artisan serve –host ipaddress” command , and the permissions in httpd.conf and httpd-vhosts.conf are configured correctly .what confuses me is that when i type the same url in my phone browser it shows the laravel page with no errors whatsoever !!! , help would be much appreciated . from La...

Laravel call contoller from blade without route - development

Laravel call contoller from blade without route I am developing cms and i want to make snippets like WordPress for ex: in the post content when someone type this post@getBySlug>hello-word This triger function getBySlug in post contoller. Any idea please from Laravel Questions and Answers https://laravelquestions.com/php/laravel-call-contoller-from-blade-without-route/ via Lzo Media

Laravel two references to same table - development

Laravel two references to same table I have a transactions tables with sender_id and receiver_id columns which are both references of user. now, I want to create a hasMany relationship for the user. (all user’s transaction, be it,received or sent) from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-two-references-to-same-table/ via Lzo Media

Laravel – Redirect even if no product selected - development

Laravel – Redirect even if no product selected I have a system where a user can select an item, submit a request and move on. I need to give the user the option to NOT select an item and still be able to move on. In my current situation, I don’t know how to achieve that. In my view, I display all the selectable items like this, using a foreach: @foreach($themes as $theme) <div class="col-md-4 mb-4"> <div class="card theme-card card-hover depth-2 border-0" id="theme-id-"> <a href="" class="theme-link" data-toggle="modal" data-target="#theme"> <div class="card-header p-0"> @if($theme->thumbnail != 0) <img src="https://s.tmimgcdn.com/scr/67400/magento-thema-over-boxen_67400-original.jpg?width=502&height=502" width="502" height="350" class="theme-card-img" alt=""> @else <img src="http://jis.gov.jm/me...

Laravel – Queues reporting as failed (even though they don’t) - development

Laravel – Queues reporting as failed (even though they don’t) I am using the latest version of Homestead. I also have Laravel Horizon set up. I am using redis as the queue driver. What’s happening is my jobs are all failing (even though the job exits correctly). I am running the job through command line by using a custom command: vagrant@homestead:~/myapp$ artisan crawl:start vagrant@homestead:~/myapp$ <-- No CLI errors after running app/Console/Command/crawl.php <?php namespace MyAppConsoleCommands; use IlluminateConsoleCommand; use MyAppJobsCrawl; class crawl extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'crawl:start'; /** * The console command description. * * @var string */ protected $description = 'Start long running job.'; /** * Create a new command instance. * * @return void */ public function...

Why am l getting "access not configured" error why trying to make an api call to google analytics reporting? - development

Why am l getting "access not configured" error why trying to make an api call to google analytics reporting? l am trying to integrate google analytics reporting to a laravel website hosted locally and its giving me this error {"error":{"errors":[{"domain":"usageLimits","reason":"accessNotConfigured","message":"Access Not Configured. Google Analytics API has not been used in project 463423597673 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=463423597673 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","extendedHelp":"https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=463423597673"}],"code":403,"message":"Access Not Configured. Google Analytics API has not...

Arrange the array by pid - development

Arrange the array by pid I have an array selected from database like this $authList = [ ['id' => 1, 'pid' => 0, 'title' => 'project'], ['id' => 2, 'pid' => 1, 'title' => 'customer'], ['id' => 3, 'pid' => 2, 'title' => 'select'], ]; And I want to arrange the array by “pid” like this $result = [ [ 'id' => 1, 'pid' => 0, 'title' => 'project', 'children' => [ [ 'id' => 2, 'pid' => 1, 'title' => 'select', 'children' => [ 'id' => 3, 'pid' => 2, 'title' => 'select' ] ], ] ], ]; So could anyone provide...

Laravel: to make external modules independent - development

Laravel: to make external modules independent We developed a modular project in Laravel 5.1. There are lots of core modules and models that use these modules. In our case, if the inserted module uses other modules, it will be related to those models dynamically. When I remove the module from project by hand, I need to remove its dependencies from each module. We want establish relations without creating dependency between modules. For example; User model from account module used by other many other modules. Assume we have discussion module. When we build a relationship for discussion model, we can reach the user of the corresponding model. However, if we establish a relationship with the user model, this project will no longer be a moduler. We want to add dynamic functions to the user module from discussion module. Temporarily, we add this code fragment to user module. /** * @return mixed */ public function lastAnswer() { if( class_exists( Config::get( ...

http error: 400 | {"msg":"Message must be no more than 64k"} while trying to use Iron to send queued emails - development

http error: 400 | {"msg":"Message must be no more than 64k"} while trying to use Iron to send queued emails I am trying to use Iron in Laravel 5.0 project and we are using Mail::queue() to send our emails but we are getting http error: 400 | {"msg":"Message must be no more than 64k"} this mail works if we directly send it but we are getting this when we are using Mail::queue() Error stack trace in IronCore.class.php line 358 at IronCore->reportHttpError('400', '{"msg":"Message must be no more than 64k"}') in IronCore.class.php line 349 Any advise on this will be highly appreciated. from Laravel Questions and Answers https://laravelquestions.com/php/http-error-400-msgmessage-must-be-no-more-than-64k-while-trying-to-use-iron-to-send-queued-emails/ via Lzo Media

Laravel – Scheduling a Large Task - development

Laravel – Scheduling a Large Task Trying to run a function in Laravel that’s quite large and fetches a lot of data from Google Places API and stores parts in my database as new entries in a table. The problem is it auto-discovers new entries for me near my current entries, and that creates more jobs. When I just access the command via GET it times out eventually. I’ve tried running it as a scheduled command with Redis but to be frank I can’t seem to figure out how it works. I’ve created a job, I tried to queue it with dispatch, but then it tries to run it immediately right now and it times out eventually again. How do I run this large task without it pausing my entire server? Thanks Zach from Laravel Questions and Answers https://laravelquestions.com/php/laravel-scheduling-a-large-task/ via Lzo Media

Doctrine lifecycle callbacks don’t fire - development

Doctrine lifecycle callbacks don’t fire I want to create an identifier for my invoices, after I persist them. I’m using an auto generated ID in my identifier, so I have to use some postPersist callback to achieve this. However, my postPersist callback doesn’t get fired. Here is my AbstractInvoice entity: <?php namespace AppInvoice; use DoctrineORMMapping as ORM; /** * @ORMEntity * @ORMHasLifecycleCallbacks * @ORMTable("invoices") * @ORMInheritanceType("SINGLE_TABLE") * @ORMDiscriminatorColumn(name="type", type="integer") * @ORMDiscriminatorMap({ * "0"="Regular", * "1"="Credit" * }) */ abstract class AbstractInvoice { /** * @ORMId() * @ORMColumn(type="integer") * @ORMGeneratedValue(strategy="AUTO") * @var int */ protected $id; /** * @ORMColumn(type="string") * @var string */ protected $identifie...

Creating a Service Provider in Laravel for a Vendor Package - development

Creating a Service Provider in Laravel for a Vendor Package I’ve installed the following package into laravel: https://github.com/omnilance/graphql-php-client I want to bind the GraphQL class in the service provider with some config values and access it like: app(OmnilanceGraphQLClient::class)->response() Below is what I have so far. How would I set the host and other options the class provides? Do I do it in the boot method? <?php namespace AppProviders; use OmnilanceGraphQLClient as GraphQL; use IlluminateSupportServiceProvider; class GraphQLServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot() { // $client->setHost($app['config']->get('graphql.host')); } /** * Register the application services. * * @return void */ public function register() { $this->app->bind(OmnilanceGraphQLClient::...

How to logout automatically from all tabs when I logout from anyone tab in laravel? - development

How to logout automatically from all tabs when I logout from anyone tab in laravel? I am building a project in laravel. The testing team has suggested me to keep a check that if the user is logged in and has opened many tabs. At once, he logout from any one of the tabs, the applications must automatically logout him from all the tabs. This functionality in present in facebook. from Laravel Questions and Answers https://laravelquestions.com/php/how-to-logout-automatically-from-all-tabs-when-i-logout-from-anyone-tab-in-laravel/ via Lzo Media

How to use GUZZLE Package in laravel to send xml request? - development

How to use GUZZLE Package in laravel to send xml request? Have any one used GUZZLE Package in laravel 5.6 to send xml request into given wsdl link and get response and manipulated it.. from Laravel Questions and Answers https://laravelquestions.com/laravel/how-to-use-guzzle-package-in-laravel-to-send-xml-request/ via Lzo Media

Can’t find Backpack/Crudnews files - development

Can’t find Backpack/Crudnews files I have a fresh install of laravel (using composer) and Backpack (using composer) and on top of that i installed Crudnews (also using composer) and everything works fine. But i want to add an “author” column to the Crudnews form so when i started looking for the files (following the documentation) i realise that the only files i have are the migration files. I changed those and migrated and now i have the extra “author” field in my database, so that works. But i can’t find the controllers or route files ANYWHERE. I have looked through all my folders and there are no files that has to do with Crudnews and i’m so confused. They should be there since it works, but i can’t find them. But if they arent there the app should break. Has anyone had similar problems? Or maybe anyone has a solution? PHP: 7.1.14 Valet (Server environment): 2.0.7 System: Mac OS, 10.13.3 from Laravel Questions and Answers https://laravelquestions.com/php/cant-find-backpack...

how to view selected dates back on the same page after executing function - development

how to view selected dates back on the same page after executing function so i have a form like so: <form role="form" action="" autocomplete="off" method="POST"> <div class="form-group-attached"> <div class="row"> <div class="col-lg-6"> <div class="form-group form-group-default required" > <label>From</label> <input type="date" class="form-control" name="from" required> </div> </div> <div class="col-lg-6"> <div class="form-group form-group-default required" > <label>To</label> <input type="date" class="form-control" name="to" required> </div> </div> </div> </div> <br/> <button class="b...