Dropzone with laravel

I am using dropzone.js with laravel to upload photos, it works perfectly.
I also added remove link for each photo. during uploading process I change the name of photo using time(). and save it into database.

My question is how I can get the new name of photo , so I can use it when I want to remove it using dropzone.js

Many thanks and best regards,


Source: stackoverflow-php

Accessor is not called

I’ve a model named Order :

<?php

namespace App;

use IlluminateDatabaseEloquentModel;
use CarbonCarbon;
class Order extends Model
{
    public function getsystemIdAttribute()
    {
        return 99;
    }
    public function setCreatedAtAttribute($value){
        $this->attributes['createdAt'] = Carbon::parse($value)->format('Y-m-d');
    }
    protected $fillable = ['customerId', 'itemId','systemId', 'createdAt'];
    public $timestamps = false;
}

The problem is that the accessor – getsystemIdAttribute()suprise isn’t getting called, I tried it on other fields, however the accessor isn’t called again.Of course I’ve changed the name form getsystemIdAttribute to getitemIdAttribute(for example). I copied the method on another model, and again changed the name a little bit and it worked. I fired up my debugger, and visited the view which is using this model, and to my surprise the method isn’t getting called, but the fields from the database are returned. The version of Laravel is 5.3 and the database is MySQL, the version of php is 7.
Any idea what my be the problem.


Source: stackoverflow-php

How do I select specific JSON value to create a string?

I have the below JSON output:

  "data" => "[{"month":2,"total_payments":"720.00"},{"month":3,"total_payments":"500.00"}]"

I am struggling for the syntax to select a specific value to create a string from. For example I want to be able to output

$month = [“2”, “3”]
$total_payments = [“720”, “500”]

So far I have this code but not working.

<?php echo $data->month?>


Source: stackoverflow-php

Query into wordpress db from laravel

I have setup my main application in laravel and set up word press for blog (CRUDE) operation. Installed wordpress inside public folder and configured database settings for 2nd database in config/database.php in laravel.

The trouble I’m having is how do i query in 2nd db (wordpress). I want to show latest 3 blog post with their featured image in landing page of my laravel app.

The main confusion is caused by one post has two rows in db (wordpress) with attributepost_status with values published for first row and inherit for second row. And 3 rows if featured image is set to blog post. I would be very helpful if anyone can walk through me from this problem.


Source: stackoverflow-php