marymvlg28

marymvlg28

Member Since 3 Years Ago

Experience Points 670
Experience Level 1

4,330 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 0
Lessons
Completed
Best Reply Awards 0
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.

23 May
1 year ago

marymvlg28 left a reply on Maintain User Authentication Through Subdomains

I just made a test with:

  • test1.example.com (http)
  • test2.example.com (http)

And just doing this:

'domain' => '.example.com',

It worked!

But... I don't know why it did not work with:

  • example.com.ve (https)
  • test.example.com.ve (http)

I don't if the problem is about the protocols or that I'm working with a domain and subdomain

Any ideas ?

22 May
1 year ago

marymvlg28 started a new conversation Mantein User Authentication Through Subdamains

Hi, I'm using Laravel 5.1, php7.0 and apanche2.

I have the same project twice in different subdomains.

  • example.com.ve
  • test.example.com.ve

If a User has logged in example.com.ve, and then go to the link test.example.com.ve, the test.example.com.ve site asks for the user to be logged in. I need somehow the same session working in the second domain, so the test site does not ask for user authentication.

I already tried editing the file config/session.php, and clearing browser cookies and cache

'domain' => '.example.com.ve',

First only in example.com.ve, and then in both sites example.com.ve and test.example.com.ve, but it did not work...

I took a look at this https://serverfault.com/questions/62868/apache-htaccess-trick-to-authenticate-only-once-for-all-subdomains

But I don't know what this file is: AuthUserFile /etc/apache2/.htpasswd-digest

Any suggestions?

26 Jul
1 year ago

marymvlg28 started a new conversation Eloquent And Unions

Hi,

I'm using Laravel 5.1

It is possible to construct this query with eloquent ORM?

SELECT 
SUM(CASE WHEN movement_type_id = 1 THEN 1 ELSE 0 END) as credit, 
SUM(CASE WHEN movement_type_id = 2 THEN 1 ELSE 0 END) as debit 

FROM (

SELECT id, user_id, movement_type_id, amount, description
FROM "movements" 

UNION

SELECT id, user_id, movement_type_id, amount, description
FROM "ticket_movements" ) as movements

WHERE "movements"."user_id" = 2 
AND "movements"."movement_type_id" in (1, 2)

If I do this:

$movements = $this->hasMany('App\Model\Movement')
    ->select(\DB::raw("
                id,
                user_id,
                movement_type_id,
                amount
            "));

$tickets_movements = $this->hasMany('App\Model\TicketMovement')
    ->select(\DB::raw("
                id,
                user_id,
                movement_type_id,
                amount
            "));

$result = $movements->union($tickets_movements->getQuery())
    ->whereIn('movement_type_id', [1, 2])
        ->select(\DB::raw('
                SUM(CASE WHEN movement_type_id = 1 THEN 1 ELSE 0 END) as credit,
                SUM(CASE WHEN movement_type_id = 2 THEN 1 ELSE 0 END) as debit
        '))
        ->first();

What I get is:

SELECT 
SUM(CASE WHEN movement_type_id = 1 THEN 1 ELSE 0 END) as credit, SUM(CASE WHEN movement_type_id = 2 THEN 1 ELSE 0 END) as debit 
FROM "movements" 
WHERE "movements"."user_id" = 2 
AND "movements"."user_id" is not null 
AND "movement_type_id" in (1, 2)

UNION

SELECT id, user_id, movement_type_id, amount, description
FROM "ticket_movements" 
WHERE "ticket_movements"."user_id" = 2 
AND "ticket_movements"."user_id" is not null limit 1

That is not what I need and besides I get this error:

Syntax error: 7 ERROR: each UNION query must have the same number of columns LINE 5: id

Can anybody help me?

marymvlg28 left a reply on Define A Relationship As A Union

I'll try to explain better:

In several parts of my code I have for example these:

$user->movements()->get();
...
$user->movements()->where(...)->get();
...
$user->movements()->where(...)->select(... sum, count, avg ...)->get();
...

But now I'm facing an important chance on the movements table structure. Now I need two tables with a similar structure (the data HAVE to be in separate tables), movements and ticket_movements.

These tables are consulted by two system, one of then needs the data to be separated and the other needs the data to be as in one table.

So, in one of the systems, I would like to define the relationship movements() as an union of movements and ticket_movements tables.

So, if I do this:

$user->movements()
    ->whereIn('movement_type_id', [1, 2])
        ->select(\DB::raw('
                SUM(CASE WHEN movement_type_id = 1 THEN 1 ELSE 0 END) as credit,
                SUM(CASE WHEN movement_type_id = 2 THEN 1 ELSE 0 END) as debit
        '))
        ->first();

The query I get is:

SELECT SUM(CASE WHEN movement_type_id = 1 THEN 1 ELSE 0 END) as credit, SUM(CASE WHEN movement_type_id = 2 THEN 1 ELSE 0 END) as debit FROM "movements" WHERE "movements"."user_id" = 2 AND "movements"."user_id" is not null AND "movement_type_id" in (1, 2)

UNION

SELECT id, user_id, movement_type_id, amount, description FROM "ticket_movements" WHERE "ticket_movements"."user_id" = 2 AND "ticket_movements"."user_id" is not null limit 1

Besides it's not the query I need, it give me an error because of the columns.

The query I need is something like this:

SELECT SUM(CASE WHEN movement_type_id = 1 THEN 1 ELSE 0 END) as credit, SUM(CASE WHEN movement_type_id = 2 THEN 1 ELSE 0 END) as debit

FROM (

SELECT id, user_id, movement_type_id, amount, description FROM "movements"

UNION

SELECT id, user_id, movement_type_id, amount, description FROM "ticket_movements" ) as movements

WHERE "movements"."user_id" = 2 AND "movements"."movement_type_id" in (1, 2)

Without modifying each line where I do $user->movements()...

I don't know is that is possible...

25 Jul
1 year ago

marymvlg28 left a reply on Define A Relationship As A Union

The problem is I need to define the union in the relationship and use the ORM. Modify every query would be the last option.

24 Jul
1 year ago

marymvlg28 left a reply on Bulk Update

I found the Codeigniter code and I did that way. It constructs an update query as a query raw where I can update several rows indicating the row id and the column-value to be updated.

marymvlg28 left a reply on Update Get Id

I was trying to update several rows at the same time, and get the id for each updated row, but I could not find an automatic solution for that. I just find another way to do the process.

marymvlg28 started a new conversation Define A Relationship As A Union

Hi,

I would like to know if there is a way to define a relationship as a union of two tables?

I've already tried this:

public function movements()
{
        $movements = $this->hasMany('App\Model\Movement')
            ->select(\DB::raw("
                id,
                user_id,
                movement_type_id,
                amount
            "));

        $tickets_movements = $this->hasMany('App\Model\TicketMovement')
            ->select(\DB::raw("
                id,
                user_id,
                movement_type_id,
                amount
            "));

        return $movements->union($tickets_movements->getQuery());
    }

The problem is when I try this:

$user->movements()
    ->whereIn('movement_type_id', [1, 2])
        ->select(\DB::raw('
                SUM(CASE WHEN movement_type_id = 1 THEN 1 ELSE 0 END) as credit,
                SUM(CASE WHEN movement_type_id = 2 THEN 1 ELSE 0 END) as debit
        '))
        ->first();

It shows an error:

Syntax error: 7 ERROR: each UNION query must have the same number of columns LINE 5: id

SQL: select SUM(CASE WHEN movement_type_id = 1 THEN 1 ELSE 0 END) as credit, SUM(CASE WHEN movement_type_id = 2 THEN 1 ELSE 0 END) as debit from "movements" where "movements"."user_id" = 2 and "movements"."user_id" is not null and "movement_type_id" in (1, 2)

union

select id, user_id, movement_type_id, amount, description

from "ticket_movements" where "ticket_movements"."user_id" = 2 and "ticket_movements"."user_id" is not null limit

I see the problem is not the number of columns, the problem is the union is not what I need, the relation movement should be a union between movements and ticket_movements and then perform the other part of the query (select sum, where, ...)

03 Nov
2 years ago

marymvlg28 started a new conversation Laravel .htaccess File

Hi, This laravel default .htaccess file:

<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 ^(.*)/$ /$1 [L,R=301]

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

I'm trying to deny for all and allow access by ip, adding this line at the beginning:

order deny,allow deny from all allow from

by it does not work

Can't anybody help me please?

20 Jul
3 years ago

marymvlg28 started a new conversation Extend Validator

Hi I'm using Laravel 5.1.40 (LTS) I'm need to extend laravel validator class, but it shows this error: Method [validateFoo] does not exist.

In App/Providers:

namespace App\Providers; use Validator; use App\Support\Validator\CustomValidator; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { public function boot() { //Custom validator Resolver Validator::resolver(function($translator, $data, $rules, $messages) { return new CustomValidator($translator, $data, $rules, $messages); }); } public function register() { // }

In config/App.php:

'providers' => [

... App\Providers\AppServiceProvider::class, ...

In App/Support/Validator:

namespace App\Support\Validator; use Illuminate\Http\Request; use \Illuminate\Validation\Validator; class CustomValidator extends Validator { public function validateFoo($attribute, $value, $parameters, $validator){ dd('Here'); } }

In my controller:

namespace App\Http\Controllers\User; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller;

class UserController extends Controller { public function postFoo(Request $request) { //Rules $rules = array( 'field' => 'required|Foo', );

    //Validator
    $this->validate($request, $rules);

dd('Awesome');

}

I get this error: Method [validateFoo] does not exist. Please help. I tried Validator::extend('Foo', function(... and that worked but I would like to use my customValidator class

28 Jan
3 years ago

marymvlg28 left a reply on Bulk Update

Postgresql allows it. Codeigniter has or use to have a way, It concatenate every update statements with semicolons, and then submit the statements in one shot.

marymvlg28 left a reply on Bulk Update

Sorry @kfirba you're right. But still, executing one update would be faster that 1000.

marymvlg28 left a reply on Bulk Update

If I had 1000 rows to update, I would have to do 1000 connections to the database, and that is just what I want to avoid, Codeigniter has a way to update multiple data in a single connection, which is much faster. I need to know if there is a way to do that in Laravel.

marymvlg28 left a reply on Bulk Update

But I'm looking for a way to do one update in batch.

marymvlg28 started a new conversation Bulk Update

Hi,

I'm wondering if there is a way to execute a bulk update like this:

$data = [ ["id" => 20, "status_id" => 1], ["id" => 21, "status_id" => 2], ["id" => 23, "status_id" => 3] ];

MyModel::update($data);

Where id = 20 set status_id = 1... and so on...

28 Dec
3 years ago

marymvlg28 left a reply on Modify Request Input Value Before Validation

Thank u! It did work!

    public function getValidatorInstance()
    {
        $this->cleanPhoneNumber();
        return parent::getValidatorInstance();
    }

    protected function cleanPhoneNumber()
    {
        if($this->request->has('phone_number')){
            $this->merge([
                'phone_number' => str_replace(['-','_',''], '', $this->request->get('phone_number'))
            ]);
        }
    }

marymvlg28 started a new conversation Modify Request Input Value Before Validation

Hi,

I have a form with a phone input.

This input has an input mask like this 9999-999 9999

I'm using form request validation (App\Http\Requests\UserRequest.php)

I would like to validate the phone number should have 11 digits (digits:11)

I have tried $this->replace(['phone_number' => str_replace(...)]) and $this->merge(['phone_number' => str_replace(...)])

  • I know $this->replace will replace all request inputs

But none of those seems to work. Validation rule still take the original input.

can anybody help me?

25 Nov
3 years ago

marymvlg28 left a reply on Update Get Id

jlrdw I don't understand. What do u mean?

24 Nov
3 years ago

marymvlg28 started a new conversation Update Get Id

hi,

I wonder if there is a way to get the ids of the rows that have been updated.

Example:

\DB:('table')->where(...)->where(...)->updateGetId([...]);

marymvlg28 started a new conversation Update Field With Another Field

Hi,

I would like to know if is possible to set a field value with another filed value in one update?

Something like this for example:

\DB::('table1') ->join('table2', 'table1.id', '=', 'table2.id') ->update(['table1.field_a' => 'table2.filed_x']);

20 Nov
3 years ago

marymvlg28 started a new conversation Call To Undefined Method Symfony\Component\HttpFoundation\ParameterBag::route()

Hi,

I'm validating my forms through "form request validation".

According to the manual, I should be able to use the route() method: http://laravel.com/api/5.1/Illuminate/Foundation/Http/FormRequest.html#method_route

But in my EditFormRequest.php, inside rules() function, if I call $this->request->route() a get this error:

Call to undefined method Symfony\Component\HttpFoundation\ParameterBag::route()

Can anybody help me?