Laravel

120

Solutions

137

Contributors

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

Hi All,

I use laravel.

I've change it to UTC To Asia\Jakarta :

// 'timezone' => env('APP_TIMEZONE', 'UTC'),
    'timezone' => env('APP_TIMEZONE', 'Asia\Jakarta'),

But it still at column Created_At using UTC time.

What should I do ?

Thank you.
0
Expert Spotlight: Joe Anderson (DatabaseMX)
LVL 19
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Hi Experts,

I create a laravel project and using MS SQL database.

 protected function authenticated(Request $request, $user)
    {
        // $user->update([
        //     'last_login_at' => Carbon::now()->toDateTimeString(),
        //     'last_login_ip' => $request->getClientIp()
        // ]);

        // Check to see if the users account is confirmed and active
        if (! $user->isConfirmed()) {
            auth()->logout();

            // If the user is pending (account approval is on)
            if ($user->isPending()) {
                throw new GeneralException(__('exceptions.frontend.auth.confirmation.pending'));
            }

            // Otherwise see if they want to resent the confirmation e-mail

            throw new GeneralException(__('exceptions.frontend.auth.confirmation.resend', ['url' => route('frontend.auth.account.confirm.resend', e($user->{$user->getUuidName()}))]));
        }

        if (! $user->isActive()) {
            auth()->logout();

            throw new GeneralException(__('exceptions.frontend.auth.deactivated'));
        }

        event(new UserLoggedIn($user));

        if (config('access.users.single_login')) {
            auth()->logoutOtherDevices($request->password);
            // Auth::logoutOtherDevices($request->password);
        }

        
        return redirect()->intended($this->redirectPath());
    }

Open in new window


Please see these code:

    // $user->update([
        //     'last_login_at' => Carbon::now()->toDateTimeString(),
        //     'last_login_ip' => $request->getClientIp()
        // ]);

If I uncomment it then it is error.

Please the attachment.

What is wrong?

Thank you.
Error-update-users-table.PNG
1
Hi All,

I want to email to several hundreds of users from database using Laravel.

I use gmail SMTP.

I try below code, by I get error. 500 - Internal Server Error.

                    foreach($users as $user){
                        $data = array(
                            'username' => $user->name,
                            'useremail' => $user->email,
                            'message' => $broadcast->message,
                            'subject' => $broadcast->subject,
                            'senderemail' => $sender->email,
                            'sendername' => $sender->name,
                            'attachment' => public_path('files').'/'.$broadcast->file,
                        );

                        //
                            sendBroadcastEmail::dispatchNow($data);

Open in new window


What is wrong with those code ?

Thank you.
0
hi laravel project not starting in browser localhost/cms/public/
Installing laravel/laravel (v5.2.31)
  - Installing laravel/laravel (v5.2.31): Loading from cache
Created project in cms
> php -r "copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 58 installs, 0 updates, 0 removals
  - Installing kylekatarnls/update-helper (1.2.0): Downloading (100%)
  - Installing symfony/polyfill-ctype (v1.12.0): Downloading (100%)
  - Installing vlucas/phpdotenv (v2.6.1): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.12.0): Downloading (100%)
  - Installing symfony/var-dumper (v3.0.9): Downloading (100%)
  - Installing symfony/translation (v3.0.9): Downloading (100%)
  - Installing symfony/routing (v3.0.9): Downloading (100%)
  - Installing symfony/process (v3.0.9): Downloading (100%)
  - Installing symfony/polyfill-util (v1.12.0): Downloading (100%)
  - Installing symfony/polyfill-php56 (v1.12.0): Downloading (100%)
  - Installing psr/log (1.1.2): Downloading (100%)
  - Installing symfony/debug (v3.0.9): Downloading (100%)
  - Installing paragonie/random_compat (v1.4.3): Downloading (100%)
  - Installing symfony/http-foundation (v3.0.9): Downloading (100%)
  - Installing symfony/event-dispatcher (v3.4.35): Downloading (100%)
  - Installing symfony/http-kernel (v3.0.9): Downloading (100%)
  - Installing symfony/finder (v3.0.9): Downloading (100%)
  - Installing 

Open in new window

0
hi which php framework i can use to develop ecommerce application like amzom
0
hi am not able to see my laravel project in browser
hi am not able to start  http://localhost/cms/public/

am geting

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404



i did chmod -R o+w cms/storage
i did create projectt

user@myubuntu:/opt/lampp/htdocs/demo/laravel$ composer create-project laravel/laravel cms 5.2.* --prefer-dist

Cannot create cache directory /home/user/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache

Installing laravel/laravel (v5.2.31)

Cannot create cache directory /home/user/.composer/cache/files/, or directory is not writable. Proceeding without cache

  - Installing laravel/laravel (v5.2.31): Downloading (100%)        

Created project in cms

Cannot create cache directory /home/user/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache

Cannot create cache directory /home/user/.composer/cache/files/, or directory is not writable. Proceeding without cache

> php -r "copy('.env.example', '.env');"

Loading composer repositories with package information

Updating dependencies (including require-dev)

Your requirements could not be resolved to an installable set of packages.



  Problem 1

    - phpunit/phpunit 4.8.9 requires …
0
Hi All,

I am a beginner of Laravel and I use MS SQL.
I want to create API to pass image for GET and POST.

The image will be stored to MS SQL database.

How could I do it?

Thank you.
0
I'm working with a small company that runs a website with an e-commerce system running in the Laravel framework with the rest of the site running in WordPress. Now I want to take a copy of all of this so that I can work on stuff without affecting the production site. Naturally there is no existing dev area. This was all set up for them by a 3rd party who have effectively run away and refuse to answer any calls or emails. I've created a VM running Ubuntu 18.04, Laravel (5.7 I think) MariaDB Apache2 and PHP7.2. I can (and have) taken a backup copy of the WordPress items that I can install onto the VM using the Duplicator Pro plugin. I've tested this on the VM and know that I can expand everything there and having done so I can at least rung the CMS side of WP although seeing the actual web pages is difficult.

I need to get this running partly because I may need to move from the existing hosting arrangement so want to use this as a sort of trial run in addition to creating a dev setup. My question is what do I need to do to get this working? Do I need to make changes in the Laravel set up? It's still got the "your-project" folder where I've put things like phpminiadmin.php (like phpMyAdmin but just one page) so I know that all the bits are running. Can I get away with just duplicating the file and folder structure of the production site and then run the Duplicator Pro installer script to set up the site? Am I being too naïve here? :-)
0
Hi All,

I have application that created with laravel and publish to windows server.
Then I want to create development environment.
So I copy from production folder to a new one.
I create a new website that pointed to the new folder.
I could login, but after login error message 500 | server error.
What is going on ?

Thank you.
0
Hi,

I have added a function to enable or disable accounts. I have added a field 'login_enabled' to the user database. During login, I check if login is allowed or not:

// Override to only allow active accounts
    protected function credentials(Request $request)
    {
        return ['email' => $request->{$this->username()}, 'password' => $request->password, 'login_enabled' => 1];
    }

Open in new window


However, there is one loophole. If you do a reset password request, the user is able to do so, and will be logged in once after the reset.
So I need to block password reset for accounts where login_enabled = 0 in the DB. However, I can't find where this is done.
Any suggestions?

Thanks!
0
Learn Ruby Fundamentals
LVL 19
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Hi All,

I have problem with queue laravel at windows server.
It does not run all the time.

How could I solve this problem ?

Thank you.
0
Hi All,

I have below code :

<?php

namespace App\Api\V1\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Mail;

date_default_timezone_set('Asia/Jakarta');

class ForgotPasswordEmailController extends Controller
{

    public function index(Request $request){
       $email = $request->email;
       //check email ke db atau sp
//       $user = User::where('email', $email)->first();
//       if ($user){
//            //jika user ditemukan
//            //kirim email
//           $this->sendEmail();
//           return response("Berhasil", 200);
//       }else{
//            //jika user tidak ditemukan
//           return response($email." tidak terdaftar", 403);
//       }

        //kirim email dengan parameter password yang sudah di ambil dari db/sp
        $this->sendEmail($email);
        return response()->json([
            'code' => "0",
            'message' => "Password sudah dikirim ke email anda. Silahkan buka email anda. Terimakasih"
        ]);
    }

    public function sendEmail($email){

       $this->pwd = str_random(8);

        Mail::send('sample-email', ["content" => $this->pwd], function($message) use ($email) {
            $message->to($email, 'Forgot Password')
                ->subject('Forgot Password');
                $message->from('bachmansabar@gmail.com','Nama Kamu');
        });



    }

    public function updateProfilePassword(Request $request)
    {
        $empcode = $request->input('empcode');
  

Open in new window

0
Hi All,

I am a newbie using API Laravel.

I have created below :
1. api.php at folder D:\SMIMobileESS\routes
     $api->get('email', 'App\\Api\\V1\\Controllers\\ForgotPasswordEmailController@email');

2. ForgotPasswordEmailController.php at folder D:\SMIMobileESS\app\Api\V1\Controllers

What else should I do in order to make it work when get called from anywhere?

Thank you.
1
Can any one tell me how to use stored procedure in Laravel
Step by step because I am not familiar with Laravel
So please help

Thank you
By Mohan Singh
0
Hi,
I have a file I'm retrieving via ftp in laravel from a 3rd party who provides it as pipe-delimited. I can get and store the file fine.. but I need to open it and convert the pipes to a comma-delimited file and save the changes.

Any idea how to accomplish this?

Small sample chunk of the file is:

ADID |CompanyID|CompanyName|Category |StockNumber|Vin |Status |Year |Make | Model |Trim |KMS |Exterior Color |Mfg Exterior Color | Interior Color | FuelType |Drive |Engine Size |Transmission |Doors |Passenger |Cylinder |Body |Price |HidePrice |Options |AdDescription | FinancingIsAvailable | FinancingPayment |FinancingPaymentType | FinancingNumberOfPayment |FinancingDownPayment | FinancingSource |FinancingType | FinancingOdometer |FinancingDescription |ManufactureProgram |Warranty |WarrantyDescription | MainPhoto |OtherPhoto|ModifiedDate|CreatedDate
43686979|20046119910706|Johns Volkswagen|"Sport Utility"|V59201PC...... 

Open in new window

0
Hello experts,

Need help with getting our feed to load the page quicker by loading artwork one at a time..it is a large feed and need better way of loading so it does not use a lot of data... http://www.einsteinsolutions.xyz/chaminuka/public/home. the page is loading art that is being uploaded..we have over 1000 artworks to upload but need a way of having an infinity scroll or lazy load that does not consume too much data on page load, and makes the page load slow.  Is they way to load each item in the array one by one like it is on pexels.com , and saving bandwidth.  Help here would be appreciated.
1
I have some complex queries with many joins i am using in a laravel project.
Currently all queries are in my controller which i want to refactor into a App\Queries namespace.

I am stuck on the app flow, would i call these queries from my model, or my controller directly?

would this be a correct structure?

<?php 
namespace App\Queries;
//App\Queries\GetClient;

class Client {

public function get($cID){

$client = DB::select( DB::raw("

select
client_id,
client_name,
client_phone,
client_address
from clients
where client_id = :cID"
), array("cID" => $cID));

return $client;

}

}

Open in new window


then how would i call this query from my controller/model?

<?PHP

//call from model ??
//call directly from controller??

public function show(Request $cID){

$client = new App\Queries\GetClient->get();

//return to view or what ever

}

Open in new window


does this make sense ? am i way off?
0
Hi,  

I am having a problem with Docker CE  (Docker version 18.09.1, build 4c52b90)

on Centos 7.  The problem is with MACVLAN Bridging I am trying to configure a MACVLAN bridge with a exclusion of 192.168.1.2 using the following code.

docker network create -d macvlan \
  --subnet=192.168.1.0/24 \
  --gateway=192.168.1.1  \
      --aux-address="router=192.168.1.2/24" \
   -o parent=enp0s3 pub_net

I get the error:  1Error response from daemon: Pool overlaps with other one on this address space
or no matching subnet for aux-address

When this is sorted out I would like to run this command:

docker run -p 8000:443/tcp  --rm -itd   --network pub_net   --name my_pub_net-alpine   alpine:latest   ash

does anyone know how to fix this problem or give me a workaround so I can forward ports for Nginx.

Kind regards

Justin
0
A program from laravel is sending Mail via smtp lotus notes, content of the body that includes image doesn't display the image at clients email, anyone had the same issue?
0
OWASP Proactive Controls
LVL 19
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Swift_TransportException in F:\xampp\xampp\htdocs\GitLabTest\connect-export-web-100-industry-type-changes\textile\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/?p=WantAuthError u7-v6sm8508148pfl.34 - gsmtp
"
0
I am using laravel eloquent to retrieve values from mysql database. The example return value below is below is retrieved from my browser:

{"cart":[{"id":1,unit_price":"0.01","total_price":0.01}]}

Open in new window


I notice that the attribute unit_price has a double quote where else the attribute id and total_price on the other hand has no double quote.

In your opinion is this acceptable? What could be the root cause of the result?

Please note that the attribute total price, its value is the result of multiplying two values. Example:

$cart['total_price'] = $variant->list_price * $cart['quantity'];

Open in new window


Your help is kindly appreciated.
0
The following is coded in Laravel framework:

QUERY

$shipping = DB::table('shipping')->where('country',$delivery->country)->first();
$data= json_decode(json_encode($shipping),true);

Open in new window


RESULT

array (
  'id' => 3,
  'carrier' => 'EN',
  'country' => 'AU',
  'rates_json' => '{"rates": [{"international": [{"zone4": [{"to_kg": "2", "total": "1", "from_kg": "1"}, {"to_kg": "4", "total": "2", "from_kg": "3"}]}]}]}',
)  

Open in new window


In MySQL database i stored rates_json in a json datatype column. The attribute from_kg and to_kg is a range.  

I intend to retrieve the total if a value is between the range. For instance, if value 1.5 is between  1 and 2 then the total is 1.

Your help is appreciated.

Thank You.
0
Hi.

I'm currently creating an application that is used for planning certain projects.

I'm running Laravel 5.7, with AdminLTE.

Currently I'm implementing the functionality to create projects and the basic CRUD functions that come along with them. Everything is working, but there's one small detail.

We assign hours per week to a project, but a project can last longer than one week, of course.

-----

What users do is they insert a start week, for example week 40 and an end week, for example week 45.

What I want to do is the following: Have a button / link below the weeks that says "Assign hours".

When that button / link is clicked, there should be a number of inputs that pop up, corresponding to the number of weeks.

For example: Start week = 40, end week = 43, I should get 4 inputs.

----

However, I have no clue how to do this since I am not familiar with JavaScript or jQuery.

The second issue is: how would I store this in a database?

I was thinking about creating a seperate table named 'project_hours' or something like that which contains the week number, project number, user id and the assigned hours for that week. How would I loop through the set of inputs thats always a different number to store them in my db?

Any help is appreciated.

I have this create view:

@extends('adminlte::page')

@section('title', 'AdminLTE')

@section('content_header')
@stop

@section('content')
	@include('inc.messages')
	<div class="box 

Open in new window

0
How to generate CSV file and send an email as an attachment of that csv file in laravel?
1


I have so for been updating the data. Now when some lecturer writes say, completed in the comments section and checks completed radio button. Now next time when the same teacher checks it then it must show that the sub/chap has been completed. So how to do that in angularjs and php? Any help would be appreciated. Please do help me i am stuck.
0

Laravel

120

Solutions

137

Contributors

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
Laravel
<
Monthly
>