mbo

mbo

Member Since 1 Year Ago

Experience Points
7,430
Total
Experience

2,570 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
42
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
7,430 XP
Aug
10
2 days ago
Activity icon

Replied to Redirect 301 Htaccess

thanks Bobby!

Any idea when he doesn't take it? This what i have (i tried both ^/berichten as ^berichten).

thanks again!


<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ / [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteRule ^berichten/.*$ https://aaa.net/ [L,R=301]



</IfModule>
Activity icon

Started a new Conversation Redirect 301 Htaccess

Good day,

I'm trying to setup a 301 redirect but it seems not to work.

I want to the following:

In my old site url's like these:

/aaa/1 /aaa/2 etc.

I want all /aaa/* (everything behind the aaa/) to go to another url

/bbb.net

I tried this sofar but does not work.

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RedirectMatch 301 ^/aaa/.*$ https://bbb.net/

but is does not work. any tips?

Jun
18
1 month ago
Activity icon

Started a new Conversation Logging 404

good day,

I moved over an wordpress website to laravel. By doing so i want to keep track of 404 errors.

So a created a custom handler and in this handler the url that is not found is saved.

I like to add the url where the link is activated (clicked). What is the best way to do this?

I was thinking of

(basename(url()->previous()) 

Any better idea's?

thanks for the reaction

maarten

Jun
08
2 months ago
Activity icon

Replied to Challenge With Query: Local Versus Server.

Tisuchi,

the relation is oke.

But i double checked the database. The seems that he gets the data from somewhere else.

strange because i'm loggedin on the remote database.

Thank for the help so far. If i don't get it working i will get back to you.

Activity icon

Replied to Challenge With Query: Local Versus Server.

even when i run this querry:

->with(['images' => function ($query) {
            $query
            ->where('image_status', 'active')
            ->where('image_type', 'dp');
           
        }])   

the images are empty.

Can it have to do with a corrupt database? (i deleted the tables by hand en imported the new data)?

Activity icon

Replied to Challenge With Query: Local Versus Server.

Tisuchi, thanks for the reaction. Yes the data is the same.

Activity icon

Started a new Conversation Challenge With Query: Local Versus Server.

good day,

i have an issue with an query:

  • Local it works fine
  • staging (forge on digital ocean) it doesn't.

Tests i did:

(1) this query produces


     public function getSingle_dp($slug,$type) {

        $dp = dp::where('dp_name_slug', '=', $slug)
         ->where('dp_status_id',1) 
         ->with(['services' => function($query) {
          $query->where('service_status_id', '=', '1');
        }])
         ->with('images')
        ->firstOrFail();

The following output:

Local:

    "images" => Collection {#626 ▼
      #items: array:2 [▼
        0 => Image {#631 ▼
          #connection: "mysql"
          #table: null
          #primaryKey: "id"
          #keyType: "int"
          +incrementing: true
          #with: []
          #withCount: []
          #perPage: 15
          +exists: true
          +wasRecentlyCreated: false
          #attributes: array:11 [▶]
          #original: array:14 [▼
            "id" => 8531
            "image_user_id" => 2661
            "image_group_id" => 2661
            "image_type" => "dp"
            "image_original_name" => "Rousant_Ligplaats.jpg"
            "image_filename" => "Rousant-Lauwerzijl-1589895639013.jpg"
             "image_status" => "active"
            "created_at" => "2019-07-08 08:51:20"
            "updated_at" => "2020-05-19 13:40:39"
            "image_oldname" => "1473739301PassantenhavenRousant_Ligplaats.jpg"
            "pivot_dp_id" => 2502
            "pivot_image_id" => 8531
            "pivot_dp_image_value" => "image"


"pivot_dp_image_value" => "image" is set.

Output Staging:

    "images" => Collection {#488 ▼
      #items: array:1 [▼
        0 => Image {#495 ▼
          #connection: "mysql"
          #table: null
          #primaryKey: "id"
          #keyType: "int"
          +incrementing: true
          #with: []
          #withCount: []
          #perPage: 15
          +exists: true
          +wasRecentlyCreated: false
          #attributes: array:10 [▶]
          #original: array:13 [▼
            "id" => 8379
            "image_user_id" => 2524
            "image_group_id" => 2524
            "image_type" => "dp"
            "image_original_name" => "lijdorp.jpg"
            "image_filename" => "1470659122blijdorp.jpg"
             "image_status" => "active"
            "created_at" => "2019-07-08 08:51:11"
            "updated_at" => "2019-07-08 08:51:11"
            "pivot_dp_id" => 2365
            "pivot_image_id" => 8379
            "pivot_dp_image_value" => null

"pivot_dp_image_value" => "image" is NOT set.

(2) This query works on local. On staging the images are empty.

     public function getSingle_dp($slug,$type) {

        $dp = dp::where('dp_name_slug', '=', $slug)
         ->where('dp_status_id',1) 
         ->with(['services' => function($query) {
          $query->where('service_status_id', '=', '1');
        }])
       ->with(['images' => function ($query) {
            $query
            ->where('image_status', 'active')
            ->where('image_type', 'dp')
            ->where('dp_image_value','image');
        }])   
        ->firstOrFail();

I set the relation like this.


public function images() {

  return $this->belongsToMany('App\Image','dp_image')->withPivot('dp_image_value');
  }


Any idea what is causing the issue? i want to be able to run the second query.

thanks in advance

May
19
2 months ago
Activity icon

Replied to Getting Extention Of Image

I solved it. It saved the pivot data etc. to my database showing the name with the pivot data. thanks for the help!

Activity icon

Replied to Getting Extention Of Image

Yes it is the column

this is the query where i use the pivot.

$dps = dp::with('places')->where('dp_status_id',1)->wherehas('images' , function ($query) {
        $query
        ->where('image_status', 'active')
        ->where('image_type', 'dp')
        ->where('dp_image_value',null);
        })
        ->with(['images' => function ($query) {
        $query
        ->where('image_status', 'active')
        ->where('image_type', 'dp')
        ->where('dp_image_value',null);
        }])

        ->limit(2)
        ->get(); 


dd(dps->images);


Collection {#602 ▼
  #items: array:1 [▼
    3 => Image {#614 ▼
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:10 [▼
        "id" => 9138
        "image_user_id" => 1
        "image_group_id" => 1
        "image_type" => "dp"
        "image_original_name" => "test-p-map.png"
        "image_filename" => "test-p-map.png"
        "image_path_wordpress" => ""
        "image_status" => "active"
        "created_at" => "2020-05-18 16:24:00"
        "updated_at" => "2020-05-18 16:24:00"
      ]
      #original: array:13 [▼
        "id" => 9138
        "image_user_id" => 1
        "image_group_id" => 1
        "image_type" => "dp"
        "image_original_name" => "test-p-map.png"
        "image_filename" => "test-p-map.png"
        "image_path_wordpress" => ""
        "image_status" => "active"
        "created_at" => "2020-05-18 16:24:00"
        "updated_at" => "2020-05-18 16:24:00"
        "pivot_dp_id" => 44
        "pivot_image_id" => 9138
        "pivot_dp_image_value" => "map"
      ]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: array:1 [▼
        "pivot" => Pivot {#587 ▶}
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: []
      #guarded: array:1 [▼
        0 => "*"
      ]
    }
  ]
}

any idea why he takes the pivot value?

Activity icon

Replied to Getting Extention Of Image

Michal, thanks for the reply.

The challenge is that i need the pivot to filter my data. So i need the use the model including the pivot.

Any other method to get only the extention?

Activity icon

Started a new Conversation Getting Extention Of Image

i want to get an extension of a file from a collection.

I have done the following:

$info = pathinfo($image->image_filename);
dd($info['extension']);

this is the output i get. I get the extension including the pivot.

Maartens-MacBook-Pro:XXX$ php artisan Innitalsetup:CleanupImages

"jpg","pivot":{"dp_id":44,"image_id":9089,"dp_image_value":null}}"

My model is:

 //relation services
  public function images() {

  return $this->belongsToMany('App\Image','dp_image')->withPivot('dp_image_value');
  }


Question: how to get the clear extention?

Activity icon

Replied to Filter Collection

This work perfect! thanks for the help!

Activity icon

Replied to Filter Collection

I tried setting up this before but doesn't work.

this is the setup:

Model:


 public function images() {

  return $this->belongsToMany('App\Image','dp_image')->withPivot('dp_image_value');
  }

this works:

hereby is the value a column in my image tabel.


        $dp = Dp::with('images')->find($id);
        $current_map_name = $dp->images->filter (function($value) {
            if($value['image_user_id'] == 1) {
                return true;
            }
         });

But this doesn't work:

Hereby the value is a pivot value in my dp_image table.




        $dp = Dp::with('images')->find($id);
        $current_map_name = $dp->images->filter (function($value) {
            if($value['dp_image_value'] == 'map') {
                return true;
            }
         });

Any idea why this doesn't work?

Activity icon

Replied to Filter Collection

Thanks again!

I think i'm making myself not clear here. This is what i try to do:

  • i want to run the query to get all images. This creates the collection $dp

After that i want to filter the $dp without running the query again.

I think to only why is to run a loop?

With for example filter()

Activity icon

Replied to Filter Collection

Micheal,

thanks for your quick reaction. This is an solution indeed.

I try to do the following:

Run 1 querry: getting all the images.

Filter the query later based on the pivot value. This way i only need 1 query. I was wondering if that is possible without a loop.

Do you know a way?

thanks in advanced.

maarten

Activity icon

Started a new Conversation Filter Collection

Good day,

I'm trying to filter the following:

Querry:

$dp =  Dp::with('images')-> find($id);

Filter on the collection:

$active_images = $dp->images->where('image_status', 'active'); 

dd($active_images);

Gives this:

Collection {#1151 ▼
  #items: array:4 [▼
    0 => Image {#611 ▼
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:10 [▼
        "id" => 9089
        "image_user_id" => 1
        "image_group_id" => 1
        "image_type" => "dp"
        "image_original_name" => "3806f7333475f4cca6bf17d6cbe0edc67c91ed91canstockphoto5174714.jpg"
        "image_filename" => "hven-1-1587494582602.jpg"
        "image_path_wordpress" => ""
        "image_status" => "active"
        "created_at" => "2020-04-21 18:43:02"
        "updated_at" => "2020-04-21 18:43:02"
      ]
      #original: array:13 [▼
        "id" => 9089
        "image_user_id" => 1
        "image_group_id" => 1
        "image_type" => "dp"
        "image_original_name" => "3806f7333475f4cca6bf17d6cbe0edc67c91ed91canstockphoto5174714.jpg"
        "image_filename" => "hven-1-1587494582602.jpg"
        "image_path_wordpress" => ""
        "image_status" => "active"
        "created_at" => "2020-04-21 18:43:02"
        "updated_at" => "2020-04-21 18:43:02"
        "pivot_dp_id" => 44
        "pivot_image_id" => 9089
        "pivot_dp_image_value" => null
      ]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: array:1 [▼
        "pivot" => Pivot {#610 ▼
          +pivotParent: Dp {#601 ▶}
          #foreignKey: "dp_id"
          #relatedKey: "image_id"
          #guarded: []
          #connection: null
          #table: "dp_image"
          #primaryKey: "id"
          #keyType: "int"
          +incrementing: true
          #with: []
          #withCount: []
          #perPage: 15
          +exists: true
          +wasRecentlyCreated: false
          #attributes: array:3 [▼
            "dp_id" => 44
            "image_id" => 9089
            "dp_image_value" => null
          ]
          #original: array:3 [▶]
          #changes: []
          #casts: []
          #dates: []
          #dateFormat: null
          #appends: []
          #dispatchesEvents: []
          #observables: []
          #relations: []
          #touches: []
          +timestamps: false
          #hidden: []
          #visible: []
          #fillable: []
        }
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: []
      #guarded: array:1 [▶]
    }
    1 => Image {#612 ▶}
    2 => Image {#613 ▶}
    3 => Image {#614 ▶}
  ]
}

I like to filter on the pivot value " dp_image_value". this does not work -> dd output -> collection empty

Wanted output: only the image with the "dp_image_value" = "map"

 $active_images = $dp->images->where('dp_image_value', 'map'); 

Is there a way to do this? Does laravel has a helper for this? Or must i loop the collection?

Thanks for the reaction.

May
04
3 months ago
Activity icon

Started a new Conversation How To Set Many 301 Redirects In Laravel?

I moving from a wordpress website to a laravel app

By doing so i like to catch all the missing urls with 301 redirect. Because of the amount of links i don't want to do this by htaccess by hand.

I thinking of setting up a table where is can set the old an new url.

What is the best way to do this in laravel?

Thanks for the reply!

maarten

Apr
30
3 months ago
Apr
29
3 months ago
Activity icon

Started a new Conversation How To Setup A Login Via A Button Within An Email

dear all,

I like to create the following:

  • I will send users a task by an email.
  • The user should do something in de backoffice off the website
  • in the email i like the put a button. When the user (receiver) of the email clicks on it, it should bring him in the back office of the website. Without having to login manually.

What is the best way to do this?

Im still running laravel 5.5

Thanks for the reactions.

Apr
28
3 months ago
Activity icon

Awarded Best Reply on Mail Partials Don't Work

founded, i used a old file. Partials are located under the vender/html etc.

Activity icon

Replied to Mail Partials Don't Work

founded, i used a old file. Partials are located under the vender/html etc.

Activity icon

Started a new Conversation Mail Partials Don't Work

I'm using mailables within laravel. Including partials.

When i send a message: the following happens:

  • The mail is send
  • The @component('mail::message') works fine (including updates)
  • The partials emailfooter,etc are included but it is not possible to update them. They don't so any adjustments. Looks like they are cached or so.

Any solution to fix this?

Thanks in advance.

mail.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
@include('partials.emails.xxx._emailheader')
@yield ('email_content')
@include('partials.emails.xxx._emailafsluitingcontact')
@include('partials.emails.xxx._emailfooter')
</body>
</html>

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class UserCreationConfirm extends Mailable
{
    use Queueable, SerializesModels;
    
    Public $user;
    Public $request;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($user, $request)
    {
    
    $this->request = $request; 
    $this->user = $user;
    $this->email = '[email protected]';
    $this->name = '[email protected]';
    $this->subject = 'xxx' ;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
         return $this->from($this->email, $this->name)
                    ->subject($this->subject)
                    ->markdown('emails.xxx.UserCreationConfirmMail');
    }
}
Activity icon

Awarded Best Reply on Moving Files On Digitalocean Spaces

We don't got it working. It seems that DO does not support moving images.

Activity icon

Awarded Best Reply on Do Spaces - How To Set Images Public

I solleved it by:

 Storage::disk('do-spaces')->setVisibility('xxx/uploads/temp/'.$filename, 'public');

Activity icon

Replied to Do Spaces - How To Set Images Public

I solleved it by:

 Storage::disk('do-spaces')->setVisibility('xxx/uploads/temp/'.$filename, 'public');

Activity icon

Replied to Moving Files On Digitalocean Spaces

We don't got it working. It seems that DO does not support moving images.

Apr
17
3 months ago
Activity icon

Started a new Conversation Command Running Out Of Memory

Dear all,

i'm running on my local macbook an command.

It works fine but when i select to many variables i get the following error. It seems that my memory should be able to proces but is not.

Maartens-MacBook-Pro:lxxx xxx$ php artisan innitalsetup:requestdata
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 4181440 bytes) in /Users/xxx/Applications/xxvendor/laravel/framework/src/Illuminate/Support/Collection.php on line 1515

In Collection.php line 1515:

  Allowed memory size of 134217728 bytes exhausted (tried to allocate 4181440 bytes)



Any idea how to solve?

thanks for the reaction.

Apr
10
4 months ago
Activity icon

Started a new Conversation Moving Files On Digitalocean Spaces

I have a issue with moving images on digitalocean. I'm using the following code:

Storage::disk('do-spaces')->move('xxx/uploads/temp/'.$image_name_request, 'xxx/dps/images/'.$image->image_filename);    

I did the following checks:

  • changing temp to temp1 gives error that he can't find the image. So it seems he can find the temp image.
  • both $image_name_request and $image->image_filename are set

Code does not give an error but nothing is changed on digitalocean spaces.

Any idea what i'm doing wrong or a way to debug this?

Activity icon

Started a new Conversation Do Spaces - How To Set Images Public

Good day,

I'm uploading images to do spaces by storeas:

 $request->file('file')->storeAs('xxx/uploads/temp/',$filename, 'do-spaces');

In the documentation i see the following:

Storage::putFileAs('photos', new File('/path/to/photo'), 'photo.jpg');
Storage::putFile('photos', new File('/path/to/photo'), 'public');


It looks like i have to choose between name of or setting public.

What is the best way to do this?

thanks for the reaction.

Activity icon

Replied to How To View Variables?

thanks, that can be very helpful indeed!

Activity icon

Replied to How To View Variables?

nakov,

thanks for your reaction. At the end i was able to solve it. I seems that the package also runs a foreach. So that was not needed. I also had to do with the multi upload settings of the package. That was causing the problems.

Thanks for the help anyway!

public function store(Request $request){

          
            $filename = sha1(time()).$request->file('file')->getClientOriginalName();
            $request->file('file')->storeAs('xxx/uploads/temp/',$filename, 'do-spaces');

            return Response::json($filename);
            
    }

settings: uploadmultiple was true is to false.

//images zone
Dropzone.options.myAwesomeDropzone = { // The camelized version of the ID of the form element
            url: '/dropzone/store',

            uploadMultiple: false, 
            parallelUploads: 5,


Apr
03
4 months ago
Activity icon

Replied to How To View Variables?

@nakov,

i tried. But got the following error;

dropzone.min.js:1 POST http://ligplaats.test/dropzone/store 500 (Internal Server Error)
c.submitRequest @ dropzone.min.js:1
c.uploadFiles @ dropzone.min.js:1
c.processFiles @ dropzone.min.js:1
c.processQueue @ dropzone.min.js:1
(anonymous) @ dropzone.min.js:1
setTimeout (async)
c.enqueueFile @ dropzone.min.js:1
(anonymous) @ dropzone.min.js:1
accept @ dropzone.min.js:1
c.accept @ dropzone.min.js:1
c.addFile @ dropzone.min.js:1
(anonymous) @ dropzone.min.js:1

As soon as i introduce the request $request it goes down.

The script i posted is working but i want to have insights wat is happening. With the script i have to issues:

  1. if i do a multi load of the images they all get the same name (he overrides them). So the file name is not set unique. I think it has to do with the [0]. Does it?

  2. i like to upload the images to DO spaces. So i have to adjust the $destinationpath. I can't get it working because i don't know how it looks like (can't see the variables)

Any idea how to solve those things?

Activity icon

Replied to How To View Variables?

Nakov,

thanks for your reply. The function is not loaded by a request. The page does not refresh. So i think it i done by javascript. How sends it by the router.

https://www.dropzonejs.com/bootstrap.html

Route::post('dropzone/store', '[email protected]');
Route::put('dropzone/store', '[email protected]');

uploadcontroller:


 /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store()
    {
      //session_start();
      $inp = Input::all();
      $destinationPath = 'storage/xxx/uploads/temp'; // upload path
      $extension = $inp["file"][0]->getClientOriginalExtension(); // getting image extension
      $fileName = Auth::id().time().$inp['file'][0]->getClientOriginalName(); // renameing image
      $inp["file"][0]->move($destinationPath, $fileName); // uploading file to given path

      return $fileName;
    }

Someone else has installed this for me in the past. Secondly i'm new in programming and don't have knowledge from javascript etc.

Any other suggestion?

Activity icon

Started a new Conversation How To View Variables?

good day,

I'm using dropzone js to upload my images. This package automatically uploads my images to a temp folder. This is done by an function in a controller. (route brings request to controller)

I want to get the values of the variables in the controller. But when i use

dd($xx);

it won't show anything,

Is there a way to breakout the function in the controller when it used to show the variable?

thanks in advance.

Apr
02
4 months ago
Activity icon

Awarded Best Reply on How To Setup Pleague Glide With Digital Ocean Spaces?

Bobby,

thanks for your reaction.

The reason why i use glide is because the package helps me the crop the images to the right dimensions. So i can keep the original in place and create a cached image with the right dimensions.

So my plan is to:

  • save the original on do spaces
  • save the cached images on my webserver

About the last step i'm thinking of putting these on do spaces as well. Don't know what is best.

What do you think about this way of working? Do you suggest a different approach?

About the problem: i got it working with help of this post: https://github.com/thephpleague/glide/issues/100

For people interested:

  • i used the default filestem adjustments
  'do-spaces' => [
            'driver' => 's3',
            'key' => 'xxx',
            'secret' => 'xxx',
            'region' => 'ams3',
            'bucket' => 'xx',
            'endpoint' => 'https://ams3.digitaloceanspaces.com',
        ],

in combination with this in my controllers.

 public function show_listing_230(Filesystem $filesystem, $path)
     {
        $server = ServerFactory::create([
            'response' => new LaravelResponseFactory(app('request')),
            'source' => Storage::disk('do-spaces')->getDriver(),
            'source_path_prefix' => '/xxx/images/listings/230',
            'cache' => Storage::disk('local')->getDriver(),
            'cache_path_prefix'     => '/xxx/images/listings/230/cache_images',
            'base_url' => 'img_listing/230/',
        ]);

         return $server->getImageResponse($path, request()->all());
     }


Activity icon

Started a new Conversation How Can I Move A File From Local To DO Spaces?

Dear all,

Currently i'm saving my temporary files first on my webserver in a "temp" folder. When they are renamed i want to move them to a digitalocean spaces.

I currently have this:

 File::move('storage/xxx/uploads/temp/'.$oldname, 'storage/xxx/images/dps/'.$newname);

In the documentation the only give a solution for moving within a storage.

Storage::move('old/file1.jpg', 'new/file1.jpg');

How can i setup a situation where i move the file from local to spaces?

thanks in advance

Apr
01
4 months ago
Activity icon

Started a new Conversation Fress Laravel 7 Causes Error By Running Npm Install

Im setting up a new new app with laravel. But during the process i get errors when i run "npm install".

question:

what are causing these errors and what to do with it?

See here the steps i have taken.

Maartens-MacBook-Pro:watersporter mbolivier$ composer require laravel/ui
Using version ^2.0 for laravel/ui
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing laravel/ui (v2.0.1): Loading from cache
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
Maartens-MacBook-Pro:watersporter mbolivier$ php artisan ui bootstrap --auth
Bootstrap scaffolding installed successfully.
Please run "npm install && npm run dev" to compile your fresh scaffolding.
Authentication scaffolding generated successfully.
Maartens-MacBook-Pro:xx mb$ npm install
npm WARN deprecated [email protected]: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

> [email protected] install /Users/mb/Applications/watersporter/node_modules/fsevents
> node-gyp rebuild

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Traceback (most recent call last):
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 523, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2170, in GenerateOutput
    part_of_all=qualified_target in needed_targets)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 795, in Write
    self.Pchify))
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1190, in WriteSources
    cflags = self.xcode_settings.GetCflags(configname)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 551, in GetCflags
    archs = self.GetActiveArchs(self.configname)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 420, in GetActiveArchs
    xcode_archs_default = GetXcodeArchsDefault()
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 118, in GetXcodeArchsDefault
    xcode_version, _ = XcodeVersion()
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1265, in XcodeVersion
    version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at ChildProcess.emit (events.js:159:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/mbolivier/Applications/watersporter/node_modules/fsevents
gyp ERR! node -v v9.2.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] requires a peer of [email protected]^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected]>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

added 1146 packages in 20.165s
Maartens-MacBook-Pro:xx mb$

Activity icon

Started a new Conversation How To Upload A File To Do Spaces

Good day,

I have a form why user can upload files by ajax script. Currently the preload places the files on my local webserver. The connection with DO spaces works.

But i can't get it working to rewrite the code below so it places the file on my do spaces.

I tried to work with:

storage::disk('do-spaces')->PutFileAs();

But i don't get it running with the code blowe (some else created this part).

Uploadcontroller:

/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store()
    {
      $inp = Input::all();
      $destinationPath = 'storage/xx/uploads/temp'; // upload path
      $extension = $inp["file"][0]->getClientOriginalExtension(); // getting image extension
      $fileName = Auth::id().time().$inp['file'][0]->getClientOriginalName(); // renameing image
      $inp["file"][0]->move($destinationPath, $fileName); // uploading file to given path
      return $fileName;
    }

Help would be appreciated.

thanks in advance.

Mar
31
4 months ago
Activity icon

Replied to How To Setup Pleague Glide With Digital Ocean Spaces?

Bobby,

thanks for your reaction.

The reason why i use glide is because the package helps me the crop the images to the right dimensions. So i can keep the original in place and create a cached image with the right dimensions.

So my plan is to:

  • save the original on do spaces
  • save the cached images on my webserver

About the last step i'm thinking of putting these on do spaces as well. Don't know what is best.

What do you think about this way of working? Do you suggest a different approach?

About the problem: i got it working with help of this post: https://github.com/thephpleague/glide/issues/100

For people interested:

  • i used the default filestem adjustments
  'do-spaces' => [
            'driver' => 's3',
            'key' => 'xxx',
            'secret' => 'xxx',
            'region' => 'ams3',
            'bucket' => 'xx',
            'endpoint' => 'https://ams3.digitaloceanspaces.com',
        ],

in combination with this in my controllers.

 public function show_listing_230(Filesystem $filesystem, $path)
     {
        $server = ServerFactory::create([
            'response' => new LaravelResponseFactory(app('request')),
            'source' => Storage::disk('do-spaces')->getDriver(),
            'source_path_prefix' => '/xxx/images/listings/230',
            'cache' => Storage::disk('local')->getDriver(),
            'cache_path_prefix'     => '/xxx/images/listings/230/cache_images',
            'base_url' => 'img_listing/230/',
        ]);

         return $server->getImageResponse($path, request()->all());
     }


Mar
30
4 months ago
Activity icon

Started a new Conversation How To Setup Pleague Glide With Digital Ocean Spaces?

Good day

I'm using glide of https://glide.thephpleague.com/ for showing and cashing my images. Till now i saved my images on my webserver. No i want do place them on Digital Ocean spaces.

But i can't get it working.

current setup:

  • imagecontroler where i handle the images.
  • installed league/flysystem-aws-s3-v3

to make it working i should work with: https://flysystem.thephpleague.com/v1/docs/adapter/digitalocean-spaces/

use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;

$client = new S3Client([
    'credentials' => [
        'key'    => 'your-key',
        'secret' => 'your-secret',
    ],
    'region' => 'your-region',
    'version' => 'latest|version',
    'endpoint' => 'https://your-region.digitaloceanspaces.com',
]);

$adapter = new AwsS3Adapter($client, 'your-bucket-name');

$filesystem = new Filesystem($adapter);

this is what my imagecontroller looks like:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Contracts\Filesystem\Filesystem;
use League\Glide\Responses\LaravelResponseFactory;
use League\Glide\ServerFactory;
use App\Http\Requests;


class ImageController extends Controller
{

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
     public function show(Filesystem $filesystem, $path)
     {
 
        $server = ServerFactory::create([
            'response' => new LaravelResponseFactory(app('request')),
            'source' => 'xx/uploads/images',
            'cache' => 'xx/uploads/cache_images',
            'base_url' => 'img',
        ]);

         return $server->getImageResponse($path, request()->all());
     }   

}

my question is:

where to use this extra code for the adapter? And why?

Thanks in advance.

Mar
28
4 months ago
Activity icon

Replied to Call To Undefined Function In Helper File.

Snapey, thanks for the reply. Im wondering: is there a way to set my local development to case sensitive?

i develop on: mac > valet.

thanks!

Activity icon

Replied to Call To Undefined Function In Helper File.

Bobby,

thanks for the reaction. That is also a solution indeed. I like to have it by a folder. But that is not going to work for now. Maybe it is connect to another issue i have with the fact that my env file does give any values to other files as well. Thanks anyway.

Activity icon

Replied to Call To Undefined Function In Helper File.

Bobbybouwmann,

thanks for your reply.

I thought this was the solution. But by ending the provider i didn't work on my local machine as well. So it seems that the classmap in composer.jon does not work. Any idea how to solve this?

To make sure is it not the function that is not working i called some other functions as well.

i also run composer dump autoload. Did not solve it either.

thanks for the reply

Activity icon

Replied to Laravel Installing Won't Install On Local Server

thanks! it worked out. Moved one step up in and run the command again. No issues with maps any more. Thanks for the help!

Activity icon

Replied to Laravel Installing Won't Install On Local Server

thanks!

that worked. But i placed in folder b again folder b.

To better understand; what was the laravel/laravel do?

Activity icon

Replied to Laravel Installing Won't Install On Local Server

tray2

thanks for your reaction.

yes i have

PHP 7.3.8 (cli) (built: Aug 6 2019 23:15:07) ( NTS ) Copyright (c) 1997-2018 The PHP Group

any other idea?

I looks like it moves directory. Can that cause the issue?

Activity icon

Started a new Conversation Laravel Installing Won't Install On Local Server

good day,

im trying to install a new laravel app in a new directory on my mac.

this is what i did:

  • install valet etc (long time ago)
  • running a website in folder A
  • Want to setup a website in folder B
  • Already created the folder B. It starts up by valet (tested and index.html file)

The challange:

by running

composer global require laravel/installer

i get the following error message.

Any idea what i'm doing wrong?

Thanks for the help!

Maartens-MacBook-Pro:b mbo$ composer global require laravel/installer
Changed current directory to /Users/mbo/.composer
Using version ^3.0 for laravel/installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel/installer v3.0.1
    - Conclusion: remove symfony/console v3.4.30
    - Installation request for laravel/installer ^3.0 -> satisfiable by laravel/installer[v3.0.0, v3.0.1].
    - Conclusion: don't install symfony/console v3.4.30
    - laravel/installer v3.0.0 requires symfony/console ^4.0|^5.0 -> satisfiable by symfony/console[v4.0.0, v4.0.1, v4.0.10, v4.0.11, v4.0.12, v4.0.13, v4.0.14, v4.0.15, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.2, v4.1.3, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.0, v4.2.1, v4.2.10, v4.2.11, v4.2.12, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9, v4.3.0, v4.3.1, v4.3.10, v4.3.11, v4.3.2, v4.3.3, v4.3.4, v4.3.5, v4.3.6, v4.3.7, v4.3.8, v4.3.9, v4.4.0, v4.4.1, v4.4.2, v4.4.3, v4.4.4, v4.4.5, v4.4.6, v5.0.0, v5.0.1, v5.0.2, v5.0.3, v5.0.4, v5.0.5, v5.0.6].
    - Can only install one of: symfony/console[v4.0.0, v3.4.30].
    - Can only install one of: symfony/console[v4.0.1, v3.4.30].
    - Can only install one of: symfony/console[v4.0.10, v3.4.30].
    - Can only install one of: symfony/console[v4.0.11, v3.4.30].
    - Can only install one of: symfony/console[v4.0.12, v3.4.30].
    - Can only install one of: symfony/console[v4.0.13, v3.4.30].
    - Can only install one of: symfony/console[v4.0.14, v3.4.30].
    - Can only install one of: symfony/console[v4.0.15, v3.4.30].
    - Can only install one of: symfony/console[v4.0.2, v3.4.30].
    - Can only install one of: symfony/console[v4.0.3, v3.4.30].
    - Can only install one of: symfony/console[v4.0.4, v3.4.30].
    - Can only install one of: symfony/console[v4.0.5, v3.4.30].
    - Can only install one of: symfony/console[v4.0.6, v3.4.30].
    - Can only install one of: symfony/console[v4.0.7, v3.4.30].
    - Can only install one of: symfony/console[v4.0.8, v3.4.30].
    - Can only install one of: symfony/console[v4.0.9, v3.4.30].
    - Can only install one of: symfony/console[v4.1.0, v3.4.30].
    - Can only install one of: symfony/console[v4.1.1, v3.4.30].
    - Can only install one of: symfony/console[v4.1.10, v3.4.30].
    - Can only install one of: symfony/console[v4.1.11, v3.4.30].
    - Can only install one of: symfony/console[v4.1.12, v3.4.30].
    - Can only install one of: symfony/console[v4.1.2, v3.4.30].
    - Can only install one of: symfony/console[v4.1.3, v3.4.30].
    - Can only install one of: symfony/console[v4.1.4, v3.4.30].
    - Can only install one of: symfony/console[v4.1.5, v3.4.30].
    - Can only install one of: symfony/console[v4.1.6, v3.4.30].
    - Can only install one of: symfony/console[v4.1.7, v3.4.30].
    - Can only install one of: symfony/console[v4.1.8, v3.4.30].
    - Can only install one of: symfony/console[v4.1.9, v3.4.30].
    - Can only install one of: symfony/console[v4.2.0, v3.4.30].
    - Can only install one of: symfony/console[v4.2.1, v3.4.30].
    - Can only install one of: symfony/console[v4.2.10, v3.4.30].
    - Can only install one of: symfony/console[v4.2.11, v3.4.30].
    - Can only install one of: symfony/console[v4.2.12, v3.4.30].
    - Can only install one of: symfony/console[v4.2.2, v3.4.30].
    - Can only install one of: symfony/console[v4.2.3, v3.4.30].
    - Can only install one of: symfony/console[v4.2.4, v3.4.30].
    - Can only install one of: symfony/console[v4.2.5, v3.4.30].
    - Can only install one of: symfony/console[v4.2.6, v3.4.30].
    - Can only install one of: symfony/console[v4.2.7, v3.4.30].
    - Can only install one of: symfony/console[v4.2.8, v3.4.30].
    - Can only install one of: symfony/console[v4.2.9, v3.4.30].
    - Can only install one of: symfony/console[v4.3.0, v3.4.30].
    - Can only install one of: symfony/console[v4.3.1, v3.4.30].
    - Can only install one of: symfony/console[v4.3.10, v3.4.30].
    - Can only install one of: symfony/console[v4.3.11, v3.4.30].
    - Can only install one of: symfony/console[v4.3.2, v3.4.30].
    - Can only install one of: symfony/console[v4.3.3, v3.4.30].
    - Can only install one of: symfony/console[v4.3.4, v3.4.30].
    - Can only install one of: symfony/console[v4.3.5, v3.4.30].
    - Can only install one of: symfony/console[v4.3.6, v3.4.30].
    - Can only install one of: symfony/console[v4.3.7, v3.4.30].
    - Can only install one of: symfony/console[v4.3.8, v3.4.30].
    - Can only install one of: symfony/console[v4.3.9, v3.4.30].
    - Can only install one of: symfony/console[v4.4.0, v3.4.30].
    - Can only install one of: symfony/console[v4.4.1, v3.4.30].
    - Can only install one of: symfony/console[v4.4.2, v3.4.30].
    - Can only install one of: symfony/console[v4.4.3, v3.4.30].
    - Can only install one of: symfony/console[v4.4.4, v3.4.30].
    - Can only install one of: symfony/console[v4.4.5, v3.4.30].
    - Can only install one of: symfony/console[v4.4.6, v3.4.30].
    - Can only install one of: symfony/console[v5.0.0, v3.4.30].
    - Can only install one of: symfony/console[v5.0.1, v3.4.30].
    - Can only install one of: symfony/console[v5.0.2, v3.4.30].
    - Can only install one of: symfony/console[v5.0.3, v3.4.30].
    - Can only install one of: symfony/console[v5.0.4, v3.4.30].
    - Can only install one of: symfony/console[v5.0.5, v3.4.30].
    - Can only install one of: symfony/console[v5.0.6, v3.4.30].
    - Installation request for symfony/console (locked at v3.4.30) -> satisfiable by symfony/console[v3.4.30].


Installation failed, reverting ./composer.json to its original content.
Maartens-MacBook-Pro:b mb$



Mar
27
4 months ago
Activity icon

Replied to Call To Undefined Method - Laravel Impersonate

zsoltgyure,

Thanks for the reaction. I expected to work with the default Missed some words.

thanks for the sollution!

Activity icon

Started a new Conversation Call To Undefined Method - Laravel Impersonate

goodday,

I setting up an package: laravel impersonate.

https://github.com/404labfr/laravel-impersonate

After installing it give the following error if when i use the the following:

what i did:

composer require lab404/laravel-impersonate

Add the service provider at the end of your config/app.php:
'providers' => [
    // ...
    Lab404\Impersonate\ImpersonateServiceProvider::class,
],

Add the trait Lab404\Impersonate\Models\Impersonate to your User model.

placed: Route::impersonate();

run: php artisan vendor:publish --tag=impersonate


By running the following i get the error's

@canBeImpersonated($user)
    <a href="{{ route('impersonate', $user->id) }}">Impersonate this user</a>
@endCanBeImpersonated

error:

Call to undefined method Illuminate\Database\Query\Builder::canBeImpersonated() (View: /Users/mbolivier/Applications/ligplaats/resources/views/my-account/users/index_admin.blade.php)


any help would be appreciated.

thanks

Activity icon

Replied to Missing Required Client Configuration Options - Setting Up DO Spaces

This is what i got now:

filesytem:


        'do-spaces' => [
            'driver' => 's3',
            'key' => env('DO_SPACES_ACCESS_KEY_ID'),
            'secret' => env('DO_SPACES_SECRET_ACCESS_KEY'),
            'region' => env('DO_SPACES_DEFAULT_REGION'),
            'bucket' => env('DO_SPACES_BUCKET'),
            'endpoint' => env('DO_SPACES_URL'),
        ],

env:

DO_SPACES_ACCESS_KEY_ID=xx
DO_SPACES_SECRET_ACCESS_KEY=xx
DO_SPACES_DEFAULT_REGION=ams3
DO_SPACES_BUCKET=watiles
DO_SPACES_URL=ams3.digitaloceanspaces.com

this the reaction of thinker:


Maartens-MacBook-Pro:lis mbo$ php artisan tinker
Psy Shell v0.9.12 (PHP 7.3.8 — cli) by Justin Hileman
>>> env("DO_SPACES_ACCESS_KEY_ID")
=> null
>>> env('DO_SPACES_ACCESS_KEY_ID')
=> null
>>>

any idea?