Data importing in database using csv file in using laravel5.2 is quite easy. Today I spend some couple of minutes to learn about data import using csv file. How I did that work , I am gonna describe here.
At first i download the laravel project using composer, then i create the mysql database using phpmyadmin and I configure the database credentials in .env file.
Now I just created the user.csv file inside of the public directory and add some comma separated values. These values is based on the user information whose table structure or migration file is provided by the laravel by default. The File is something like this
I just run the migration file using command php artisan migrate command and made some route configuration in routes.php file which is something like this.
In above figure shows that routing for the importing csv file, Here I am not using controller for the importing Because I created this project for learning purpose. In which fopen() function is used to open the user.csv file and fgetcsv() function is used to fetch data from csv file to store into database.
I can run this project using base_url/csv then it will import all the data of user.csv file. and show all the result to the browser because it return the User::all() values. Thanks ! I learned it ! Keep On Working !!!!
In these days software testing is essential for the software development process, TDD, BDD etc are the popular methods of Software Testing. In TDD at first we write the test functions and then we will make functions which need to pass the tests. In These days i am learning about TDD in which some of the testing such as unit testing, integration testing, regression testing . I am weak in software testing But Software testing is fun and interesting for me at this time. Using TDD it ensures my code is correct and reliable code that's why i need to use testing.
Today I am watching the video tutorials from Laracasts.com, I understand some testing jargon about the Eloquent Model Testing in Laravel In the following way.
First I downloaded the Laravel project and create database in phpmyadmin and configure for the database credentials in .env file of the laravel.
Now i Create a simple Article Model and migration file for articles table using the command php artisan make:model Article -m
I am Just added just these columns for the articles table, Which is shown in the below figure.
And Just create the table using the commands php artisan migrate:install and php artisan migrate.
Now tables are created in the database.
Now create the factory method inside of the ModelFactory.php which will useful to add the records in the database tables. I am making the factory method for the articles table, which is shown follwing.
For the Model Test I create the test class ArticleTest.php inside of the tests/integration/models folder and test class is as follows.
Now If i run the test using the phpunit command then it Sure fails Because I do not created the trending() function in the Article.php Model. In above testing shows that At First two articles are created using the factory method, one article created with value of 10 in the reads column and another article is created with value of 20 in the reads column. After then trending() method is called and stored the result in $articles variable. Now actual comparing started using the assertEquals and assertCount methods which is quite simple. Ok How trending() method is organized in the Article.php is shown below.
I have been Pause my Project Work from one month before, From Today I am started to continue my final year project. I paused my work because i spend time for my exam at that time. My Project is social media type of web application which connect the service seeker and Service Provider at one place and make their business easier, and main another purpose is to provide the information which kinds of information users wants to see. Which is made using the Laravel Framework, At the time of starting of my project i use the php version 5.6.14 but meantime i upgrade the php verison to 7.0, After upgrading I change the some configuration and make project work in that environment. But When I start to continue work for my project today, I got some another extra Problems. One of the Problem is Shown in below figure.
I am Just Install all the php7 related cURL on my computer But the problem is still stay in the application. I studied and learn about what is cURL in php, cURL is a Command Line Tool which is used to communicate external server, upload files using ftp, Send Mail etc. so It is essential for my project .
Now I solve the problem by following steps, I am Using Linux Mint as an OS
- I search the php.ini file for the configuration of cURL
- I got that file inside of /etc/php/7.0/cli folder
- Uncomment the "extension=php_curl.dll" line
- Restart the Apache Server using the command "sudo /etc/init.d/apache2 restart"
- And I start my application using "php artisan serve"
- It Works, And Solved the cURL Problem
Ok Thank you ! Happy Coding, Keep Working on Problem Solve !
In these days, I am involving in final year project, For this
project our group members are working hardly. We are getting knowledge by
studying different blogs, posts, tutorials or by watching video tutorials and
some experiments. We can not do any work without knowing it’s core concept. We
are beginner so we must need to search or study lots of different kinds of
stuffs. And we are working on project by research work. How the research will
work for our project by research work. what happen if we can not get conclusion
and result by involving in research work that things I am going to describe
here .
According to the syllabus of the our final year project we
need to make documentation first and then start the technical part of the
application. We just finish some part of the documentation and the some part of
the technical stuff . Obviously we searched the different kinds of things to do
for the project work. But we have to study lots of things which are required
for our work, We are going to make something special not just CRUD app. If we
study surface about the topic and terms and simply copy paste to the
documentation that never going to help for our skill and career. We need to
understand what we are doing right now . Some People seems to be wild
researcher , Always research on the internet but not going to give the
conclusion from research of his/her study, That does not make sense or does
not going to help anybody. It’s just like someone is researching about how to
cook food, research completed but does not know how to cook food. There is no
meaning of research in that case. It’s very hard to understand all the things
at beginning time. If we going to the detail of the topic we will clear about
the topic we need to dive into until we get the conclusion.
Again I want to give example of research on cooking food, if
you want to research or experiment about cooking food you just understand what
type of food you are going to prepare. After that list out the required
ingredients just know procedure to how to cook that. After study and analysis
you must do experiment to cook food by following the procedure and rules. You
may be success or fail to cook food if you got success we have to try to make
better taste and more awesome otherwise you have to try to cook food again. It
is better if you get success and get knowledge about how to do it. It will be
best if you help or encourage to cook food who are interested at the work if
you only know how to cook food that’s good because you know it . if you teach
or encourage other you will get the community or team that makes your and your
team mates skill up very quick.
Conclusion:
Deep Study is required for the any type of research work we
are going to success in our final year project. We are going to achieve it by
bringing the strong conclusion after of research work.