Laravel is a free, open-source PHP web application framework for the development of web applications following the model–view–controller (MVC) architectural pattern. Some of the features of Laravel are a modular packaging system with a dedicated dependency manager, different ways for accessing relational databases, utilities that aid in application deployment and maintenance, and its orientation toward syntactic sugar. Laravel is regarded as one of the most popular PHP frameworks.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm new to Laravel and I'm trying to figure this out.

I'm working through the tutorial at

My code right now looks like this:

Here's my "home.blade.php:"

<form action="/insert" method="Post">

Open in new window

My web.php page has my routes structured like this:

Route::get('/home', 'HomeController@index')->name('home');


Route::post('/insert', 'InsertController@add');

Open in new window

My InsertController looks like this:

use Illuminate\Http\Request;

class InsertController extends Controller
	public function display() {
    public function add(Request $request) {


Open in new window

I'm thinking that "add::display(Request::all())" is targeting my "add" model sitting in my "app" directory. At that point, I've got this:


namespace App;

use Illuminate\Database\Eloquent\Model;

class add extends Model
    protected $fillable = ['question_text', 'keywords', 'required', 'type', 'answer_a', 'answer_b', 'answer_c', 'answer_d', 'answer_e'];

Open in new window

I'm wrong, apparently. Because when I submit my form, I get this error:

Class 'App\Http\Controllers\add' not found

What am I doing wrong? And am I right in assuming that this code:

add::display(Request::all()); going to submit my data and then grab the "display" method and show that page?

I'm a mess...

Straighten me out, please...
Angular Fundamentals
LVL 13
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

What is the cleanist way to make ajax calls on content that is dynamically generated? For example  i have a laravel controller that returns data organized into divs:

$counter = 1;
foreach($data_set as $data){
<div id="$counter" data-content="$id">$data</div>



Open in new window

So if i return 3 results
<div id="1" data-content="45">$data</div>
<div id="2" data-content="66">$data</div>
<div id="3" data-content="22">$data</div>

Open in new window

Now i want to use an ajax call to drill further down into that data so i need an ajax call to grab the data-content field from id="1" which will then return me another subset of data

<div id="1" data-content="45">$data</div>
                       <div id="1a" data-content="45">$item</div>
                       <div id="1b" data-content="45">$item</div>
                       <div id="1c" data-content="45">$item</div>
<div id="2" data-content="66">$data</div>
<div id="3" data-content="22">$data</div>

Open in new window

What is the easiest way to do this with JAvascript if my ID's are being generated dynamically? Use a loop and a this keyword to get the array key of the element being clicked ?
I am having trouble finding out how to do routing with PHP.

I know WordPress and Laravel use it, but I was wondering how to code it.

I realize it would use Apache mod rewrite, but I'm having trouble figuring out how to do routing without a framework in PHP.
I'm starting a new web development project and have decided on using PHP with the latest version of the Laravel framework (currently v5.7). I'll likely be deploying to AWS, and will be using Amazon Aurora as the database engine (which is supposed to be MySQL compatible).  As I prepare to dive in, a few questions have come to mind that I'm hoping someone here can answer.  I'm relatively new to the Laravel framework, I must say, so I a apologize in advance for my ignorance.

1) What options are available to me for setting up a local development environment under Windows 10 Home Edition (64-bit)?  So far, I've read about using Vagrant/Homestead, (which sounds complicated and like it might require Windows 10 Professional) -- and also using WAMP, which I already have installed and running on my machine. By any chance, does some kind of pre-configured Virtual Box disk image exist anywhere that I could download and install that would simplify things for me?  

2) Is there anything important that I need to keep in mind (that's not so obvious) regarding the supposed MySQL compatibility of Amazon's Aurora database engine as I'm developing and/or deploying?  Can I safely treat Amazon's Aurora as a normal MySQL database engine, or are there any "gotchas" that I should be aware of such as driver compatibility, etc?

3) What's the most current trend regarding which templating system to use with Laravel? I know that it comes with the Blade templating engine, and I've heard some …
We´re providing online exam for ours members. The exam can be done in computer, tablet or smartphone. The exam have from 5 to 10 questions with 5 true or false afirmatives in each question. The exam have especific date, time and duration (20 minutes),  occurs quartely in all country, on centers with supervisors. The System use PHP language with laravel and Mysql. My question is if there´s any way to know if anyone during the exam copy the screen with the question and answer ? (like print scr button, or press three fingers on android screen)
How do I separate this "tue-09:00 AM-10:00 AM" in the format Start Time: 9:00 AM End Time: 10.00AM using angularjs?
I have table in which the day and time is getting stored in this ("tue-09:00 AM-10:00 AM" ) format, when I have to view the data I want it to be in the above format.
How can it be done?
I'm a few months away from starting to take on Freelancing gigs.

I was wondering how to do my books/bill clients.

I had a fantasy about using Laravel to create a separate site on a subdomain that would bill clients and export a CSV. But I've been thinking about using Freshbooks.

I will probably offer subscription services (hosting/maintenance) which I want to bill using the web.

My website will be WordPress.

I'm not sure how to handle billing, and I want to have a good system down when I start. I know that Freshbooks has an API.

What would be the best way to handle this?
I have written a function to insert data into database. I want to know how to update the row data when inserting again?
public function detailsInsertion(Request $request) {

$link = \App\Models\Gallery::where(['id'=>$this->getSelectedSchoolId()])->first();

  if ($request->hasFile('file')) {
      $file = $request->file('file');
      $file->move('images/'.$this->getSelectedSchoolId().'/websitehome', $link->id.'.'.$file->getClientOriginalExtension());
        $link =  \App\Models\Gallery::create(['id'=>$this->getSelectedSchoolId(),'source_url'=>'images/image-not-found.png']+$request->all());
        if(count($request->social_media)!=0 && count($request->social_url)!=0)
          $social_media = $request->social_media;
          $social_url = $request->social_url;
          foreach (array_combine($social_media,$social_url) as $media=>$link) {
            $insert_social_link = \App\Models\Gallery::create(['section_type'=>'social_media','name'=>$media,'description'=>$media,'source_url'=>$link]);
        if ($request->hasFile('file')) {
            $file = $request->file('file');

Open in new window

How to get attendance per day of a student in jquery? I have combo box where there are 2 options "full day", "subject wise". On click of subject wise entire teacher data, date time is shown but if its full day then how to write in jquery to get student attendance for the entire day?
Hi Experts

Could you point what is needed in terms of Apache2.x  configurations to runs Laravel apps ?

The examples I had run uses Laravel's internal server

Open in new window

And I want to run from Apache.

Thanks in advance!
JavaScript Best Practices
LVL 13
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Hi Experts

Could you point how to correctly configure PHP to use with Laravel?

After a composer update this error occurs
- laravel/framework v5.2.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.2/cli/php.ini
    - /etc/php/7.2/cli/conf.d/10-mysqlnd.ini
    - /etc/php/7.2/cli/conf.d/10-opcache.ini
    - /etc/php/7.2/cli/conf.d/10-pdo.ini
    - /etc/php/7.2/cli/conf.d/20-calendar.ini
    - /etc/php/7.2/cli/conf.d/20-ctype.ini
    - /etc/php/7.2/cli/conf.d/20-exif.ini
    - /etc/php/7.2/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.2/cli/conf.d/20-ftp.ini
    - /etc/php/7.2/cli/conf.d/20-gettext.ini
    - /etc/php/7.2/cli/conf.d/20-iconv.ini
    - /etc/php/7.2/cli/conf.d/20-json.ini
    - /etc/php/7.2/cli/conf.d/20-mysqli.ini
    - /etc/php/7.2/cli/conf.d/20-pdo_mysql.ini
    - /etc/php/7.2/cli/conf.d/20-pdo_sqlite.ini
    - /etc/php/7.2/cli/conf.d/20-phar.ini
    - /etc/php/7.2/cli/conf.d/20-posix.ini
    - /etc/php/7.2/cli/conf.d/20-readline.ini
    - /etc/php/7.2/cli/conf.d/20-shmop.ini
    - /etc/php/7.2/cli/conf.d/20-sockets.ini
    - /etc/php/7.2/cli/conf.d/20-sqlite3.ini
    - /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.2/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.2/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.2/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by 

Open in new window

I've been asked to submit a code sample using JQuery and Laravel. It's done and I'm getting ready to zip things up to hand to the administrator but I've got a question.

When I go to zip up the entire Laravel project, the "vendor" and the "node_modules" folders are enormous.

The exercise itself is pretty simple. I think I could get the point across with a couple of blades and the controller. Still, I want them to see the entire site, so here's my question:

Do those who work in Laravel typically expect those two directories? Is there a more streamlined approach to sharing the code to a Laravel site or do you have to box up the whole thing?

Basic question, I know, but it's worth asking if there's a more expeditious way to do things.
I have XAMPP running on Windows 10. I am trying to setup a Virtual Host so that when I use "" as a domain I get directly to my public folder of laravel project.
Laravel is located at C:/xampp/htdocs/myapp/public.
By using http://localhost:8000/myapp/public/ i can access laravel index.php
So far i have tried the following:
http v-host.conf file
#this is the default address of XAMPP    
<VirtualHost *:8000>
   DocumentRoot "C:/XAMPP/htdocs/"
   ServerName localhost

<VirtualHost *:8000>
    DocumentRoot "C:/xampp/htdocs/myapp/public"
    ServerName myapp.test
    SetEnv NS_ENV variable_value

and in C:\Windows\System32\drivers\etc\host file localhost myapp.test

and after restarting apache and typing myapp.test leads to iis homepage instead of index.php in public folder.
I would like to find out whether is there a way to perform the following:

1) Include (when $id is not null) and exclude (when $id is null) in the where clause for the code below.
2) Switch between sortByDesc and sortBy based on condition ($sort=='asc' then.... $sort=='desc' then...) for the code below.

   $maxlimit = Product::where('category_id_fk',$id)->with(['child','price','variant','thumbnail','image','description'])->count();
   $products = Product::where('category_id_fk',$id)->with(['child','price','variant','thumbnail','image','description'])->take($recperpage)->get()->sortByDesc('price.list_price');
   $maxlimit = Product::with(['child','price','variant','thumbnail','image','description'])->count();
   $products = Product::with(['child','price','variant','thumbnail','image','description'])->take($recperpage)->get()->sortByDesc('price.list_price');

Open in new window

The objective is to simplify the code above as much as possible but achieve the same result.

Your help is kindly appreciated.
I am a college student. I have some money I inherited and I was thinking about starting an eCommerce site for vapes and juices.

I wanted some advice to see what platform I should use. To show you where my coding skills are at a project I am working on is available at

I've played around with Woocommerce. I'm intrigued by Magento.

I've also wondered about building an ecommerce site from scratch or with Laravel.

Thanks for your help, if I could make 1k a month I could pay expenses. What do I need to begin researching? Is this a foolish use of my money?
Here are the codes I have written to submit my shopping cart details to paypal.

        private $_api_context;

	public function __construct(){
             $paypal_conf = Config::get('paypal');		
             $this->_api_context = new ApiContext(new OAuthTokenCredential($paypal_conf['client_id'], $paypal_conf['secret']));
             $this->_api_context->setConfig($paypal_conf['settings']); //the problem is here

        $payer = new Payer();

       $items = new ItemList();
	     'price'=>$v['price'] * $v['quantity']

      $amount = new Amount();
      $transaction = new Transaction();
	->setDescription('Your transaction description');
      $redirect_urls = new RedirectUrls();
      $payment = new Payment();
	try {
	}catch (\PayPal\Exception\PPConnectionException $ex){
	}catch (Exception $ex) {
	$approvalUrl = 

Open in new window

I installed Laravel.

I created a virtual host on my computer with the hostname laravel.local.

When I installed Laravel I chose the name sample-application, and when it installed it, it  created a directory in my public directory that was called sample-application.

My question is really dumb, but because of apache mod rewrite, you won't have to move files around to display a page for laravel.local right?

I have a datatables table I am using to allow a person to resort the row order of the slides (see attached as example). In my mysql table I am using an additional column to set the row order of each row.
So essentially in mysql I have
id - primary auto increment
SlideOrder - I am using for the sequence
and a couple created/modified datetime etc.

table example
When the user drops a row into place the code I'm using is below to send to server ( I start getting sketchy here on in):

oTable.on( 'row-reorder', function ( e, diff, edit ) 
var result;
var sendloop = [];
	for ( var i=0, ien=diff.length ; i<ien ; i++ )
		var rowData = oTable.row( diff[i].node ).data();
		result = ''+diff[i].newData+','+diff[i].oldData+'';
	var jsonString = JSON.stringify(sendloop);
        type: "GET",
        url: "/dealboxx/ohs/admin/sort",
        data: {data : jsonString}, 
        cache: false

Open in new window

The result of which sends an ajax request and the data variable (when I drag row 1 below row 4 for example):

Had I dragged row 2 below row 3 initially I'd be sending:

Had I dragged row 3 in front of row 1:

When the data gets to my server (my wrong code) does this:
public function sortCourse(Request $request)
	$obj = json_decode($request->input('data'), true);
	foreach($obj as $row)
		$insertArray = explode(",",$row);
		$slidechange = DB::table('ohs_courses_content')
            ->where('id', $slidechange->id)
            ->update(['SlideOrder' => $insertArray[0]]);

Open in new window

Depending on what I initially dragged it may work (if I'm dragging down or up). Couple drags into it and its a mess.

So my logic etc is no doubt totally wrong.

any help would be very much appreciated as always.
I am running composer global require "laravel/installer"

I'm getting the following output

brian@brian-XPS-13:~$ composer global require "laravel/installer"
Changed current directory to /home/brian/.composer
Cannot create cache directory /home/brian/.composer/cache/repo/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/brian/.composer/cache/files/, or directory is not writable. Proceeding without cache
./composer.json is not writable.

Open in new window

I'm running Ubuntu 16.04.
OWASP: Forgery and Phishing
LVL 13
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

I've been taking on the occasional client, undercharging for my hours to meet market rates, but I just discovered Wordpress and I realized I can have enough output (you know for the average site someone wants to have built) and I can charge extra for custom plugins or Laravel or other solutions that require something more than Wordpress.

After 2018 I would like to start taking on clients - I would like to have the following on my portfolio
-Ecommerce site for local business built with Woocommerce
-Ecommerce site built for another local business built with Woocommerce rewritten in Laravel, possibly with a new design possibly redone with wordpress - a social media site for people with prader willi syndrome written in Laravel - a streaming audio site for Umphrey's Mcgee written with Laravel and React

Would listing these sites be a good idea or a bad idea? Should I use Google Adwords? How much do I need to save up for advertising when I build a site advertising services?

I'm going to offer hosting and security. I'm studying Cyber Security and I don't know if I should put that.

I have Schizophrenia and Bipolar and it's a lot harder for me to communicate professionally that it is for most people. Presenting myself well will be a challenge, but I know that my work will be good. I have to work very hard at this, it doesn't come naturally to me, at least not since my diagnosis.

I want to create a streaming audio site for a band that allows taping. A site that it will be similar to is this one

How do I create a Streaming Audio site?

I'm not going to mess with Laravel right now, but I want to create a primitive Model View Controller for this site. Can you reference materials on how to build a MVC site?

I am a Cyber Security major. I've done a lot of programming as a hobbyist, and when I got into Java (and later when I looked at Swift) I felt like I was experiencing some major breakthroughs with Object Oriented Programming and PHP.

I have Crohn's so I didn't even complete the first course which only went up to multidimensional arrays.

So now I need some guidance - do I work out of PHP Patterns Objects and Practice before learning a framework? That book covers Object Oriented Design as well as the concepts.

Should I do that or just move to Laravel and start learning that?

What would be best.

A huge question I have about object oriented frameworks are - can you add functionality that's not built into the framework into your application?

When designing a complex website do you want to use an existing framwork or build your own? If you use an existing one and functionality isn't built in how do you add functionality?
I have 5 tables namely product, category, price, inventory and image.

In my product table I have a foreign key column (category_id_fk) referencing to category table primary key column (id). In my product model I have the following function defined:

    public function price(){
		return $this->hasOne('App\Models\Price','product_id_fk');
    public function inventory(){
		return $this->hasOne('App\Models\Inventory','product_id_fk');
    public function image(){
		return $this->hasMany('App\Models\Image','product_id_fk');
    public function category(){
                return $this->belongsTo('App\Models\Category','id');

Open in new window

In my category model I have the following function defined:

      public function product(){
		return $this->hasMany('App\Models\Product','category_id_fk');

Open in new window

I have performed the following query:

$product = Product::with('price','inventory','image')->get();

Open in new window

The result is it return all records that exist in the product table and associated tables (price, inventory, image) which is correct.

However when I attempt to perform similar action by including the category table

$product = Product::with('category','price','inventory','image')->get();

Open in new window

The result is it return all records that exist in the product table and associated tables (price, inventory, image) but the category record is incorrect (either null or unrelated record).
Hey, guys!

Here's a snippet from a page called "user.class.php:"

 function updateDevices() {
        global $S;
        global $CN;
        $maxHistory = date('Y-m-d',strtotime("now - 2 weeks"));
        $R = new xajaxResponse();
        $fitBitCalls = array( '/1/user/-/body/weight/date/'.date('Y-m-d').'/'.$maxHistory.'.json',
        //See if this user any devices that have not been synced.
        $stmt = $CN->prepare("SELECT * 	FROM hraUserDevices  UD INNER JOIN hraUserDeviceTypes UT  ON UD.udtID = UT.udtID  WHERE usrID = ? AND (DATEDIFF(day,udFetchedLastDate,getdate()) IS NULL OR DATEDIFF(day,udFetchedLastDate,getdate()) >=1) AND (udUpdating IS NULL  OR udUpdating !=1 OR DATEDIFF(day,udFetchedLastDate,getdate()) >=2)");
        $devices = $stmt->fetchAll();
        $update = $CN->prepare("UPDATE  hraUserDevices SET udUpdating = ? WHERE udID = ? ");

Open in new window

The question I have is, "What is $CN?"

Obviously, it's a database connection. My problem is that it's not defined anywhere on the page, nor is EVER defined that I can see anywhere in the app.

You do, however, have this at the top of the same page:


	function __construct(PDO $conn) {
		if (!isset($conn))
			throw new Exception('User objects must be passed a PDO Connection object ($this->cn) upon construction');
		$this->cn = $conn;

Open in new window

Is there a convention that I'm missing? $CN is not equivalent to $cn, and yet throughout the entire app you see repeated references to $CN but I can't find anywhere that $CN is actually defined.

Any ideas?
Hi I want to update the DB when drag and drop.

I post here the question on SO and you can check all the code.

I will be really appreciated, i'm really stocked.



Laravel is a free, open-source PHP web application framework for the development of web applications following the model–view–controller (MVC) architectural pattern. Some of the features of Laravel are a modular packaging system with a dedicated dependency manager, different ways for accessing relational databases, utilities that aid in application deployment and maintenance, and its orientation toward syntactic sugar. Laravel is regarded as one of the most popular PHP frameworks.

Top Experts In