akLearn

Experience

3,740

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 32 Lessons Completed
  • 0 Favorites

14th July, 2018

akLearn left a reply on Is DigitalOcean's Bucket A Reliable Server? • 1 week ago

I'm surprised no one else in the community used DigitalOcean's services.

akLearn started a new conversation Is DigitalOcean's Bucket A Reliable Server? • 1 week ago

Hi everyone,

We've recently moved to DigitalOcean and are using their buckets to save non-structured data(mp3s). However, their bucket has been having problems for the past couple of days.

Can anyone share the experience they've had with DigitalOcean? Would appreciate anything you have to share? Should we move to Amazon?

11th July, 2018

akLearn left a reply on Eloquent Creates New Record Sometimes And Fails Sometimes • 1 week ago

Ok... So, I found the problem. In case anyone else is having a similar problem....

There was another line of code which was failing. This was causing my API to crash silently. This was only happening in one scenario where partial information was given.

Long story short. It's not eloquent which is causing the crash. It's some other line of code you probably wrote.

@Dalma Thanks! I learned something new.

akLearn left a reply on Eloquent Creates New Record Sometimes And Fails Sometimes • 1 week ago

Sure... The create call. I'm importing some data from an older site's DB. I don't which values are blank. So, I'm using the empty function check. Also, in the DB i've set the attributes to be nullable.


          // Save the values
             $newTape = Tape::create([
                  'id' => $request->id,
                  'name' => (!empty($request->tape_name)?"$request->tape_name":NULL),
                  'artist_id' => ($request->artist_id?$request->artist_id:null),
                  'artist_name' => (!empty($request->artist_name)?"$request->artist_name":null),
                  'tape_by' => ($request->artist_id?$request->artist_id:null),
                  'category' => ($request->category?$request->category:null),
                  'status' => 'active',
                  'views' => ($request->views?$request->views:null),
                  'downloads' => ($request->downloads?$request->downloads:null),
                  'keywords' => ($request->keywords?"$request->keywords":null),
                  'created_at' => (!empty($request->created_at)?"$request->created_at":null),
                  'tape_url' => (!empty($request->tape_url)?"$request->tape_url":null),
                  'cover_image' => $albumTapeCover
             ]);

The model


namespace App;

use Illuminate\Database\Eloquent\Model;

class Tape extends Model { protected $fillable = [ 'id','name', 'artist_id', 'artist_name', 'tape_by', 'category', 'status', 'views', 'downloads', 'keywords', 'tape_url', 'cover_image' ];

public $timestamps = true;

protected $dates = ['created_at','updated_at'];
public $incrementing = false;
/**
* Gets the user this tape belongs to
*/
public function user() {
     return $this->hasOne('App\User','id','artist_id');
}

/**
* Get the tracks that are on this tape
*/
public function tracks() {
     return $this->hasMany('App\Track','tape_id','id');
}

/**
* Get the category info
*/
public function categoryInfo() {
     return $this->hasOne('App\TapeCategory','id','category');
}

}

akLearn started a new conversation Eloquent Creates New Record Sometimes And Fails Sometimes • 1 week ago

Hi,

I have a simple create query. It creates a new record at times and fails at times. Is there a way to get more information as to why it's failing. Is there a missing attribute, etc?

By the way, aside from the id of the table I set every attribute to not required (null-able)

4th July, 2018

akLearn left a reply on Storage::disk('something')->move($oldLocation, $newLocation) Fails But No Hints • 2 weeks ago

I went to Digital Oceans web panel access of the bucket and tried to rename the file there. I was thinking that maybe there's a security issue that's preventing the file name change.

It accepted simple file name changes but didn't allow me to save names with special characters.

Yeah, that is weird. They should have a note that shows up on top of the web panel at least as a warning to users.

akLearn left a reply on Storage::disk('something')->move($oldLocation, $newLocation) Fails But No Hints • 2 weeks ago

If anyone is following along, here's what happened. Digital Ocean has a rule where they don't allow you to save special characters in your filename. So, here's an example of what I was trying to save "03 - Cops And Rob [Prod By Zt].mp3".

This was the main reason the above code wasn't working. Hope this helps.

2nd July, 2018

akLearn left a reply on Storage::disk('something')->move($oldLocation, $newLocation) Fails But No Hints • 2 weeks ago

@Cronix $path = 'albums/17/178/mp3/someFile.mp3'; $newName = 'albums/17/178/mp3/newName.mp3';

akLearn left a reply on Storage::disk('something')->move($oldLocation, $newLocation) Fails But No Hints • 2 weeks ago

Thanks for the help @Cronix I misunderstood

Both paths are the same. I printed them out to be sure. The only difference is in the name of the file on the $newName.

akLearn left a reply on Storage::disk('something')->move($oldLocation, $newLocation) Fails But No Hints • 2 weeks ago

@Cronix So, there's one folder on the root called lets say "allMedia". All the paths are from one level up.

So, it's "allMedia/albums/etc"

The $path and $newName are starting from the "albums" onwards. However, I checked if my paths were correct by calling the exists method as shown in the initial post above.

akLearn started a new conversation Storage::disk('something')->move($oldLocation, $newLocation) Fails But No Hints • 2 weeks ago

Hi everyone,

This is driving me nuts. I am using the below to rename a file on DigitalOcean's space bucket storage. Before running the command below, I make sure the file exists on the given path. However, the move method returns a false but no hints as to why the move (rename) is failing.

Please guide me on this.


// the condition below passes
if (Storage::disk('do_spaces')->exists($path)) {
           // this returns false
             Storage::disk('do_spaces')->move($path, $newName); 
}

akLearn left a reply on DigitalOcean Getting Uploaded Files • 2 weeks ago

Thanks for the help guys

Here's what I was doing wrong. Admittedly, I am new to the whole bucket storage scene. I had not gotten the space key and space secret. I needed to set that in the .env and use it in the config/filesystems.php file.

For anyone else who's new, you need to go to the DigitalOcean/AW3 and get these things along with region and other info.

You can view a video tutorial on Youtube . However, this guy goes over the important info after half the video has passed by. https://www.youtube.com/watch?v=vFwy-vB_d_k

Hope this helps

1st July, 2018

akLearn started a new conversation DigitalOcean Getting Uploaded Files • 2 weeks ago

Hi,

I'm new to uploading files to the clould. The MIS guy created a bucket and put a folder on the root. I have uploaded files to that folder but when I try to view those images via the img element, it doesn't show.

Route::get('/testing', function(){ return ''; });

26th June, 2018

akLearn left a reply on I Can Not Run Php Artisan Migrate • 3 weeks ago

Try to run "php artisan " alone. If you get the same error, then there's probably a command (App\Console\Commands) which was created on this project and has an error in it.

You can do a site wide search using some of the keywords above and see if that helps.

akLearn started a new conversation [email protected] And Not [email protected] • 3 weeks ago

Hi,

I've found answers for integrating [email protected] into Laravel 5.4 but nothing about 4.1.1. Which is what the front-end developer used to create the markup.

Does anyone know how to use Bootstrap 4.1.1 with Laravel 5.4? I've tried updating package json but hasn't helped.

25th June, 2018

akLearn left a reply on Search Multiple Tables For A Search Term • 3 weeks ago

@rumm.an I selected your answer as the best answer. Please make the necessary adjustments to it because the "$input" or "$keyword" is not accessible within the query builder anonymous function.

akLearn left a reply on Search Multiple Tables For A Search Term • 3 weeks ago

My mistake. It does work. I wasn't looping through all the records when I was doing QA on the query.


$keyword = 'jo'; $result = Tape::where('name','like','%'.$keyword.'%') ->orWhereHas('user', function($q) use ($keyword){ return $q->where('name','like','%'. $keyword . '%'); }) ->orWhereHas('tracks', function($q) use ($keyword){ return $q->where('name','like','%'. $keyword . '%'); })->get(); foreach($result as $res) { echo $res->name . ' ... Artist: ' . $res->user->name . ' ... '. '
'; foreach($res->tracks as $track) { echo '--------------track: ' . $track->name . '
'; } echo '

'; }

akLearn left a reply on Search Multiple Tables For A Search Term • 3 weeks ago

@ rumm.an

It hasn't worked so far. I did have to change it a little seeing "$input" variable's scope wasn't accessible within the query builder anonymous function.

$result = Tape::where('name','like','%'.$keyword.'%') ->orWhereHas('user', function($q) use ($keyword){ return $q->where('name','like','%'. $keyword . '%'); }) ->orWhereHas('tracks', function($q) use ($keyword){ return $q->where('name','like','%'. $keyword . '%'); })->get(); echo $result[0]->name . ' ... Artist: ' . $result[0]->user->name . ' ... tracks: ' . $result[0]->tracks[0]->name; die();

akLearn started a new conversation Search Multiple Tables For A Search Term • 3 weeks ago

Hi everyone,

I have searched and can't find the answer anywhere. I have three tables (user, tracks, album). I want to search for a single keyword in all three of these tables. So, if a user says "Jangy", I want to search this term as a possible artist name (user table), track name or an album name.

Here's what I tried but know will not work. App\Album::with(['user'=>function($q){ $q->where('name','like','%jo'); } ])->get();

I stopped here because it was returning albums but the users (artist) was blank for some albums. Meaning that the sub-query was not returning any users(artist) which didn't match the sub-condition, but it was returning all albums. I hope that made sense.

And yes, I did try to find the answer on my own but couldn't.

15th June, 2018

akLearn left a reply on Trying To Understand The Mentality • 1 month ago

"When helping others you build up real life karma!" ... I liked this part.

Thanks

akLearn started a new conversation Trying To Understand The Mentality • 1 month ago

Hi everyone,

Why do you guys go out of your way to help others asking the question?

I was going through some of the posts here, Stack overflow, etc. I couldn't understand the benefit of helping people with their development problems.

Why do you do it? What's the pay off? What am I missing?

I feel like asking the same question to people who create great plugins and then hand it out for free.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.