mardi 31 janvier 2017

create additional validation on the form registers the default laravel

This users(mstanggota) table:

 Schema::create('mstanggota', function (Blueprint $table) {
            $table->increments('id');
            $table->string('no_anggota',10);
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

Mstbeasiswas table:

Schema::create('mstbeasiswas', function (Blueprint $table) {
            $table->increments('id');
            $table->string('no_anggota',10)->unique();
            $table->string('nm_anak',25);
            $table->string('kt_lahir',25);
            $table->date('ttl');
            $table->String('nm_skl',50);
            $table->String('st_pend',6);
            $table->String('lbg_pend',6);
            $table->String('prov_skl');
            $table->String('jenkel',9);
            $table->integer('k_umum');
            $table->integer('k_khusus');
            $table->integer('score')->nullable();
            $table->boolean('status')->default(0);
            $table->string('ket',250)->nullable();
            $table->string('img1',50)->nullable();
            $table->string('img2',50)->nullable();
            $table->string('img3',50)->nullable();
            $table->timestamps();
        });

I would like to make an additional validation. If no_anggota does not exist on table mstbeasiswas then the user cannot register, what is there that could help me? :(

register form view-> enter image description here



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

How can I get distant many to many relationship with Eloquent

INFO: Using Laravel 5.2
BaseModel extends Eloquent

I have three models that I want to get a relationship for. Here are my models and there relationships.

class A extends BaseModel
{
    protected $table = 'a';

    use SoftDeletes;

    public function b ()
    {
            return $this->hasMany(B::class);
    }

}

For class B

class B extends BaseModel
{
    protected $table = 'b';

    use SoftDeletes;

    public function A ()
    {
            return $this->belongsTo(A::class);
    }

    public function C ()
    {
            return $this->belongsTo(C::class);
    }
}

For class C

class C extends BaseModel
{
    protected $table = 'c';

    use SoftDeletes;

    public function b ()
    {
            return $this->hasMany(B::class);
    }

}

I want to be able to get the distant C relationships from A. For instance:

$cCollection = $a->b->c;

That is find me all Cs that belong to Bs that are owned by A.

I know I can call $a->with('c.b') but that query is computationally expensive. I want to be able to call it just like a normal relationship. Any ideas?



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

controller not found laravel 5.2

ReflectionException in Route.php line 280:
Class App\Http\Controllers\admin\FotoAlbumController does not exist

I've create my controller with this command:

php artisan make:controller admin\\FotoAlbumController --resource

But, it can't find my controller when i submit it with my form. here's my forms code:

<div class="modal-body">
    {!! Form::open(['url' => 'admin/detailalbum', 'class' => 'form-horizontal', 'files' => true]) !!}
        <input type="hidden" name="id_album" value="">
        <div class="form-group">
            <label for="foto" class="col-md-4 control-label">Photo</label>
                <div class="col-md-6">
                    <input type="file" id="foto" name="foto" value="" required>
                </div>
        </div>
        <div class="form-group">
            <label for="caption" class="col-md-4 control-label">Caption</label>
            <div class="col-md-6">
                <textarea id="caption" name="caption" class="form-control" required></textarea>
            </div>
        </div>
</div>
<div class="modal-footer">
    <button type="submit" class="btn btn-default">Submit</button>
    {!! Form::close() !!}
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>

Here's my routes.php:

Route::resource('admin/detailalbum', 'admin\\FotoAlbumController');

And here's my controllers code:

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Session;
use Validator;
use App\DetailAlbum;

class FotoAlbumController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $requestData = $request->all();
        $noo = 'admin/album/'.$request['id'];
        $rules  = [
            'foto' => 'required|mimes: jpg, jpeg, png, gif',
            'caption' => 'required',
        ];

        $validasi = Validator::make($requestData, $rules);

        if ($validasi->fails()) {
            return back->withErrors($validasi)->withInput();
        } else {
            $extension = $request->file('foto')->getClientOriginalExtension();
            $fileName = rand(11111, 99999) . '.' . $extension;

            $request->file('foto')->move($uploadPath, $fileName);
            $requestData['foto'] = $fileName;

            DetailAlbum::create($requestData);
            Session::flash('success', 'Berhasil menambahkan Foto pada album tersebut.');

            return redirect($noo);
        }
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

Is that something wrong with my code?

PS: i've already use composer dumpautoload and php artisan clear-compile



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

Laravel stripe checkout.js not loaded

I'm developing a webapp that allows one-off payments. I'm using Laravel with Cashier for that.

I'm displaying a number of products with the typical Stripe pay button. Clicking on it should display the checkout.js form but this is not happening.

The product view is basically a loop that displays the Stripe button:

<div class="row">
 @foreach ($products as $product)
    <form action="" method="POST">
    
     <div class="col-sm-5 col-md-5">
       <div class="thumbnail">
         <div class="caption">
           <h3></h3>
           <p></p>
           <p>Buy for $</p>
           <p>
           <script src="http://ift.tt/1doUtf9" class="stripe-button"                       
            data-key=""
            data-amount=""
            data-name="Stripe.com"
            data-description="Widget"
            data-locale="auto"
            data-currency="usd">
           </script>
          </p>
        </div>
       </div>
      </div>
     </form>
   @endforeach
   </div><!--row-->

When I click on the button, the Stripe pay overlay does not load.

The relevant routes are

Route::get('product', 'ProductController@index')->name('product');
Route::post('pay/{product}', 'OrderController@payWithStripe')->name('pay');

The Controller file is as follows:

public function payWithStripe(Request $request, Product $product) {
  $token = $request->input('_token'); 
  return $this->chargeCustomer($product->id, $product->price, $product->name, $token);
}

public function chargeCustomer($product_id, $product_price, $product_name, $token) {
    \Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));

    if (!$this->isStripeCustomer()) {
       $customer = $this->createStripeCustomer($token);
    }
    else {
       $customer = \Stripe\Customer::retrieve(access()->user()->stripe_id);
    }
 return $this->createStripeCharge($product_id, $product_price, $product_name, $customer);
 }

 public function createStripeCharge($product_id, $product_price, $product_name, $customer) {
   try {
       $charge = \Stripe\Charge::create(array(
           "amount" => $product_price,
           "currency" => "usd",
           "customer" => $customer->id,
           "description" => $product_name
        ));
    } catch(\Stripe\Error\Card $e) {
       return redirect()
           ->route('frontend.user.product')
           ->with('error', 'Your credit card was been declined. Please try again or contact us.');
    }
        return $this->postStoreOrder($product_id);
  }


 public function createStripeCustomer($token) {
    \Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));

    $customer = \Stripe\Customer::create(array(
        "description" => access()->user()->email,
        "source" => $token
    ));

    access()->user()->stripe_id = $customer->id;
    access()->user()->save();

    return $customer;
 }

 public function isStripeCustomer() {
    return access()->user() && \App\Models\Access\User\User::where('id', access()->user()->id)->whereNotNull('stripe_id')->first();
 }

The issues are:

  • 1) The overlay payment (where VISA card details should be entered) is not displayed
  • 2) In the chargeCustomer function, the customer is not generated in Stripe. I get an error "No such token: xxxxxxxx". Printing it out is definitely the hidden token (checked from the pageview). The problem might be related to the _token, where I see that stripeToken should be used. However stripeToken always returns null.


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

On server my application is looking for uppercase table name instead of lowercase

i have this table on my local xampp , the table name is tags , this works perfectly fine on my local system , but when i upload this table to my server , i get the following error:

enter image description here

The tables i have under the table peckinga_blog are the following:

enter image description here

As you can see tags is one of them , Also for the tags table i have the following migrations in my laravel application:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTagsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('Tags', function (Blueprint $table) {
            $table->increments('id');
            $table->mediumText('tag');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('Tags');
    }
}

Now why am i getting this this error in spite of my database clearly being available ? What can i do to so that my server will look for the database tags instead of Tags ?



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

Folders for subdomain-specific files beside Laravel's folder

I'd like to make a Laravel app, where the subdomains' folders are beside the Laravel project folder. If a file (eg. a controller file) is not found in the current subdomain's folder, then it's loaded from the main project folder.

So my folder tree would look like this:

  • Laravel project (all Laravel files)
    • app
    • Http
      • Controllers
      • ...
    • ...
    • ...
  • Subdomain1 (only subdomain specific files)
    • app
    • Http
      • Controllers
      • ...
    • ...
    • ...

Can I have Laravel behave like this?

Thank You for your help!



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

Laravel 5 Facebook 'Share' Customization

I'm currently in the process of learning Laravel 5 and would like to customize a blade file that allows users to share content. It functions well, I'd just like to implement some customization.

Here is the code in the heading area I've been directed to modify for my needs (edited the content for the purposes of this question);

@section('fb_title', "This is my Facebook title")
@section('fb_description', $article->description)
@section('title', $article->title)
@section('description', $article->description)
@section('meta_author', $article->member->name)
@section('image', $article->member->profile_picture)
@section('content')

I'm attempting to replace the 'image' section with my own custom image I have uploaded to my server but I am unable to find a solution on how to use an URL, or should I be using the <link rel="image_src"> solution?

Lastly I'd like to use my own custom Share button, however the articles I have come across so far that explain how to do this are either outdated, or do not look like the code I have below;

   <div class="fb-share-button pull-right" style="display: block;" data-href="" data-layout="button" data-size="large" data-mobile-iframe="true">
<a class="fb-xfbml-parse-ignore" target="_blank" href="">Share it on Facebook</a></div>

Any guidance on these minor issues would be greatly appreciated, thank you!



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

Laravel-Excel Macro support

I've got a simple question, does Laravel-Excel has Macro support? I want to get data from my sheet into my database. But it seems like the package can't handle macro's. My code below:

\Excel::selectSheets('Uitslagen_Site')->load($storagePath, function($reader) {
        foreach ($reader->toArray() as $row) {
            // Insert into database
        }
    });

But this is my output if I var_dump $row:

Array ( [ronde] => 0 [tijd] => [poule] => 0 [team1] => 0 [team2] => 0 [scheidsrechter] => 0 [uitslagen] => 0-0 | 0-0 [dag] => Zondag [dagdeel] => Zondagochtend [set_1] => 0-0 [set_2] => 0-0 [totaal] => 0-0 )

This needs to be the output (just an example):

Array ( [ronde] => 1 [tijd] => 9:00 [poule] => A [team1] => Team 1 [team2] => Team 2 [scheidsrechter] => Team 3 [uitslagen] => 20-25 | 20-25 [dag] => Zondag [dagdeel] => Zondagochtend [set_1] => 20-25 [set_2] => 20-25 [totaal] => 20-25 )

Anybody know a solution for this?

Thanks in advance.



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

How to filter empty/null multidimensional arrays

The goal was this - return !empty($arr), using array_filter. But still the empty arrays are not filtered. I tried using array_values and then apply array_filter but still the result was the same. Any Ideas on how to filter these empty arrays? That would be a greater help for me thank you! by the way this is a multidimensional array.



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

Lumen by Laravel - Validation on Routes vs. Validation in Models

I wonder which solution is the best one for creating a professional secure Restful API by Lumen.

Lumen lets validating on routes as described on its documentation. As described on the documentation, validation in models/controllers is easy by Validator::make. The question is, which one is the best professional choice when it comes to validating and inserting data.



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

Not able to resolve cause for LARAVEL error: " Uncaught exception 'ReflectionException' with message 'Class session does not exist'"

I've cloned a working LARAVEL project.

The LARAVEL project works fine on my local vm, but when I push to production server I get the following error when loading the site in the browser.

PHP message: PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class session does not exist' in /.../vendor/laravel/framework/src/Illuminate/Container/Container.php:779 Stack trace: .0 /…/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('session') .1 /.../vendor/laravel/framework/src/Illuminate/Container/Container.php(659): Illuminate\Container\Container->build('session', Array) .2 /.../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(644): Illuminate\Container\Container->make('session', Array) .3 /.../vendor/laravel/framework/src/Illuminate/Container/Container.php(1234): Illuminate\Foundation\Application->make('session') .4 /.../vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(148

I've tried everyting from the following post: http://ift.tt/2kNNM0f

In that specific post they mention that you should check the .env and other config files for possible errors and spaces that should not be there. I've double checked this and I am unable to find a fault.

I've double checked the PHP packages that is installed on my vm and made sure all of them are available on the server.

One user mentioned to add the following code to the Container.php head and run the artisan command that gives a issue. My problem is that all the artisan commands run without issue, but the site does not load. The above error can be seen in the nginx error log.

namespace {

    use Monolog\Logger as Monolog;
    class log extends Illuminate\Log\Writer {
       function __construct()
       {
            $this->monolog = new Monolog("local");
       }
    }
}

I've also followed another users suggestion to use backtrace by adding the following code above the $reflector = new ReflectionClass($conrete) line.

Updated Code in function build within Container.php

dump($concrete, debug_backtrace());
$reflector = new ReflectionClass($concrete);

The resulting output of this file can be viewed here (Quite Large): http://ift.tt/2kQmylF or http://ift.tt/2kNRHtT

Migrations also work fine so DB connection should be good.

Any help would be greatly appreciated. I've tried reinstalling using composer install and this runs without any issues.



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

How to use whereIn to check multiple columns?

I have this query:

$query->whereHas($key,function($q) use($option){
            $q->whereIn('district', $option);
            $q->whereIn('region', $option);
          });

But its not working. I want to check district and region and i get an array from $option



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

Block-scoped declarations not yet supported outside strict mode - Laravel Mix

I'm running Laravel 5.4 on my Homestead vagrant box. I've installed all the npm dependencies with npm install command. That didn't produce any errors.

In my webpack.min.js file I have:

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js([
        'resources/assets/plugins/jquery-1.11.3.min.js',
        'resources/assets/plugins/bootstrap/js/bootstrap.min.js',
        'resources/assets/js/main.js'
    ], 'public/js'
);

mix.combine([
       'resources/assets/plugins/bootstrap/css/bootstrap.min.css',
       'resources/assets/plugins/font-awesome/css/font-awesome.css',
       'resources/assets/css/styles.css'
   ], 'public/css/all.css');

When I want to run npm run production I'm getting the following errors:

> @ production /home/vagrant/projects/nielsvroman
> node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/home/vagrant/projects/nielsvroman/node_modules/laravel-mix/setup/webpack.config.js:120
        let extractPlugin = new plugins.ExtractTextPlugin(
        ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at requireConfig (/home/vagrant/projects/nielsvroman/node_modules/webpack/bin/convert-argv.js:96:18)
    at /home/vagrant/projects/nielsvroman/node_modules/webpack/bin/convert-argv.js:109:17
    at Array.forEach (native)

npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "production"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! code ELIFECYCLE
npm ERR! @ production: `node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script 'node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! This is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/projects/nielsvroman/npm-debug.log

What could be the problem with this?



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

Laravel 5: Call to Undefined Method Response::header() when trying to access data through API?

I built an API with Laravel and while trying to make a get request via URL localhost8000/api/itemsI built a CORS middleware.

<?php

namespace App\Http\Middleware;

use Closure;

class Cors
{

    public function handle($request, Closure $next)
    {
        return $next($request)
            ->header('Access-Control-Allow-Origin', '*')
            ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, OPTIONS')
            ->header('Access-Control-Allow-Headers','Content-Type, Authorization, X-XSRF-TOKEN');
    }
}

When trying to access data via API, localhost:8000/api/items, I get the following URL on my Laravel terminal and

Call to undefined method Symfony\Component\HttpFoundation\Response::header()



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

Using with and withCount together in laravel eloquent

withCount is a new method of laravel to return count of the relations. I'm trying to use with and withCount together. For example:

Article::with('Comments')->withCount('Comments')->paginate();

Problem I'm facing is, in the results is see for example:

comments_count = 10
comments = []

It returns comments array null. I don't know is it possible to get both the results or not. In some articles on different sites, i see withCount still has some restrictions. But not sure what I'm trying to do is possible or not.

Please help me to know about this issue.

Thank you,



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

How to get values from price range slider?

http://ift.tt/1RkjdcI Im using this range slider but i have problem to get values in controller. In blade i have this:

<input type="text" id="amount" readonly name="price" >



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

How to solve TokenMismatchException in VerifyCsrfToken.php line 67

When I have submit form then I am getting a Error. You can view Error Related Token Mismatch Exception. How to solve TokenMismatchException in VerifyCsrfToken.php line 67: error I have already added token Variable.

<input name="_token" value="dZfqvG7m1G0TGtXtWkDoWFXs5wqIwH86mMzCKfTy" type="hidden">

Is there any other solution for that



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

Querying a belongsTo relationship

I have two tables, "tasks" and "courses". There is a one to many relationship setup (tasks belongTo a course, courses hasMany tasks). I am trying to filter my list of tasks, but am confused as to how to query based on a column in the courses table.

In the courses table I have a column called "college_name". I have a dropdown filter, and when I select a college name from that, I want to return all tasks that are linked to rows in the courses table that has the same 'college_name'.

So the query I am trying to build is something along the lines of "select all the tasks that belong to a course with the college_name of X (college name is taken from dropdown select input. In my controller I am getting the dropdown value like this:

$college = Input::get('colleges_filter');

...which returns the college name (e.g. "Oxford College"). I now need to take that add use it in the query, but everything I try errors. Can anyone help please?



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

How can I move the login behvior form the /login URL to my home page in a Laravel application?

I am pretty new in PHP and moreover in Laravel framework (I came from Java) and I have the following problem related to Laravel security.

I have correctly configured my Laravel login system so if I access to the page:

http://localhost:8000/login

I obtain my login page from where I can access to the restriced area of my portal. This is the standard Laravel login page.

My doubt is: can I take this behavior into my home page? Because I have to put the login into a custom login from into my home page (the one that is automatically opened launching http://localhost:8000/).

How can I do this?



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

Laravel and league/flysystem-sftp: Connection closed prematurely

I'll start from the problem and give some additional info then. So the problem is that the SFTP filesystem stops working in 1 day after the process is started. The error it returns is:

Connection closed prematurely /var/www/html/hub/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(2906)

My Laravel app listens on a Redis channel, converts the received data into a CSV file and uploads it through SFTP to another server using the league/flysystem-sftp library. The process that listens/converts in long-living, controlled by supervisor.

All these manipulations are performed by a separate composer package. Originally I passed instances of the connections directly to the package through the service provider of the main app and I though this was the root of the problem:

$sageExportFacade->setDisks(
Storage::disk('sage_local'),
Storage::disk('sage_remote')
);

The code was changed so that it passes callbacks that resolve the connection instances every time the component needs them:

$sageExportFacade->setDisks(
            function (): FilesystemAdapter {
                return Storage::disk('sage_local');
            },
            function (): FilesystemAdapter {
                return Storage::disk('sage_remote');
            }
        );

No luck. The first day it's working just fine, the second day in the morning it crashes saying "Connection closed prematurely". Any idea what it could be?



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

How to create custom pagination link?

Right now i have this link on paginate :

http://ift.tt/2kKijst

http://ift.tt/2kmsxBB

and what i want is this: http://ift.tt/2kKjzMx and so on

Right now i have this:

{!! $properties->appends(['toggle' => Request::get('toggle'), 'search' => Request::get('search')])->render() !!}

How can i change this to have route like this what i want?

i found this:

Route::get('users', function () {
    $users = App\User::paginate(15);

    $users->setPath('custom/url');

    //
});

But problem is that i use one function for multiple stuff so i can not set path in controller.



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

lundi 30 janvier 2017

Laravel5: Can't delete from DB

This is in controller MessagesController:

    public function destroy(Messages $id)
{
    \DB::delete(
            'DELETE FROM messages WHERE id=' . $id
        );
    return redirect()->route('messages.index')->with('message', 'Deleted.');
}

This is routes.php:

    Route::delete('messages.destroy', ['as' => 'messages.destroy', 'uses' => 'MessagesController@destroy']);

This is view file:

   {!! Form::open(array('route'=>['messages.destroy',$message->id],'method'=>'DELETE')) !!}
       {!! Form::button('Delete',['class'=>'btn btn-danger','type'=>'submit']) !!}
   {!! Form::close() !!}

So, I have an error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[]' at line 1 (SQL: DELETE FROM messages WHERE id=[])

I understand that there is no id going to controller. How to solve this?



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

Laravel 5 : deployed on server in public_html give HTTP ERROR 500

I am using laravel 5, I just deployed the code in public_html on the server. When I call the URL it give me the below error

The www.xyz.com page isn’t working

www.xyz.com is currently unable to handle this request.
HTTP ERROR 500

I think this is not a server issue bcoz when I call the phpinfo file http://ift.tt/2jO6Dqp, its work.

I start debugging by echo exit, I found that the problem in bootstrap/app.php at 14 line

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);

Can anyone suggest me why this happening and how to solve this? Thanks

Add the cpanel error log

File does not exist: /home/kkb/public_html/404.shtml
File does not exist: /home/kkb/public_html/404.shtml, referer: http://ift.tt/Rvp0MX
File does not exist: /home/kkb/public_html/404.shtml, referer: http://ift.tt/Rvp0MX
File does not exist: /home/kkb/public_html/404.shtml, referer: http://ift.tt/2jPVsea
File does not exist: /home/kkb/public_html/favicon.ico, referer: http://ift.tt/2jPVsea
File does not exist: /home/kkb/public_html/404.shtml, referer: http://ift.tt/Rvp0MX

My cpanel folder structure for code

enter image description here



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

Laravel API Project - Design and Authentication

I am tasked with building an external API for customers. Without giving any business data away, the database consists of our entire workflow. Events generated, associated tickets and other information, all distinguishable by customer.

I want to build an api with very simple endpoints. For each table, say tickets for example, I wish to have two endpoints:

/tickets            #will return a list of tickets and general information
/ticket/<ticket_id> #More detailed information about the specific ticket

For any customer that authenticates, these routes will only return those DB records for which they are associated.

I have not written a system like this in Laravel before. Am I correct in understanding that Passport is the way to go? I guess I am asking if there are simpler ways to do authentication of this type securely (is Passport overkill)? If we have a small set of customers, and are fine with setting up their authentication for them, would certificates be a better way to go? Or is OAuth2 such the industry standard now that not using Passport is a mistake?

If Passport is best, is it better to have the OAuth2 server and application server be separate sites, or can they be combined into one app?

Thanks for any advice.



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

How to setup Laravel Mix SASS reloading

How to setup the Laravel Mix on version 5.4 to do css livereloading whenever the sass files get compiled? All the tutorials I found are relating to older versions.

I have installed the node modules, and I am running the watch by npm run watch, as stated on the tutorial http://ift.tt/2jNxkeF. So far the webpack.mix.js is as follows:

const { mix } = require('laravel-mix');

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');



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

Custom models for custom query in Laravel

Lets me explain! I have an API with plain php that my app use (returns JSON).

Now I making a web site with Laravel 5.4 to show the same data that the user can see with the mobile app connected with the api.

The problem? I have to make the same logic that I follow in my api (because I need to get the same result). I need to list data but is not directly from one of my table, is from a custom query, then this result of the query I need to do some logic and then create the model that I Want to return to the view.blade.php to loop after all.

Of course, working with Laravel, I don't have to use any api because I'm already on the server side.

It is possible to do what I want? This is an example of my custom model (I put an image from my json of my API, but I need to get the same result with a custom model like I said above) what i gonna have after the query and after make some logic on the query result:

enter image description here



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

How do I toggle a boolean value with a button?

I have a table that lists some tasks, with a column to show if they are completed or not. I have added a button to toggle the "Completed" column, but I can't seem to get the row I select to update. Can someone show me where I am going wrong?

I have created the route, button and method, and it all seems to work but the DB doesn't update (for now I just have the code to change the "completed" column to 1).

Routes:

Route::patch('tasks/complete/{id}', 'TaskController@updateCompleted');
Route::resource('tasks' , 'TaskController');

Button in view:


    
    


Controller:

public function updateCompleted($id)
{

    $task = Task::findOrFail($id);

    $task->completed == 1;

    $task->update();

    Session::flash('message', 'Task updated!');
    return redirect('tasks');

}

Thanks!



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

Laravel: How to enable stacktrace error on PhpUnit

I have a fresh installation of laravel 5.4

I've tried to modify the default test just to see a failing test.

tests/ExampleTest.php

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        $response = $this->get('/ooops');

        $response->assertStatus(200);
    }
}

I was expecting to see more detailed error like no route has been found or defined etc, but instead just this error saying

Time: 1.13 seconds, Memory: 8.00MB

There was 1 failure:

1) Tests\Feature\ExampleTest::testBasicTest
Expected status code 200 but received 404.
Failed asserting that false is true.

/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:51
/var/www/tests/Feature/ExampleTest.php:21

Its really hard to do TDD without meaningful error (yeah I know 404 in this case is enough, but most of the time its not the case).

Is there a way to enable the stacktrace the same as the one displayed on the browser? Or at least closer to that one so that I know what step should I do.

Thanks in advance.



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

Laravel saves child record, but sets foreign key to null

This has got to be a simple fix, as I have done this many times before. But as it stands I am completely stumped. I use the following code to save a parent object Unknown_Tag and its many children.

Method:

public function saveUnknown(Request $request)
{
    $url = $request->url;
    $tag = new Unknown_Tag();
    $tag->url = $url;
    $protocol =
        substr($url, 0, strpos($url, ':'));
    $tag->protocol = $protocol;
    $domain =
        parse_url($url, PHP_URL_HOST);
    $tag->domain = $domain;
    $tag->save();

    //get the path
    $Path = parse_url($url, PHP_URL_PATH);
    if ($Path) {
        $splitPath = substr($Path, 1);
        $paths = explode('/', $splitPath);
        foreach ($paths as $p) {
            $path = new Path();
            $path->path = $p;
            $tag->Paths()->save($path);
        }
    }
    //get Queries
    $splitQuery = parse_url($url, PHP_URL_QUERY);
    if ($splitQuery) {
        $queries = explode('&', $splitQuery);
        foreach ($queries as $q) {
            $query = new Query();
            $q = substr($q, 0, strpos($q, '='));
            IF (SUBSTR($q, -1) != ' ') {
                $q .= ' ';
            }
            $query->var = $q;
            $value = $q = preg_replace('/^[^=]*:/', '', $q);
            $query->value = $value;
            $tag->Queries()->save($query);
        }
    }
}

The Parent Object

class Unknown_Tag extends Model
{
    protected $table = 'unknown_tags';
    public $timestamps = false;
    public function Paths()
    {
        return $this->hasMany('App\Path', 'tag_id', 'ID');
    }
    public function Queries()
    {
        return $this->hasMany('App\Query', 'tag_id', 'ID');
    }
}

The Child objects

class Query extends Model
{
    protected $table = 'queries';
    public $timestamps = false;
    public function Tag()
    {
        return $this->belongsTo('App\Unknown_Tag', 'tag_id', 'ID');
    }
}

class Path extends Model
{
    protected $table = 'paths';
    public $timestamps = false;
    public function Tag()
    {
        return $this->belongsTo('App\Unknown_Tag', 'tag_id', 'ID');
    }

}

When I run all this via a post request, The Parent and all the children are saved properly, but all the child objects have a foreign key that is set to null. If I manually change the foreign key to what it should be, everything works just fine, so I am fairly sure this is not a problem with my database. Can anyone see the obvious that I am missing here?



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

Laravel 5.4 sometimes uses different database credentials

Laravel 5.4 randomly (sometimes not always, or even frequently) tries to connect to a database using the default forge credentials...

I've changed the .env variables to my local MySQL Server already... and as I said it ONLY happens SOMETIMES (rarely)...

I'm able to force the issue to happen by spamming an ajax request that I created.

I did NOT tell Laravel to use a secondary database connection anywhere (unless there's an alternate connection by default when you first install).

Here's the error.

QueryException in Connection.php line 647: SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from users where users.id = 2 limit 1)



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

Adding a column with foreign key

My existing table is like below

Story
-------------------------------
| id | name | author_id | date |

Now I want to add one more foreign key column created_by how to add this without deleting the existing data. The existing data foreign key must be the admin id.

From this question I understood how to add a column without deleting all the existing data.

How to add column in a table using laravel 5 migration without losing the data in the table?

I want to do this modification in my PC, test machine, live server. So I have to add the foreign key and also I have to find out the admin id from users table and assign to it. How to do this?



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

How To calculate discount in Crinsane/laravel

I want to ask about how to calculate discount in laravel using Crinsane/LaravelShoppingcart, i try to search a lot to understand ho to add the discount but i failed, i hope someone help me soon.



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

JSON Search in laravel eloquent

I am storing destinations field as json type in mysql

example column value ["Goa", "Moonar", "Kochi"]

I would like to get all rows that matches goa as destinations

However this row query returns the desired result

SELECT * FROM `packages` 
WHERE JSON_CONTAINS(destinations, '["Goa"]');

But what is the eloquent equivalent of the above query??

Laravel version 5.3

Modelname :Search



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

Auth facade suddenly stopped working

I have an install that worked consistently until for some reason after install Auth facade stopped working. I did run composer dump-autoload, then php artisan clear-compiled .

But i'm still getting

PHP Fatal error: Call to undefined method Illuminate\\Support\\Facades\\Auth::user() in somePath/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 207

I didn't change any code or the laravel version, so it must be something else. I'm running laravel 5.0.16.

Anyone have an idea where to start looking?



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

Use button click to change child view

I have a button on my main layout page:

<INPUT TYPE="BUTTON" id="run" onclick="" VALUE="Run File Finish"  class="button" style.visibility="visible">

All I want to do is redirect to a separate child view when the button is clicked. Simple enough right? No, all I can find after searching for hours are suggestions to use an href. I am not using bootstrap and do not want to use an href. Since this seems to be to be a common thing to do in web design, I can't beleive there is not a simple way to do this. I am finding the documentation on laravel 5 less than adequate. Any help would be appreciated.



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

How to create dynamic query?

I have 7 records. 6 of them have selling and 1 is rent. In array i get this:

array:2 [▼
  0 => "Selling"
  1 => "Rent"
]

But when i foreach that in result i get 4 and not 7. Any suggestion how can i fix this. Im trying to create dynamic query so if i enter one more thing that i dont need to change here anything.

if(is_array($option)){
    foreach($option as $o){
        $q->orWhere('name', 'like', $o);
    }

  }
   else{
      $q->orWhere('name', 'like', $option);
   }



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

How can I change the landing page after a success Laravel login?

I am absolutly new in Laravel and I have the following problem. I am using Laravel 5.3.

When I perform the login from my login page it automatically land me on this home page:

http://localhost:8000/home

My doubt is: how can I change the landing page after a success login?

I have these routes:

Andrea@Andrea-PC MINGW64 ~/Documents/Betrivius/WorkSpace/betriviusExtranet (master)
$ php artisan route:list
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+
| Domain | Method   | URI                    | Name     | Action                                                                 | Middleware   |
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+
|        | GET|HEAD | /                      |          | App\Http\Controllers\LoginBetriviusController@index                    | web          |
|        | GET|HEAD | api/user               |          | Closure                                                                | api,auth:api |
|        | POST     | doLogin                |          | App\Http\Controllers\LoginBetriviusController@doLogin                  | web          |
|        | GET|HEAD | home                   |          | App\Http\Controllers\HomeController@index                              | web,auth     |
|        | POST     | login                  |          | App\Http\Controllers\Auth\LoginController@login                        | web,guest    |
|        | GET|HEAD | login                  | login    | App\Http\Controllers\Auth\LoginController@showLoginForm                | web,guest    |
|        | POST     | logout                 | logout   | App\Http\Controllers\Auth\LoginController@logout                       | web          |
|        | POST     | password/email         |          | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail  | web,guest    |
|        | GET|HEAD | password/reset         |          | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest    |
|        | POST     | password/reset         |          | App\Http\Controllers\Auth\ResetPasswordController@reset                | web,guest    |
|        | GET|HEAD | password/reset/{token} |          | App\Http\Controllers\Auth\ResetPasswordController@showResetForm        | web,guest    |
|        | GET|HEAD | register               | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm      | web,guest    |
|        | POST     | register               |          | App\Http\Controllers\Auth\RegisterController@register                  | web,guest    |
+--------+----------+------------------------+----------+------------------------------------------------------------------------+--------------+

So I tried to modify my LoginController (related to the App\Http\Controllers\Auth namespace) changing this value from:

protected $redirectTo = '/home';

to:

protected $redirectTo = '/dashboard-hotel';

where dashboard-hotel represents the dashboard-hotel.php view that I want to open just after a success login.

But doing in this way I obtain the following error message:

NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 766
at Router->findRoute(object(Request)) in Router.php line 621
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\Users\Andrea\Documents\Betrivius\WorkSpace\betriviusExtranet\public\index.php') in server.php line 21

This is my /routes/web.php file content:

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('/', 'LoginBetriviusController@index');

Route::post('/doLogin', 'LoginBetriviusController@doLogin');

Auth::routes();

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

So, what is wrong? What am I missing? How can I fix this issue?



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

How to use orWhere when i have an array and other fields with only one value?

I want to make filter. In view i have two inputs like this:

<input type="checkbox" id="test" value=""  name="prop_category[]"/>

  <input type="checkbox" id="toggle-on" value="" class="singleChb" name="publishing_types" @if ($index == 1) {!! "checked" !!}

First input can have multiple values and second can have only only one value.

Now in controller i have this:

  foreach($options as $key => $option) {
            if($key != "search" &&
                $key != "page"  &&
                $key != "starterResult"  &&
                $key != "totalResult") {

                $query->whereHas($key,function($q) use($option){
                    $q->orWhere('name', 'like', $option);
                });
            }
        }

In $options i get an array for first input and for second i get one value. How can i use that now orWhere to check all of that selected values from first input. Now im able to check only for one value, and not for array. Any suggetion?



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

Class MongoDB\Driver\Manager' not found

I am using XAMPP. Installed mongo version 3.4.1 If I hit $mongo command I get -

MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1

And If I hit $php -i | grep mongo then I get -

mongodb support => enabled
mongodb version => 1.2.2
mongodb stability => stable
libmongoc version => 1.5.0
mongodb.debug => no value => no value

I have required "jenssegers/mongodb": "^3.1" in laravel version 5.1

I have configured laravel with mongo in database.php Also migrated using PHP artisan mitrate command and tables have been created in mongo.

After routing, I have added just

DB::collection('collection_name')->get();

But I am getting "FatalThrowableError in Client.php line 81: Class 'MongoDB\Driver\Manager' not found" error

Can anybody help me here? I don't know what is happening! Is there something like I have installed mongo from a command prompt and I am using XAMPP?.



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

Laravel Stormpath Social Login Error

I am using Laravel 5.1 and Stormpath for User management.

I followed the below docs to implement google login

http://ift.tt/2k8Z0tb

  1. Configuring Your Social Provider = DONE

I created project in Google Console and in “Authorized redirect URIs” I've added
http://ift.tt/2kjnEd1

  1. Create a Stormpath Social Directory = DONE
  2. Initiate Social Login - In my form when I click on Google Sign In it redirects to

    http://ift.tt/2k8UoD6;
    account_store_href=http://ift.tt/2kjwkjt}
    &redirect_uri=https%3A%2F%2Flocalhost
    
    

and returns

{"status":404,"message":"Resource not found."}

As per this documentation

http://ift.tt/2k91PKQ

  1. The user clicks on a “Login with Google” link pointing at your application’s /authorize endpoint
  2. Stormpath handles the login to Google and redirects the user back to your app with a Stormpath Token JWT response

What am I doing wrong? Why isn't stormpath redirecting to the google login page?

Any help appreciated! Thanks in advance!



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

How to write on route to receive request from external laravel project

$client = new Client();
$response = 
$client->GET('http://ift.tt/2k8SDG6',
[
 'json' => ['foo' => 'bar']
]);

This is how i'm sending a request to external LARAVEL api. I just want to know what do i need to write in laravel api router to get something return when i send this request. Currently i have the following code on laravel api router

Route::GET('module/url', 'Nameof Controller@NameOfMethhod');

And in controller looks like:

public function GetApplicationModuleList()
{
  echo 'something';
  //i want to print the parameter value which i just sent by above mention request.
}



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

Distinct most recent data from database

I am storing data in my database. The data being stored looks like this

id  | upload_month | created_at
-----------------------------------------
1   | January      | 2017-01-30 13:22:39
-----------------------------------------
2   | Febuary      | 2017-01-30 13:23:42
-----------------------------------------
3   | January      | 2017-01-30 13:25:33

Within my Controller I am trying to retrieve the distinct upload_month, but get the latest inserted version for each. At the moment I am trying

$uploadedFile = UploadedFile::groupBy('upload_month')->orderBy('created_at', 'desc')->get();

The problem is that this is returning the following

id  | upload_month | created_at
-----------------------------------------
1   | January      | 2017-01-30 13:22:39
-----------------------------------------
2   | Febuary      | 2017-01-30 13:23:42
-----------------------------------------

So for the January record it is giving the older version. If I change it to ->orderBy('created_at', 'asc') it returns the same records but Febuary being the first row.

In essense, what I am after is this

id  | upload_month | created_at
-----------------------------------------
1   | January      | 2017-01-30 13:25:33
-----------------------------------------
2   | Febuary      | 2017-01-30 13:23:42
-----------------------------------------

How am I able to achieve this?

Thanks



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

Laravel 5 check if value exist in database insert another value once

i am new in laravel and i try to insert some values from json array to database, and i want to check if record exits, and if exists want to insert another value. below code works fine for the first time, but when i refresh it changes inserted records again. how i can check the value when inserting first time and when refreshed i dont want to change inserted records. i hope u can help

        $slug = str_slug($post->post_title, '-');

        if (!empty($slug)) {
            if (Post::where('post_slug', '=', $slug)->exists()) {
                $post->post_slug = $post->post_id;
            } else {
                $post->post_slug = $slug;
            }
        } elseif (empty($slug)) {
            $post->post_slug = $post->post_id;
        }
            $post->save();



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

Split a dateTime column into a separate date and time column in Laravel 5

I have a table called 'offers' with a column called start_date of type dateTime.

I want to split this column into two separate columns called:

  • start_date of type date
  • start_time of type time

To do this I have the following code:

<?php

use App\Offer;
use App\Schedule;
use Carbon\Carbon;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class FixOffersTable extends Migration
{
    public function up()
    {
        Schema::table('offers', function(Blueprint $table)
        {
            $table->renameColumn('start_date', 'start_date_time');
            $table->renameColumn('end_date', 'end_date_time');
        });

        Schema::table('offers', function (Blueprint $table)
        {
            $table->date('start_date')->after('start_date_time')->nullable();
            $table->time('start_time')->after('start_date')->nullable();

            foreach (Offer::all() as $offer) {
                /* Cannot use model mutator, as model class can change over time, and may no longer have certain columns
                in the $casts attribute. Therefore using the raw string fetched from the MySQL database. */
                $startDateTime = Carbon::createFromFormat('Y-m-d H:i:s', $offer->getOriginal('start_date_time'));
                $offer->start_date = Carbon::createFromDate($startDateTime->year, $startDateTime->month, $startDateTime->day);
                $offer->start_time = Carbon::createFromTime($startDateTime->hour, $startDateTime->minute, $startDateTime->second);
                $offer->save();
            }
        });
    }
}

However the above gives the following error:

[Doctrine\DBAL\Schema\SchemaException]                        
There is no column with name 'start_date' on table 'offers'. 

Please help. Better methods is also welcome!



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

inputs loaded through ajax don't appear in request body

I have form, with two hidden inputs and submit button in my bootstrap modal

<form method="POST" action="http://ift.tt/2kiIBV4" accept-charset="UTF-8" id="editVideoForm">
<div class="modal-body modal-video-cont">
    <div class="modal-body-container">

    </div>
</div>
<div class="clearfix"></div>
<div class="modal-footer">
    <div class="col-md-5 col-md-offset-7">
        <input class="btn green pull-left ddf_button_pad" name="update_video_form" type="submit" value="Save">

        <button data-dismiss="modal" type="button" class="btn green btn-outline pull-right ddf_button_pad">Cancel</button>

        <input class="position-input" id="editVidTempPos" name="template_position" type="hidden">
        <input id="editVidType" name="type" type="hidden" value="video">
    </div>
</div>

in <div class="modal-body-container"> element I load content(which contains radio buttons) through ajax(works fine)

<input type="radio" class="blockRadio video-input" name="resource" data-position="" value="http://ift.tt/2kFctZA" style="position: absolute; opacity: 0;">

<input type="radio" class="blockRadio video-input" name="resource" data-position="" value="http://ift.tt/2kFctZA" style="position: absolute; opacity: 0;">

however when i submit form, i don't see these radio elements in request body(there should be resource index)

"_token" => "FF1zRnyORk9BzBUIWTj13PI06SZxYld1iLfpNZ0e"
"template_position" => "6"
"type" => "video"

how can I fix it? I'm using laravel framework(if it's matter:)



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

Laravel 5.3 Custom authentication provider auth middle ware not working

I have used laravel 5.3 in my application ..And i'm not using laravel default auth hash password method. I have changed to crypt encryption both username and password . I have implemented the custom provider method as mentioned in the below link. My problem is after auth->attempt() . The middleware auth is not working and i'm not able to retrieve auth->user() its always return null

http://ift.tt/2kL6mSQ



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

How can I add the ' character into a string representing the JSON for a WS call in PHP?

I am an abslolute beginner in PHP and moreover in Laravel framework (I came from Java).

I am finding the following problem trying to perform a Guzzle call to a REST web service:

if I do it using mocked creadential data it works fine:

    $response = $client->get('http://localhost:8080/Extranet/login',
        [
            'auth' => [
                'nobili.andrea@gmail.com',
                'pswd'
            ]
        ]);

    $dettagliLogin = json_decode($response->getBody());

    \Log::info('response: '.(json_encode($dettagliLogin)));

But trying to do in this way

    $response = $client->get('http://localhost:8080/Extranet/login',
        [
            'auth' => [
                //'nobili.andrea@gmail.com',
                //'pswd'
                $credentials['email'] . ','
                .$credentials['password']
            ]
        ]);

    $dettagliLogin = json_decode($response->getBody());

    \Log::info('response: '.(json_encode($dettagliLogin)));

it goes into error.

I think that maybe the problem could depend by the fact that the mocked credential contain the ' before and after username and password fields:

'nobili.andrea@gmail.com',
'pswd'

How can I insert it in my dynamic version of code?



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

How can I correctly print the object content in PHP?

I am absolutly new in PHP and moreover in Laravel framework and I have the following problem.

I am doing:

    $attributes = array(
        'id' => $dettagliLogin->id,
        'username' => $dettagliLogin->email,
        'name' => $dettagliLogin->userName,
    );

    $user = new GenericUser($attributes);

    \Log::info('USER: '.(var_dump(($user))));

Where the last line:

\Log::info('USER: '.(var_dump(($user))));

should write the content of the $user object into a log file.

The problem is that into my log file I obtain this output:

[2017-01-30 10:25:19] local.INFO: USER:  

so it is as this object is empty but I think that it is not empty because then is used.

Why? How can I correctly print the object content?



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

Laravel routing two optional one after another

First, I would gladly accept suggestions on that title, because I am not sure how to explain my issue in one row.

I have a route that looks like that

Route::get ('/i/{group?}/{name?}', 'Controller@index')->name('name');

Problem is when I go to /i//myname it throws a route exception.

I made both conditional because I have strict validations within the controller. I want to keep that structure, but what route should I make to make both optional variables work ?

Ex. When you open /i//myname to redirect you to the select group page, so as /i/group// or /i/group/



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

Who can I automatically scroll to bottom of page on load in laravel

I want to scroll to bottom of the page on page-load automatically in laravel 5.2, i tried soo much but i couldn't figure out were i went wrong, I have attached my view code below.Can u go through it please and let me know were i went wrong. Actually i'm not good at design soo please help me on it.

my code:

 @section('content')
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="col-md-3 col-sm-6 col-xs-12 profile_left">
                <!-- start Support Tickets -->
                <ul class="list-unstyled user_data">
                    <li>
                        <div class="panel panel-success">
                            <div class="panel-heading"><span class="glyphicon glyphicon-filter"></span><strong>&nbsp;&nbsp; Ticket Information</strong></div>
                            <div class="panel-body">
                                <!-- Modal -->
                                <table class="table table" style="color: #009933;">
                                    @if(!empty($tickets))
                                        <tr>
                                            <td style="font-weight: bold; ">
                                                <small>
                                                    &nbsp;
                                                </small>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="font-weight: bold;  ">
                                                <small>
                                                    @if ($tickets->status === 'open')
                                                        <span class="label label-success"></span>
                                                    @elseif ($tickets->status === 'ongoing')
                                                        <span class="label label-warning"></span>
                                                    @elseif ($tickets->status === 'closed')
                                                        <span class="label label-default"></span>
                                                    @endif
                                                </small>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="font-weight: bold;  ">
                                                <small>
                                                    <p style="font-family: 'Times New Roman', Times, serif; ">Agent:&nbsp;</p>
                                                </small>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="font-weight: bold;  ">
                                                <small>
                                                    <p style="font-family: 'Times New Roman', Times, serif; ">Priority:&nbsp;
                                                        @if ($tickets->priority === 'Low')
                                                            <span class="label label-info"></span>
                                                        @elseif ($tickets->priority === 'Medium')
                                                            <span class="label label-primary"></span>
                                                        @elseif ($tickets->priority === 'High')
                                                            <span class="label label-danger"></span>
                                                        @endif</p>
                                                </small>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="font-weight: bold;  ">
                                                <small>
                                                   <p style="font-family: 'Times New Roman', Times, serif; ">Last_Updated:&nbsp;</p>
                                                </small>
                                            </td>
                                        </tr>
                                    @endif
                                </table>
                            </div>
                        </div>
                    </li>

                    <li>
                        <div class="panel panel-success">
                            <div class="panel-heading">
                                <span class="glyphicon glyphicon-dashboard"></span><strong>&nbsp;&nbsp; Support</strong>
                            </div>
                            <div class="panel-body">
                                <!-- Modal -->
                                <table class="table table-striped">
                                    <tr>
                                        <td><span class="glyphicon glyphicon-home"></span>&nbsp;<a href = '/view' style="text-decoration:none">My Support Tickets</a></td>
                                    </tr>
                                    <tr>
                                        <td><span class="glyphicon glyphicon-open"></span>&nbsp;<a href = '/openticket' style="text-decoration:none">Submit Tickets</a></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </li>
                </ul>
                <!-- end of Support Tickets -->
            </div>

            <div class="col-md-9 col-sm-9 col-xs-12">
                <center>
                    <h2 style="color: #00BCD4;">My Ticket Feedback/<small>Your Comments History</small></h2>
                </center>
                <hr style="height:2px;border-width:0;color:gray;background-color:gray">
                @if($tickets->status === 'closed')
                    @if(Auth::user()->_id === $tickets->user)
                        <div class="alert alert-warning" role="alert">
                            <center>
                                <p style="font-weight: bold; color:#FF9966; ">This Ticket is closed. You can reply to reopen this ticket.</p>
                            </center>
                        </div>

                        <div class="panel panel-success">
                            <div class="panel-heading">
                                <form action = "/reopentick/<?php echo $tickets->id; ?>" method = "post">
                                    <input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
                                    <input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
                                    <input type="hidden" name="status" value="open">
                                    <span class="glyphicon glyphicon-pencil"></span>
                                    <input type = 'submit' value = "Reply To Reopen Ticket"  class="btn btn-link btn-xs" style="font-weight: bold; color:#009933; " />
                                    <span class="glyphicon glyphicon-plus pull-right"></span>
                                </form>
                            </div>
                        </div>
                    @endif
                @endif

                <table class="table table-striped">
                    <tr><td>
                            <div class="panel-group">
                                @if($tickets->user == Auth::user()->_id)
                                    <div class="panel panel-info">
                                        @else
                                            <div class="panel panel-success">
                                                @endif
                                                <div class="panel-heading">
                                                 <span class="glyphicon glyphicon-user">
                                                     <strong>
                                                       
                                                     </strong>
                                                 </span>
                                                    <span class="glyphicon glyphicon-time pull-right">
                                                    </br>
                                                </span>
                                                </div>
                                                <div class="panel-body">
                                                    <p> Hello,</br>
                                                        {!! $tickets->message !!}</br>
                                                        <b>...</b></br>
                                                        Thank you,</br>
                                                        
                                                    </p>
                                                </div>
                                            </div>
                                    </div>
                        </td></tr>
                    <tr>
                        @foreach($anstickets as $t)
                            <td class="answer_block">
                                <div class="panel-group">
                                    @if($t->user_id == Auth::user()->_id)
                                        <div class="panel panel-info">
                                            @else
                                                <div class="panel panel-success">
                                                    @endif
                                                    <div class="panel-heading">
                                                <span class="glyphicon glyphicon-user ">
                                                    <strong>
                                                       
                                                    </strong>
                                                </span>
                                                        <span class="glyphicon glyphicon-time pull-right">
                                                    </br>
                                                </span>
                                                    </div>
                                                    <div class="panel-body">
                                                        <p>Hi,</p>
                                                        {!!$t->comments!!}</br>
                                                    </div>
                                                </div>
                                        </div>
                            </td>
                    </tr>
                    @endforeach
                </table>

                @if(($tickets->status === 'ongoing')||($tickets->status === 'open'))
                    @if(Auth::user()->_id === $tickets->user)
                        <div class="panel  panel-danger">
                            <div class="panel-heading">
                                <form action = "/closetick/<?php echo $tickets->id; ?>" method = "post" >
                                    <input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
                                    <input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
                                    <input type="hidden" name="status" value="closed">
                                    <input type = 'submit' value = "Close Ticket"  class="btn btn-link btn-xs" style="font-weight: bold; color:#CC0000; "/>
                                    <span class="glyphicon glyphicon-remove-sign pull-right"></span>
                                </form>
                            </div>
                        </div>
                    @endif

                    <br>
                        @if(Auth::user()->_id === $tickets->user)
                            <b><h1> Response</h1></b>
                        @else
                            <b><h1> Solution</h1></b>
                        @endif
                    <form action = "/tickanswert/<?php echo $tickets->id; ?>" method = "post" onsubmit="return form_submit()">
                        <input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
                        <input type="hidden" name="user_id" value="<?php echo Auth::user()->id; ?>">
                        <input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
                        <div class="form-group">
                            <textarea class="form-control" name="comments" rows="14" required></textarea>
                        </div>
                        <br>
                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit"  name="submit" class="btn btn-primary btn-lg">
                                    <i class="fa fa-btn fa-ticket"></i> SUBMIT
                                </button>
                            </div>
                        </div>
                    </form>
                @endif
            </div>
        </div>

    @endsection
    @section('additional-scripts')
        <script>
            $( document ).ready(function() {
                $('html,body').animate({
                            scrollTop: $('.answer_block').children('.panel-group').last().offset().top},
                        'slow');
                alert("Hello! I am an alert box!!");
            });


        </script>

    @endsection



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

return json data using ajax in laravel not working

I'm trying to receive an id by first sending it through ajax and then return it in json format in laravel. For some reason, it's not working, also console shows I'm getting a "Internal server error" for this url: http://localhost/public/admin/questions/sort

What could be wrong here?

jquery code:

<script>
            $(document).ready(function () {
                //alert(url);
                $('select[name=selector]').change(function() {
                    var quiz_id=$(this).val();
                $.ajax({
                    method: "POST",
                    url: '',
                    data:{id:quiz_id}
                    }).done(function (msg) {
                        console.log(msg['id']);
                    })
                });
            });
        </script>

routes file

Route::post('questions/sort',['uses'=>'QuestionController@sort','as'=>'admin.questions.sort']);
Route::resource('questions', 'QuestionController');

controller file

   public function sort(Request $request) {
        $id=$request['id'];
        return response()->json(['id'=>$id  ],200);
    }



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

dimanche 29 janvier 2017

Pagination working but Infinite scroll not working

Pagination working perfectly, but I want to move next page when user scroll down. Please correct my code.

Here is my html code

<div class="form-group col-md-8 col-md-offset-1">
  <div class="row">
    <div id="content" class="col-md-12">
      @if(count($hotel_list) > 0)   
        @foreach($hotel_list as $hotel)
          <a href="/hotels/hotel-details?hotel=">
            <div class="row hotel-details">
              <div class="col-md-4"><img src="/uploads/"></div>
              <div class="col-md-5">
                <div class="hotel-name"></div>
                <div class="hotel-address">
                  
                </div>
                <div class="hotel-location"><i class="fa fa-map-marker fa-1x" aria-hidden="true"></i> LOCATE HOTEL</div>
              </div>
              <div class="col-md-3 text-right">
                <div><span class="hotel-rate">Rs.  </span></div>
              </div>
            </div>
          </a>
        @endforeach
       @endif
    </div>
  </div>
</div>
<div class="row">
  <div class="col-md-12 text-center">
    {!! $hotel_list->render() !!}
  </div>
</div>

JS

var loading_options = {
  finishedMsg: "<div class='end-msg'>Congratulations! You've reached the end of the internet</div>",
  msgText: "<div class='center'>Loading news items...</div>",
  img: "/img/image_loader.gif"
};
$('#content').infinitescroll({
  loading: loading_options,
  navSelector: "div",
  nextSelector: "div a:first",
  itemSelector: "#content a"
});



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

Laravel - Mongodb [ jenssegers/laravel-mongodb ] - Schema Builder

I have an web app with mongodb, using jenssegers package.

Since I'm using mongodb, do I need to create any migration table? Jenssegers database driver also has (limited) schema builder support

Schema::create('users', function($collection)
{
    $collection->index('name');

    $collection->unique('email');
});


I found two different "answers". This guy is using the schema builder

enter image description here

And the Mulkave answer:

Q: "When i run the comman "php artisan migrate" then i am getting following error where as migration table is created into mongodb database:"

A: "You might have misinterpreted the purpose of MongoDB being a document database, you do not need to have migrations in document-based databases and this is what they're good a. They have dynamic schemas so all you'll have to do is save your model regardless of what attributes they have which means you'll have to tighten your application's business logic to make sure the models are being saved as you expected."


So, do I need migrations table? Thanks!



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

Laravel 5 - Define custom route method?

I just got an issue , i have 2 problems :

  1. I want create a custom route for fast using without copy past code many time. Example Laravel 5 have default Route:resource (...) to make Restful! But i want to make my custom route function , Route:api(...) , Route:xxx(...) ... and I can custom it what I want !

  2. How can I use multi route file ? Example : I can define route in App\User\route.user.php , App\Book\route.book.php .... because now, I can only use route file in route folder default !



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

Issue in uploading image file on server using postman in laravel 5.3?

I am using intervention for file resize functionality and for file uploading. In controller I am just checking hasFile() or not. so, everytime I got "no" in response even if I am sending it properly using postman. what can be the issue ?

my route

Route::post('contact/image/upload',['as'=>'intervention.postresizeimage','uses'=>'contactController@upload_image']);

code in controller

public function upload_image(Request $request){

      if((preg_match("/^[789]\d{9}$/", $request->header('UID')))){
        if($request->hasFile('photo'))
          return "yes";
        else
          return "no";


        $photo = $request->file('photo');
        $imagename = time().'.'.$photo->getClientOriginalExtension(); 

        $destinationPath_thumb = storage_path('images/thumbnail_images');
        $thumb_img = Image::make($photo->getRealPath())->resize(100, 100);
        $thumb_img->save($destinationPath_thumb.'/'.$imagename,80);

        $destinationPath_medium = storage_path('images/medium_images');
        $medium_img = Image::make($photo->getRealPath())->resize(500, 500);
        $medium_img->save($destinationPath_medium.'/'.$imagename,80);

        $destinationPath_original = storage_path('images/original_images');
        $photo->move($destinationPath_original, $imagename);

        $user = \App\User::select(['inst_id'])->where('mobile','=',$request->header('UID'))->first();

        $update_img = \App\Contact::where([['id','=',$request->ID],['inst_id','=',$user->inst_id]])->update(['image'=>$imagename]);

        if($update_img)
          $response = response()->json(['data'=>[], 'error'=>0,  'error_msg'=>'', 'message'=>'Profile updated']);
        else
          $response = response()->json(['data'=>[], 'error'=>1,  'error_msg'=>'some went wrong', 'message'=>'Please try again']);
      }
      else
         $response = response()->json(['data'=>[], 'error'=>1,  'error_msg'=>'wrong mobile in UID header','message'=>'wrong mobile no. in header']);

    return  $response;

  }



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

Laravel 5.2 - Calling stored procedure with error [SQL Server] Incorrect syntax near '@P1'

I'm using Laravel 5.2 and PHP PDO for connect Mssql database. I created stored procedure like this:

GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description:  <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[TestSelect](
@policy nvarchar,
@memberval int output
)
AS
BEGIN
select * from Member
set @memberval=(select count(*) from Member where (PolicyNo LIKE '%' + @policy + '%'))
END

I have write php source in Laravel 5.2 like this:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class ExtractController extends Controller
{
    public function index()
    {

    $policy = '00006001';
    $test = \DB::connection('sqlsrv')->select('EXEC TestSelect(?)',array($policy));

    return view('extract.index');


    }//
}

I got this error every time:

QueryException in Connection.php line 729: SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near '@P1'. (SQL: EXEC TestSelect(00006001))

Do you have any idea for this error?



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

How can I get the value of my role using this query

im having an error... i don't know how to fix this... im doing something that will set page privileges to admin employee and other roles. But suddenly i doesnt get the value of my variable role.

enter image description here

 public function login(Request $req)
     {
        $username=$req->input('email');
        $password=$req->input('password');
        $breadcrumb = 'Dashboard';
        $pageTitle = 'CollabUX | Dashboard';
        $prepath ='../';
        $currentURL = Req::url();

        $user = DB::table('add_users')->where(['username'=>$username,'password'=>$password])->get();

        if(count($user)>0){
            session(['isloggedin' => 'true']);
            session(['roles' => $user->role]);

        return View::make('dashboard')->with(
            array('breadcrumb' => $breadcrumb,'pageTitle' => $pageTitle,'currentURL' => $currentURL,'prepath' => $prepath));
        }
        else{
            //redirect page
            $data = array(
                'error' => 1,
                'remarks' => 'Invalid Username/Password. Please try again.'
                );
            return View::make('login')->with('data', $data);


        }       
     }



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

Use Controller with my public folder in Laravel

I bought an template with HTMLs files, CSS and Javascript. Now I want to use Laravel 5.4 so I have resources folder and public folder. After reading this

Click here to redirect to the topic

I understood that all my CSS, Javascript that the template gave me I have to put into my public folder.

What is the problem? My index page (the page that is opened when the user enter in my site www.mysite.com) has to connect to the server to get some staditics data, and the index page is in public folder! If I make a controller for my index I need to put it into resource/view folder with index.blade.php

If I put my index page into resources/view my browser alway redirect to the index of public folder so... I have a Headache for all of this, can you help me to solve my problem?

I think I'm not the first one that need to make a index with a controller to connect to my server.

Thanks!



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

How can I parse a JSON object in PHP? How can I retrieve the values of some specific fielnds of this JSON object?

I am absolutly new in PHP and moreover in Laravel framework (I don't know if Laravel provides some utility class for this kind of tasks). I came from Java.

So I have the following problem:

into a class I perform a call to a REST web service, something like this:

    $response = $client->get('http://localhost:8080/Extranet/login',
        [
            'auth' => [
                'dummy@gmail.com',
                'pswd'
            ]
        ]);

    $dettagliLogin = json_decode($response->getBody());

   \Log::info('response: '.(json_encode($dettagliLogin)));

$response->getBody() contains the returned JSON object, this is the output of the previous \Log::info():

{
    "id":5,
    "userName":"Dummy User",
    "email":"dummy@gmail.com",
    "enabled":true
} 

So I have the following problems:

1) What exactly returns the json_decode() function? I really can't understand because PHP is not strongly typed and I have not a declared return type.

This is the method signature:

function json_decode($json, $assoc = false, $depth = 512, $options = 0)

and in the related doc it says @return mixed. What exatly means mixed?

2) Anyway the main problem is: I have to use the content of the previous returned JSON object and put these value into the related field of an array like this:

$attributes = array(
    'id' => HERE THE id FIELD VALUE OF MY JSON OBJECT,
    'username' => HERE THE email FIELD VALUE OF MY JSON OBJECT',
    'name' => HERE THE userName FIELD VALUE OF MY JSON OBJECT,
    );

So I think that I have to parse the value of the $response->getBody() or of the json_decode($response->getBody()) to obtain these values. But how exactly can I do it? What is the neater way to do it? Laravel fframework provides some utility to do it?

Tnx



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