giovanniciriello

giovanniciriello

Member Since 4 Years Ago

Rome

Experience Points 4,920
Experience Level 1

80 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 29
Lessons
Completed
Best Reply Awards 3
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

14 Jul
1 year ago

giovanniciriello left a reply on How To Use Faker In Seeder?

run php artisan db:seed -vvv to get errors during operation.

giovanniciriello left a reply on Issue With The Model

Does the create() method correctly insert enetity in your database?

giovanniciriello left a reply on Json_decode() Expects Parameter 1 To Be String, Array Given

if $bank['amount'] is already a string or a number, why do you nee json_decode? I would try:

'amount' => $bank['amount']

20 Oct
2 years ago

giovanniciriello left a reply on Undefined Variable: Users Error

Does the query returns any data? Have you tried debugging $users variable before returning view?

19 Oct
2 years ago

giovanniciriello left a reply on [SOLVED] Passing Data From JS To Laravel Controller

You probabily make a mistake when define the route in your js function. Try to remive the initial slash

giovanniciriello left a reply on [SOLVED] Passing Data From JS To Laravel Controller

Show me your js function and your controller

giovanniciriello left a reply on [SOLVED] Passing Data From JS To Laravel Controller

Yes, you Can do it. But you have to define your route in this way

Route::post('url-to-route', '[email protected]');

giovanniciriello left a reply on [SOLVED] Passing Data From JS To Laravel Controller

This happens usually when you call a route with the wrong method with it was defined (POST or GET etc..)

giovanniciriello left a reply on [SOLVED] Passing Data From JS To Laravel Controller

try to insert a

Log::info($request);

in your controller to see if the server function is correctly called and if the request is correctly set

18 Oct
2 years ago

giovanniciriello left a reply on Pivot Table And Syncing

You just have 1,2,3 rows in conditions table and medications table?

giovanniciriello left a reply on Pivot Table And Syncing

Ok. So there's no problem in seed. Please let me see your models

giovanniciriello left a reply on Pivot Table And Syncing

Yes. Simply try to separate creation of Patients and creation of row for pivot tables :)

giovanniciriello left a reply on Pivot Table And Syncing

So do you already have patients in your database! What about this code?

foreach(Patient::all() as $patient){
    $patient->conditions()->sync(array(1, 2, 3));
    $patient->medications()->sync(array(1, 2, 3));
}

giovanniciriello left a reply on Pivot Table And Syncing

Yes. That should be right if you correctly set relations. Any problems now?

giovanniciriello left a reply on Pivot Table And Syncing

The sync method works only on an istance of belongsToMany type relation.

It will not work if you miss the parentheses after 'contitions' or 'medications' when call the sync method

giovanniciriello left a reply on Using Input::get(); From The Table

@bobbybouwmann gave the solution. You could stringify the information you need. For example with a attribute in your tr element like:

data-info="{!! $device->toJson() !!}"

and then, onclick of the link, fetch data in this way:

var info_object = $('selector-to-tr').data('info');

and fill your form :) Let me know if you have some problems with this js function

giovanniciriello left a reply on Pivot Table And Syncing

First of all, I suggest you to use a pivot name like "condition_patient" for laravel conventions. So, you have a conditions table and a patients table. You should define in both models the BelongsToMany relationship instead of BelongsTo relationhsip. This should be helpful for you https://laravel.com/docs/5.2/eloquent-relationships#many-to-many

giovanniciriello left a reply on Laravel Can't Access Resources When Route Like "/orders/list" But Access Them When "route/orderlist"

Please show me the call to your resources in your layout page. The error is there. The best way to do it is with the following code (example for img, css or js):

<img src="{{ URL::asset('img/logo.png') }}" alt="logo"/>

<link href="{{ URL::asset('css/plugins.css') }}" rel="stylesheet" type="text/css"/>

<script src="{{ URL::asset('js/app.js') }}" type="text/javascript"></script>

giovanniciriello left a reply on Populating Lookup Tables

Can you show me your relation functions in your models?

giovanniciriello left a reply on Populating Lookup Tables

But.. have you defined your relation as a ManyToMany relation? Because in this way, yoiu trait your table as a pivot table that respect the DB Laravel convention according to which the name of pivot table must be the concatenation of the singular items names that the relation links

giovanniciriello left a reply on Populating Lookup Tables

Simply, in your CategoryPhoto Model:

class CategoryPhoto extends Model
{
        protected $table = 'category_photo';

    //code
}

giovanniciriello left a reply on Artisan Command On Server

Don't worry if you don't have ssh on your server or hosting! I had the same needs and I simply created a group of route for artisan commands, like these:

//artisan commands
Route::group(['prefix' => 'artisan'], function(){

    Route::get('migrate/{app_key}', 'Admin\[email protected]');
    Route::get('migrateRefresh/{app_key}', 'Admin\[email protected]');
    Route::get('seed/{app_key}', 'Admin\[email protected]');
    Route::get('down/{app_key}', 'Admin\[email protected]');
    Route::get('up/{app_key}', 'Admin\[email protected]');

});

And my ArtisanController will be:

class ArtisanController extends Controller
{

    public function migrate($app_key){
        if($app_key != env('APP_KEY')){
            abort(403);
        }

        try {
            Artisan::call('migrate');
            echo 'Migrated tables';

        } catch (Exception $e) {
            die($e->getMessage());
        }
    }

    public function migrateRefresh($app_key){
        if($app_key != env('APP_KEY')){
            abort(403);
        }

        try {
            Artisan::call('migrate:refresh');
            echo 'Migrate refreshed';

        } catch (Exception $e) {
            die($e->getMessage());
        }
    }

    public function seed($app_key){

        if($app_key != env('APP_KEY')){
            abort(403);
        }

        try {
            set_time_limit(3600);
            Artisan::call('db:seed');
            echo 'Seeded';

        } catch (Exception $e) {
            die($e->getMessage());
        }
    }

    public function down($app_key){

        if($app_key != env('APP_KEY')){
            abort(403);
        }

        try {
            Artisan::call('down');
            echo 'App is now in Maintenance Mode';

        } catch (Exception $e) {
            die($e->getMessage());
        }
    }

    public function up($app_key){

        if($app_key != env('APP_KEY')){
            abort(403);
        }

        try {
            Artisan::call('up');
            echo 'App is no more in Maintenance Mode';
        } catch (Exception $e) {
            die($e->getMessage());
        }
    }
}

Of course I use the .env APP_KEY as "password" to access to these special commands callable in this way:

your-path-app/artisan/migrate/[APP_KEY]
17 Oct
2 years ago

giovanniciriello left a reply on Database Question: Best Database Design For My App

I suggest a DB structure like this:

users table

| id | name | contract_number| contract_type_id (nullable) | custom_contract_type|

The foreign key contract_type_id will be keep empty (null) if the custom contract type will be a string

contract_types table (static)

|id| name|description|

|1|First generation| Lorem impsum..|

|2|Second generation| Lorem impsum..|

phases table (static)

|id| name|description|

|1|mgmt| Lorem impsum..|

|2|control| Lorem impsum..|

|2|planning| Lorem impsum..|

There is a many to many relationships between users and Phases. So we need a pivot table: user_phase table

|user_id| phase_id|custom_phase|

That's enough to have a complete and good designed structure for your situation

14 Oct
2 years ago

giovanniciriello left a reply on Mail AttachData Of PDF Breaks Html Styling

There is a syntax error. Write

$pdf = PDF::loadView('pdf.invoice', ['invoice' => $invoice]);

instead of

$pdf = PDF::loadView('pdf.invoice', ['invoice' => $invoice)]);

giovanniciriello left a reply on Rename .env.example File To .env

Move it on you server with Filezilla or another FTP program. Rename file, and re-download it on your computer...

giovanniciriello left a reply on Get Data On Multiple Tables Grouped By Hours

Maybe I couldn't understand exactly your needs, but try in this way:

$query = $visits
                ->select(DB::raw('count(id) as `visits`'),DB::raw('HOUR(created_at) hour'))
                ->union($clicks->select(DB::raw('count(id) as `clicks`'),DB::raw('HOUR(created_at) hour')))
                ->union($sales->select(DB::raw('count(id) as `sales`'),DB::raw('HOUR(created_at) hour')))
                ->groupby('hour')
                ->orderBy('hour')
                ->get()
        ->groupBy('hour')
        ->transform(function($item, $key){
            return $item->collapse();
        });

But at this point I advice you to use first solution in this discussion :)

giovanniciriello left a reply on How To Set A HasMany Relation Between 3 Tables?

It seems that the solution is make a custom method in your model, in which you define the complete relationship. What is an example of query you wish execute?

giovanniciriello left a reply on Get Data On Multiple Tables Grouped By Hours

It would be like something like this in a raw query:

(SELECT count(id) as `visits`, created_at as `date` FROM visits)
UNION
(SELECT count(id) as `clicks`, created_at as `date` FROM clicks)
UNION
(SELECT count(id) as `sales`, created_at as `date` FROM sales)
ORDER BY date DESC;

Of course it' would easly written using the power of laravel query builder and union method :)

giovanniciriello left a reply on Get Data On Multiple Tables Grouped By Hours

You can obviously make a more complex query (with union syntax). And that's of course more performant then three queries and union with collection method "merge".

giovanniciriello left a reply on Get Data On Multiple Tables Grouped By Hours

You just got 3 separeted collections. So if you merge these with

$merged = $user->merge($clicks);
$merged = $merged->merge($sales);

You can without problems order them by hour with:

$merged = $merged->sortBy('hour');

You should use the whole date for a correct sorting of items, and show only hour if you want. (At this time, it's useless you order items in your query, you already do it in your merged collection).

giovanniciriello left a reply on Eloquent Relationship Chaining Problem

Please post your model relationships

giovanniciriello left a reply on Heart Of The Date Format

I really advice you to use Carbon PHP library. It is included into Eloquent, you have just to define the date (or datetime, or time) field in your database in your model class:

class Order extends Model
{

    protected $dates = [
        'date',
        'created_at',
        'updated_at'
    ];
/**/

}

In this way you will directly get from your queries a object of Carbon Class, and so:

$order->date->toDateTimeString(); //2016-10-14 12:17:51

And make it easy :)

giovanniciriello left a reply on Laravel Error With No Back Trace In Debug Mode

make sure you didn't delete or changed name to .env file.

Anyway I got this problem when there are more of the same requests in a few milliseconds (for example if a press f5 to reload page more times). But this only in local environment. It shouldn't appear if you're on a real server in production.

13 Oct
2 years ago

giovanniciriello left a reply on Custom Error Pages With Message And Code

Hi @willvincent and thanks a lot for your userful answer. What are in your opinion the usefulness of Graham Campbell's package that should make me choose this last one instead of "resuscitate" laravel 4 whoops?

giovanniciriello left a reply on Custom Error Pages With Message And Code

That's really a bad new......

giovanniciriello started a new conversation Custom Error Pages With Message And Code

Hello everyone, As we already know, Laravel provides an error page in which the code and the file of errors are shown. Somethings like this: https://s13.postimg.org/k88y54qwn/Cattuqra.png.

In the most of laracasts tutorial I saw a clearer and more precise page error. I have captured screen and that's the image: https://s16.postimg.org/7beqyhuid/Cattura.png.

Does anyone an idea of how can I get this type of errors? Is it a external package?

02 Dec
3 years ago

giovanniciriello started a new conversation .

30 Nov
3 years ago

giovanniciriello started a new conversation Role System With Middleware

Hi everybody. I'm new with Laravel, and i'm developing a web app with different type of users. In this web app a User has a level numeric field in his table. I want to permit some operation, some Controller-Methods access in base of his level (e.g. if the level is bigger then x) Should I use middleware? How could I do it in the cleanest and correct way possible? Thank u

08 Sep
4 years ago
07 Sep
4 years ago

giovanniciriello left a reply on [$request->get('name')], [$request->input('name')] Or [$request->name] ?

ok, right. But differences between get and input method. Are there?

giovanniciriello started a new conversation [$request->get('name')], [$request->input('name')] Or [$request->name] ?

Hi. The three solution perfectly works. But the documentation is not totally clear about. Which are the differences and what's the best way to get a variable from request?

public function(Request $request){

    $request->get('name');  //Josh
    $request->input('name'); //Josh
    $request->name; //Josh

}
06 Sep
4 years ago

giovanniciriello left a reply on Mail Functions Cannot Recognize Request Variables

Yes. I've just solved in this way. Do you know the reason?

giovanniciriello started a new conversation Mail Functions Cannot Recognize Request Variables

Hi, i've this simple method of MyController :

public function send(Request $r){

    Mail::raw('content of mail', function ($m) {
        $m->to($r->email);
    });

}

The error is that: 'Undefined variable: r' That's very strange: if I log the variable $r->email, it correctly show me the variable; If I substitute $r->email with a simple string, mail perfectly works! Help me

05 Sep
4 years ago

giovanniciriello left a reply on "Not Allowed To Load Local Resource" Showing Images In 'storage' Folder

Thank u. I've just moved my gallery folder into public.

giovanniciriello started a new conversation "Not Allowed To Load Local Resource" Showing Images In 'storage' Folder

Hi. I have to show static images that are placed in storage/app/gallery. But i really can't anyway get a correct url for this image. Trying with: {{ public_path().'/laravel/storage/app/gallery/'.$fileName }} or {{ public_path('/laravel/storage/app/gallery/'.$fileName) }} it appear this strange error: Not allowed to load local resource: file:///C:/xampp/htdocs/........... I'm using xampp on windows, help me