lundi 1 août 2016

laravel throws error when returning ->first() in controller

this:

public function show($id)
    {
        return DB::table('apps')->where('id', $id)->first();//->get();
    }

will return an error: UnexpectedValueException in Response.php line 399: The Response content must be a string or object implementing __toString(), "object" given.

this will not return an error (but I cant use it since I need an object not array):

public function show($id)
    {
        return DB::table('apps')->where('id', $id)->get();
    }

whats wrong?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2adnYWt
via IFTTT

laravel relationship between user and user_info tables

i'm newbie on laravel 5.1 so i have an easy problem.

i have user table and user_info table. if i create a user, i want to create another record for user_info table and if i get user then i want to get user_info record but i don't do this.

codes are below.

<?php
namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{

    protected $fillable = [
        'name', 'email', 'password',
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];

    public function profile()
    {
        return $this->hasOne('Http\Models\userInfo');
    }
}

this is userInfo class

<?php

namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;

class userInfo extends Model
{
    protected $table = 'user_info';
}

this is welcome page

@extends('master')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-default">
                <div class="panel-heading">Welcome</div>

                <div class="panel-body">
                    <pre></pre>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

i got this error

FatalErrorException in Model.php line 740:
Class 'Http\Models\userInfo' not found

where am I doing wrong?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aDZXGa
via IFTTT

change css style after modal is hide

when I click on my table row there appear modal window and change "tr" background-color indicates for each row was modal opened. However, when I close my modal background color of tr remains the same. How to change it to default?

<tr class='revisions'>
      <td>
      </td>

<td class="text-right">
                    <a  
                       data-toggle="modal" 
                       data-target="#revisionEdit" 
                       class='btn btn-warning revisionEdit'>
                        <span class="glyphicon glyphicon-pencil"></span>
                    </a>

</td>
</tr>



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2amKt8v
via IFTTT

All Laravel routes gives 404 on nginx subdirectory

I have problem with nginx configuration. I wanna have Laravel app in subdirectory, exactly domain.com/alfa. At domain.com is another app. And now all Laravel routes gives 404 on nginx subdirectory. Could someone help you find an error?

My paths:

  • /var/www/ <-- it's for domain.com
  • /var/www/alfa_path <-- it's for domain.com/alfa

It's my nginx configuration:

server
{
        listen 80;
        server_name domain.com;

        root /var/www;
        index index.php index.html index.htm;

        location / {
        }

        location /alfa {
                root /var/www/alfa_path/public;
                index index.php index.html index.htm;
                try_files $uri $uri/ /alfa_path/public/index.php?$query_string;
        }

        location ~ .php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/www.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }

        location /phpmyadmin {
                root /usr/share/;
                index index.php index.html index.htm;
                location ~ ^/phpmyadmin/(.+\.php)$ {
                        try_files $uri =404;
                        root /usr/share/;
                        fastcgi_pass unix:/var/run/www.sock;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include /etc/nginx/fastcgi_params;
                }
                location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                        root /usr/share/;
                }
        }

        location /phpMyAdmin {
                rewrite ^/* /phpmyadmin last;
        }
}

laravel 404



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aMjSTg
via IFTTT

Sendgrid can't receive emails in application

I'm trying to receive e-mails sended to my account on sendgrid. So What I basically have is the following:

Good, So I'm running Nginx on that server and I want to be able to get the e-mails send to @rallypodium.be to be saved and stored inside of my database wich is on the same DigitalOcean server.

I've set up the Inbound Parse like this:

HOST: www.rallypodium.be URL: http://ift.tt/2aDC5Td

My domain is whitelabled.

I've read the docs for 10 times and still didn't figure out what I'm doing wrong.

This is how I store them:

public function ReceiveMail(Request $request)
    {
      DB::table('email')->insert([
          'headers' => $request->get('headers'),
          'html' => $request->get('html'),
          'from' => $request->get('from'),
          'to' => $request->get('to'),
          'cc' => $request->get('cc'),
          'subject' => $request->get('subject'),
          'dkim' => $request->get('dkim'),
          'spf' => $request->get('spf'),
          'envelope' => $request->get('envelope'),
          'charsets' => $request->get('charsets'),
          'spam_score' => $request->get('spam_score'),
          'spam_report' => $request->get('spam_report'),
          'attachments' => $request->get('attachments'),
          'attachment-info' => $request->get('attachment-info'),
          'attachmentX' => $request->get('attachmentX')
      ]);
      return 'ok';
    }

If I take a look at the Activity Feed, then I see this:

enter image description here

The error message is the following:

EMAIL: robin@rallypodium.be

REASON: error dialing remote address: dial tcp 104.24.101.114:25: i/o timeout

SMTP-ID: <1f7f313f27fd051b525581562e6af9b5@rallypodium.be>

PROCESSED STRING: August 1, 2016 - 06:53:45PM

MSGID: J1irmehmR_GELI7tIpPXNg.filter0810p1mdw1.1861.579F77CC27.0

Can someone help me out? Thanks!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aMjynh
via IFTTT

Laravel migration with SQLite

Hello i have migration in Postgres and SQLite, I am facing problem with SQLite database. Same migrations are for 2 diffrent database. Postgres migration is OK, but SQlite not good. I added migration for altering table and adding new field.

   public function up()
    {
        Schema::table('retailer_products_photo_fix', function ($table) {

            $table->integer('currency_id')->unsigned();
            $table->foreign('currency_id')->references('id')->on('currency')
               ->onUpdate('cascade')->onDelete('cascade');

           $table->dropColumn('currency');
        });


    }

but i got error

General error: 1 Cannot add a NOT NULL column with default value NULL

When i try to add nullable() field isn't created and when i add default value 0 or 1 i got constraint error because i related table i have rows 1 and 2. What to do?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ap1cwk
via IFTTT

How with eloquent pull lists and sorted connected taks

How with eloquent pull lists and sorted connected tasks to those list(something like this

$classes = Classes::find(1)->student;

but for all lists(for example I thought this will work but sadly no)

$lists = Lists::all()->task;



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2aJtdhs
via IFTTT