dan3460

dan3460

Member Since 2 Years Ago

Haddon Hts

Experience Points
20,440
Total
Experience

4,560 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
131
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 5
20,440 XP
Jul
03
1 month ago
Activity icon

Replied to Moving Files To Public Directory

I have another problem. I'm moving the files to the public storage, how i can force to overwrite the files, if they are there?

Activity icon

Started a new Conversation Moving Files To Public Directory

I'm a little confused on the way the Storage::move(), and copy or delete, work. My original command was: The content of $file = 'temp/arcash.cvs'

$movedTo = Str::replaceFirst('temp/', '', $file);
Storage::move($file, public_path($movedTo));
...

but i'm getting the following error:

League/Flysystem/Exception with message 'Impossible to create the root directory "C:/Users/Daniel.SFP/Documents/Pr
ojects/Credit Limit/Armanager/storage/app/C:/Users/Daniel.SFP/Documents/Projects/Credit Limit/Armanager/public". '

I can probably hard code the path to the public folder, but i'm puzzled as to why this happens. Could someone explain please.

Jul
02
1 month ago
Activity icon

Replied to DataTables Button Not Recognized On Second Page

Yes, that work. Thanks very much.

Jul
01
1 month ago
Activity icon

Started a new Conversation DataTables Button Not Recognized On Second Page

I have an application that implements yajra datatables. In one of the columns i have a button that when clicked send an email. The button has a class that i use to trigger the action:

$(".salesperson").on('click', function(){
            console.log('salesperson');
            customerNumber = customers.row($(this).closest('tr')).data()[11];
            console.log(customerNumber);
            $.get('/credit/'+customerNumber+'/notifySalesperson');
            $(this).css("background-color","red");
 });

The datatable has pagination. My problem is that when i go to the second page or beyond, the function is not triggered anymore. Any ideas. I don't know what is happening when the button is clicked.

Jun
24
1 month ago
Activity icon

Replied to DataTables Coming Back To A Page

@bobbybouwmann you probably correct. Thanks very much.

Activity icon

Replied to DataTables Coming Back To A Page

@bobbybouwmann, my idea would be if the index page is called from the main menu (the index function on the controller) the state is refreshed. If i'm coming back from the action button, where i have the "return back()", it should save the state. I could change the call to an ajax call from the page so i never leave the page, but i'm trying to save some programming.

Jun
23
1 month ago
Activity icon

Started a new Conversation DataTables Coming Back To A Page

I have a datatable with some action buttons on the rows. The function activated by the button as a:

return back()

On the datatable definition i have:

{
	"stateSve": true
}

This returns me to the same page. My problem is that the state stays even is the site is closed. Any ideas how to solve the problem? Thanks guys,

Activity icon

Started a new Conversation VSC Laravel Blade Not Recognizing Blade

Is anyone using this extension? I don't know what i'm missing but i cannot make the extension recognize blade syntax automatically. Every time that i open a blade i have to go to the bottom left which shows HTML and change it for Laravel Blade. What is the setup that i'm missing?

Jun
10
1 month ago
Activity icon

Replied to Fail To Open File In Public Folder

@bobbybouwmann and you will be correct sir!!, Sorry i didn't come back to the issue as i had to jump into an unrelated problem in my office and just today i'm coming back to this. I don't know what made me think that after changing APP_URL was working correctly, this morning i looked in the database and it was not updated, also the logs of the queues were pointing to not finding the files. Added your suggestion (used the public_path helper) and i see the database updating.

Jun
09
1 month ago
Activity icon

Replied to Fail To Open File In Public Folder

@bobbybouwmann what you just wrote gave me an idea. Because is a new install, i have not finished configure the .env file. The APP_URL was pointing to the address of my desktop. Works fine now.

Thanks

Activity icon

Started a new Conversation Fail To Open File In Public Folder

The application works on my desktop. I just spawn a new Ubuntu server to run the application, is an internal server so there is only basic security. Have a bunch of jobs handled by queues that reads files located in the public folder and process them. On my development desktop works fine, but i'm getting:

fopen(public/customer.csv): failed to open stream: No such file or directory

Using Tinker from the app folder opens the file without a problem. I made sure by changing on of the letters on the name in the second attempt:

>>> $handle = fopen('public/customer.csv','r')
=> stream resource #663
>>> $handle = fopen('public/customer.csr','r')
PHP Warning:  fopen(public/customer.csr): failed to open stream: No such file or directory in Psy Shell code on line 1
=> false

here is the job:

<?php

namespace App\Jobs;

use App\Customer;
use App\Upload;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class ProcessCustomers implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $upload = new Upload;
        $upload->code = 4444; /** Code is an arbitrary number to identify the Process being run */
        $upload->save();
        $handle = fopen('public/customer.csv', 'r');
        while ($csvLine = fgetcsv($handle, 0)) {
            $customer = new Customer;
            $customer->custno = $csvLine[0];
            $customer->name = $csvLine[1];
            $customer->salesman = $csvLine[18];
            $customer->lastsold = ($csvLine[21] == '/  /') ? null : Carbon::createFromFormat('m/d/Y', $csvLine[21]);
            $customer->lastpaid = ($csvLine[22] == '/  /') ? null : Carbon::createFromFormat('m/d/Y', $csvLine[22]);
            $customer->creditLimit = $csvLine[28];
            $customer->dueDays = $csvLine[104];
            $customer->hold = ($csvLine[38] == 'F') ? false : true;
            $customer->email = $csvLine[70];
            $customer->altemail = $csvLine[71];
            $customer->save();
        }
        fclose($handle);
        $upload->delete();
    }
}

any ideas?

May
29
2 months ago
Activity icon

Replied to Update Or Create From New

@joefusco That is interesting, didn't know that such a command existed. I'm guessing you could put the execution of the command as a raw sql from Laravel. I will play with it.

Thanks very much.

May
28
2 months ago
Activity icon

Replied to Update Or Create From New

@joefusco Yes it is looped over and it is going into a MySQL.

 $handle = fopen('customer.csv', 'r');
        while ($csvLine = fgetcsv($handle, 0)) {
            $customer = new Customer;
            $customer->custno = $csvLine[0];
            $customer->name = $csvLine[1];
            $customer->salesman = $csvLine[18];
            $customer->lastsold = ($csvLine[21] == '/  /') ? null : Carbon::createFromFormat('m/d/Y', $csvLine[21]);
            $customer->lastpaid = ($csvLine[22] == '/  /') ? null : Carbon::createFromFormat('m/d/Y', $csvLine[22]);
            $customer->hold = ($csvLine[38] == 'F') ? false : true;
            $customer->email = $csvLine[70];
            $customer->altemail = $csvLine[71];
            $customer->save();
        }
        fclose($handle);
Activity icon

Replied to Update Or Create From New

@bugsysha you are probably correct. I was looking for someone that may have done something similar and it would say to me "oh, i got great results by ....". I did some pruning and the 2 files have about half the records. It takes 30 minutes to process on my desktop, the server should be a little faster, but 30 minutes is doable.

Activity icon

Started a new Conversation Update Or Create From New

I'm running some analysis on data from a system in Visual Fox Pro. The only option that i have to access the data is to dump the tables into CSV files. Even when i'm limiting the data to only one year a couple of tables have more than 500k records each. The process that i'm doing now is truncate the tables and upload the csv files into them. The 2 500k record files take a very long time to upload (i'm not collecting a lot of data from each file). my question is: do you think will be quicker to compare the data from the files and only create the new records and update the ones have changed. Any ideas on speeding up the upload/update of a csv file.

Activity icon

Replied to Ternary Operator Not Working On A Job

@guybrush_threepwood today it work perfectly. Maybe was something stuck on my computer? But a came early in the morning to try your suggestion and run the job before adding the dd, all the dates were fine. Took me a while to make sure that i was running the job and not the controller. Thanks for the help.

May
27
2 months ago
Activity icon

Started a new Conversation Ternary Operator Not Working On A Job

I'm reading a series of CSV files, right now the process is on a controller and i want to move them to a queue. I created separate jobs for each file and it worked ok except for a date field. In the controller the code produces the correct date, but on the job the ternary operator produces just null. The code is the same with the exception of the location of the file, on the controller i just put the name of the file on the job i preface the name with public:

        $handle = fopen('customer.csv', 'r');
        while ($csvLine = fgetcsv($handle, 0)) {
            $customer = new Customer;
            $customer->custno = $csvLine[0];
            $customer->name = $csvLine[1];
            $customer->salesman = $csvLine[18];
            $customer->lastsold = ($csvLine[21] == '/  /') ? null : Carbon::createFromFormat('m/d/Y', $csvLine[21]);
            $customer->lastpaid = ($csvLine[22] == '/  /') ? null : Carbon::createFromFormat('m/d/Y', $csvLine[22]);
            $customer->hold = ($csvLine[38] == 'F') ? false : true;
            $customer->email = $csvLine[70];
            $customer->altemail = $csvLine[71];
            $customer->save();
        }
        fclose($handle);

BTW i'm getting the data from a Visual Fox Pro (yikes) database.

Apr
23
3 months ago
Activity icon

Replied to Need Help Choosing Between Shopify Or Woocommerce

Maybe too late but in any case: I installed Bagisto (https://bagisto.com/en/) and i'm using PayPal to take credit cards, they have a guest feature that doesn't require the customer to create an account with PayPal, the cost is 2.9% + $0.30 per transaction. I think is very well constructed but it is hard to add other custom functionality, i guess once one understand how is made maybe becomes easier.

Apr
17
3 months ago
Activity icon

Started a new Conversation PHP Or C++ Or Something Else

We are developing an application that analyzes a pretty good amount of data of production for several companies. We have a mysql database in the background. I'm using Laravel to display the data, graphs any updates that need to be made to the data set, etc. My question is on the crunching of the numbers and if it will be better to use a different language to it. The analysis is more reading adding and storing back to the database that actually doing big math on the data. My hunch is that the bottleneck is going to be with the database and creating a program in C++(or something else) to do crunching will not significantly improve performance compared to doing it in PHP. The crunching of the numbers is done in the background every certain amount of time. Any opinions or suggestions?

Apr
13
3 months ago
Activity icon

Replied to Jobs And Queues

That is embarrassing :(, i have not !! thanks @bugsysha

Apr
12
3 months ago
Activity icon

Started a new Conversation Jobs And Queues

I'm trying to send a scheduled job to different queues. I'm using the task scheduler to call that job and put it on a queue:

    protected function schedule(Schedule $schedule)
    {
        $schedule->job(new ProcessMarket(0),'market1')->everyMinute();
        $schedule->job(new ProcessMarket(49),'market2')->everyMinute();
        $schedule->job(new ProcessMarket(99),'market3')->everyMinute();

    }

We are analyzing 150 companies, right now i have the frequency at a minutes but eventually that will be about 30 minutes to 1 hour. My job function is this:

    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    private $start;
    private $offers;
    private $needs;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($start)
    {
        $this->start = $start;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $products = Product::all();

        for ($i = $this->start; $i < $this->start + 50; $i++) {
            foreach ($products as $product) {
                $this->offers = MarketOffer::where('country_id', $i)->where('product_id', $product->id)->orderBy('price', 'asc')->get();
                $this->needs = MarketNeed::where('country_id', $i)->where('product_id', $product->id)->orderBy('price', 'desc')->get();
                if (!$this->offers || !$this->needs) {
                    break;
                }
                $offer = $this->offers->first();
                $needs = $this->needs->first();
                if (Arr::get($offer, 'price') > Arr::get($needs, 'price')) {
                    break;
                }
                $this->processOffers();
            }
        }
    }

The job is processing the test data correctly, but it doesn't seem to be sent to the queue. Looks like it processing it sequentially. My idea of putting them in different queues is to eventually separate the processing into different machines. What i'm doing wrong that the job is not sent to a queue for processing?

Apr
06
3 months ago
Activity icon

Started a new Conversation Github Synchronizing Between Local And Production Sites

I posted this on the github forum but i have not gotten any answers, maybe one of you know the answer. With all the caos going around our company quickly had to branch out to access other markets and to be able to serve the people in our community. In just a few days i created an ecommerce site where we sell produce and groceries directly to the public. Trying to get the site up and running i skipped a few process steps and now i'm not sure if what i have on my local matches with production. I'm using Bagisto as the base (https://bagisto.com/en/) and i have been using this guide to install the site (https://devmarketer.io/learn/deploy-laravel-5-app-lemp-stack-ubuntu-nginx/).

I work from home and the office, when i first push the project i did it from home. So now i'm trying to make sure that my office and production are synced. On the server i created a bare repository (git init --bare) and created a post-receive hook that places the files on the website. my github repository show:

$ git remote show origin
* remote origin
  Fetch URL: https://github.com/dan3460/bagisto.git
  Push  URL: https://github.com/dan3460/bagisto.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

but my production shows:

$ git remote show production
[email protected]'s password: 
* remote production
  Fetch URL: ssh://[email protected]/usr/seashore
  Push  URL: ssh://[email protected]/usr/seashore
  HEAD branch: (unknown)

I know that my home and work computers matches with the github origin, but i don't know how to tell if my production is the same.

Thanks for the help

Mar
28
4 months ago
Activity icon

Replied to VSCode Annoying Problem

ok, but then how do i stop the feature? I work on 3 different computers, in two of them this doesn't happens.

Mar
27
4 months ago
Activity icon

Replied to VSCode Annoying Problem

I have looked everywhere can see anything. I even deleted all the extensions and reinstall vsc, still the same.

Activity icon

Started a new Conversation VSCode Annoying Problem

Maybe is someone there familiar with VSCode. The autocomple puts a "\" before the function or word selected from the drop down. for example you start type fo... then a popup comes with a list of functions and classes that have "fo" on it, you select one (for example fopen) and the result is:

\fopen();

Any ideas?

Mar
20
4 months ago
Activity icon

Replied to How To Add Export Buttons To Yajra/laravel-datatables?

What i normally do add buttons is to use the addColumn function of DataTables, here is a sample that returns a couple of buttons and a link to a picture:

public function getAlbums(Request $request)
{
    $albums = Albums::where('users_id', Auth::user()->id);

    return DataTables::of($albums)
        ->addColumn('actions', function ($albums) {
            return '<a href="/albumsDetail/manageAlbum/' . $albums->id . '" class="btn btn-xs btn-success">' . trans('buttons.Edit') . '</a>' .
                '<form action="/albums/' . $albums->id . '" method="post">' . csrf_field() . ' ' . method_field('DELETE') . '<button type="submit" class="btn btn-xs btn-danger">' . trans('buttons.Delete') . '</button></form>';
        })
        ->addColumn('cover', function ($albums) {
            return '<img src="' . url('storage/' . $albums->cover()) . '" alt="Not Selected" class="img-thumbnail" width=100>';
        })
        ->addColumn('pictures', function ($albums) {
            return $albums->pictures()->count();
        })
        ->addColumn('selectFamily', function ($albums) {
            return $albums->family ? "Yes" : "No";
        })
        ->addColumn('selectPublic', function ($albums) {
            return $albums->public ? "Yes" : "No";
        })
        ->rawColumns(['actions', 'cover'])
        ->make(true);
}
Activity icon

Replied to Moving From L.6 To L.7 And Bootstrap To Tailwind

@ajithlal thanks, i did saw that post and will use it to guide us when we do this thing for real. We probably are more concern about erasing all Bootstrap references from the application before we install Tailwind.

Activity icon

Started a new Conversation Moving From L.6 To L.7 And Bootstrap To Tailwind

I have an application that was developed in Laravel 6 that we are upgrading and moving it to Laravel 7. Among the things that we want to do is to also move from Bootstrap to Tailwind, because we want to have different look. I found a converter for Tailwind called TailWindo that seem to do a pretty good job converting the Bootstrap classes. When the app was created we used the php artisan ui bootstrap --auth, then we run npm run dev to push it in to the app.css file. My questions are:

  • Is there a command to un-scaffold the application?
  • I see the steps to upgrade in the Laravel web site. Do you have any suggestions for this to go smoothly? We did a test run on a copy of the application and it was rough, we dump the test after several tries.

Thanks

Mar
15
4 months ago
Activity icon

Replied to Posting An Issue On Github

@bobbybouwmann Thanks. I'll look at that post.

Activity icon

Started a new Conversation Posting An Issue On Github

I don't know if anyone is familiar with posting issues on GitHub via their API. I'm trying to post issues directly from a web application. I get an OK when performing a GET request. But if i try to POST an new issue giving title and body i get an error message "Problems parsing JSON". I'm using Guzzle to make the requests. This is the first time that i'm tacking this, so i'm probably doing something stupid, also i'm testing so the code is messy . I have this on the constructor of a class that i'm using for this purpose:

public function __construct(Issues $issue)
{
    $this->issue = $issue;
    $this->client = new Client([
        'base_uri' => 'https://api.github.com/'
    ]);
    $this->auth = [
        'auth' => ['XXXXXX', 'XXXXXXXXX'],
        'title' => "Title",
        'body' => "This is the issue"
    ];
}

This is the function that triggers the post:

/**
 * This function posts an issue in GitHub
 *
 * @return void
 */
public function postIssue()
{
    $response = $this->client->request('POST', '/repos/XXXXX/XXXXXX/issues', $this->auth);
    dd($response->getBody());
    return 'Issue posted';
}

Any ideas.

Mar
10
4 months ago
Activity icon

Replied to Adding A Custom Class

wow, thanks for the tips. It was a typo. I have been using PascalCase for a while, i also think it looks better.

Activity icon

Replied to Adding A Custom Class

Thanks Rodrigo. I was confused why the article would say that you needed to add the class to the composer.jason. I have one question, i probably will be creating a couple more classes so i have a directory under App called classes, i'm assuming that this will be correct:

<?php
namespace App\Classes;
class my class {
...
}

Then used as:

<?php
namespace App\Http\Controllers:
use \App\Classes\MyClass;

public function theFunction() {
$myClass = new MyClass;
}
Mar
09
4 months ago
Activity icon

Started a new Conversation Adding A Custom Class

I'm creating a class that will handle the interaction with another site via API calls. I'm using Guzzle to interact with the other site. I look around and could not find much information about this. One of the articles that i found talks about adding the class to composer.json, do i need to do that. Is there something that i need to pay attention so it will work?

Feb
29
5 months ago
Activity icon

Replied to Ubuntu And PHP > 7.1

Don't know, it doesn't feel right. It seems to me that the above command will install a new version of PHP instead of upgrading. I have been running this server for 2 years now, i have upgraded from 6.X to the 7.1 and don't remember having any trouble. I thought this upgrade would have been a 1/2 Saturday morning upgrade, now is turning into an endeavor. I'm afraid of braking the two apps running on the server. Going home and rethink.

Activity icon

Replied to Ubuntu And PHP > 7.1

how would you upgrade to 7.2 or 7.2 afterwards? I have never used homebrew.

Activity icon

Replied to Ubuntu And PHP > 7.1

That is the guide that i followed. Cannot find php 7.2.

Activity icon

Started a new Conversation Ubuntu And PHP > 7.1

I'm trying to confirm a suspicion. I'm running a couple of server on Vultr one of them has Ubuntu 17.10, i see on the site that this version (17.XX) is no longer available. You can still get 16 or 18 or 19. I need to update PHP to more than 7.20 and i'm having a very difficult time, the system keeps telling me that could not find 7.2 (nor 7.3 when i tried to upgrade to that one). I'm suspecting that there is no version better than 7.1 for that flavor of Ubuntu. Is that correct?

Feb
23
5 months ago
Activity icon

Replied to Testing If A Function Within A Model Is True

@sinnbeck That solution did not work for me. I got "Undefined class constant 'share'". If i do Albums::share(), i get "Non-static method App\Albums::share() should not be called statically". The way that i have solved it in the mean time is:

        $familyAlbums = Albums::where('family', true)
            ->whereIn('users_id', AccessGranted::select('users_id_from')->where('users_id_to', Auth::user()->id))
            ->get();

I don't know how taxing is this query on the system when you have a 10,000 or more albums and a couple of hundreds of users.

Feb
22
5 months ago
Activity icon

Started a new Conversation Testing If A Function Within A Model Is True

I'm trying to select albums to view only if there a relation between the user viewing and the user owner of the album. I created a function in the Album model that test the relation:

    public function share()
    {
        $test = AccessGranted::where('users_id_from', $this->users_id)
            ->where('users_id_to', Auth::user()->id)
            ->first();

        return $test ? true : false;
    }

Now i want to pull all the albums where the user has this relation with something like this (there is a test also here if the owner of the album wants to share with it):

        $familyAlbums = Albums::where('family', true)
            ->where(Albums::share(),true)
            ->get();

i'm drawing a blank here. I'm pretty sure that i can do the selection via raw sql.

Feb
19
5 months ago
Activity icon

Started a new Conversation What Extensions On VSCode

My system crash and i'm installing VSC from new. What are the must have extensions you would suggest? I have been using Inteliphense, material icons, laravel 5 snippets, laravel blade snippets. Tips on the setup of any of these or the ones you are suggesting.

Feb
16
5 months ago
Activity icon

Replied to Returning Data From Ajax Request

@sinnbeck thanks for the answer. As you can see i'm not very proficient in jQuery or JavaScript. I do understand that is an async call, but i thought that the .done() waited for the answer to continue. In any case the sample you gave works.

Thanks again.

Activity icon

Started a new Conversation Returning Data From Ajax Request

Originally i had this function:

        $.ajax({
            url: "/albums/getAlbumData",
            data: {
                albumID: albumID,
                dataType: dataType
            }
        })
        .done(function(data){
            $("#infoModalData").text(data));
        });

within a block that was triggered when pressing a button. We are adding more buttons so it makes sense to push the ajax call to a function:

 function getAlbumData(albumID, dataType) {
        $.ajax({
            url: "/albums/getAlbumData",
            data: {
                albumID: albumID,
                dataType: dataType
            }
        })
        .done(function(data){
            console.log(data);
            return(data);
        });

    };

The console.log() shows the correct data but it doesn't return anything to update the DOM. What i'm doing incorrectly.

Feb
15
5 months ago
Activity icon

Replied to Selecting Using Test In Model

@tray2 that looks nice

Activity icon

Replied to Selecting Using Test In Model

@a4ashraf thanks for that. The album model has a function hasmay() shares as the same album can be shared between many users. Don't understand the "hasOne" do you want me to create a function returning the relationship between the Album and the share?

Activity icon

Replied to Selecting Using Test In Model

Thanks @tray2, your answer is pretty much what i have now. I thought that could be a more elegant solution using something like the granted function that i have. Maybe is not such a thing.

Activity icon

Started a new Conversation Selecting Using Test In Model

On a model i have the following:

    public function granted()
    {
        if (Shares::where('albums_id', $this->id)
            ->where('users_id', Auth::user()->id)) {
            return true;
        } else {
            return false;
        }
    }

I'm trying to select albums where granted returns true but I'm blanking on how to do it. I wanted to write something like this:

    public function familyAlbums()
    {
        $albums = Albums::where($this->granted, true)->get();

        return view('albums.browse', compact('albums'));
    }

of course i'm getting an error. Can i do what i want to do?

Feb
11
5 months ago
Activity icon

Replied to Automatically Refresh Content

I don't really nee to update the data base. The user is presented with his/hers cards, with co-worker card, others cards or all or some combination of them. The datatable that i have now pulls the data depending on the selectors on the screen. I want to keep the selectors but present the data on prettier way. I've been meaning to learn Vue. Do you think this is a Vue project?. I started to write some java and stopped as i could not bear the task to do all this in Javascript. Maybe is the only solution.

Activity icon

Started a new Conversation Automatically Refresh Content

I was using DataTables server side to present content depending on the selection of the user. It works great but it looks like a sterile business presentation. So i want to present the same information using a cards (using boostrap here) that have a picture and, links and information in the body on the card. So every time that the user selects something the cards are updated. I know that i can do this using JavaScript and Ajax calls but, do you know if it is something out there that could do what i want?

Feb
08
5 months ago
Activity icon

Replied to Error In Copying A File

It works if i use the public directory.