Abi

Abi

Member Since 2 Years Ago

Experience Points 87,540
Experience Level 18

2,460 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 724
Lessons
Completed
Best Reply Awards 22
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

01 Oct
7 months ago

Abi left a reply on Upgrade To Laravel 5.7 Problem Consuming Own API With Passport

There was a change to the cookie in laravel 5.6.30, this might be the problem

https://laravel.com/docs/5.6/upgrade

You might have to protected static $serialize = true; to the EncryptCookies middleware

30 Sep
7 months ago

Abi left a reply on Scopes - Good Practice

@Cronix yeah, I know about whereBetween but I want the query to be passed as date(`date`) <= '2017-12-31' and still the example answers the question about scopes.

Abi left a reply on Scopes - Good Practice

Scopes are mostly use to append actions to your queries. for instance one scope that i always create is a date range. it looks something like

    public function scopeInDateRange($query, $startDate, $endDate, $field = 'created_at')
    {
        return $query->whereDate($field, '<=', $endDate)
                ->whereDate($field, '>=', $startDate);
    }

then add it to a trait so all my models have access to it.

02 Sep
8 months ago

Abi left a reply on How To Make A Query To Filter With A Pivot Table & Another Table In Laravel 5?

Photo::whereHas('album', function ($query) {} use ($albumID){
    $query->where('id', $albumID)

})->whereNull('processed')->get();

30 Aug
8 months ago

Abi left a reply on My [email protected] Doesnt Recognise My Post Model

Your post namespace might be wrong use namespace\Post

Abi left a reply on If Exists: Update, Else: Insert In Laravel 5.5

@jec360 I see, try something like

Process::select(DB::raw('DATE_FORMAT(created_at, "%m") AS date, proccess.id '))
->where('bag_id', $request->input('bag_id'))->groupBy('date' , 'id')->having('date', date('m'))->first();

Abi left a reply on Form Handling With A OneToMany Relationship

@queu if it is in the same form, it should already be in the request.

do a dd($request->all()) and double check.

if it is in the request

    $institution = $request->all();
        $institution = MedicalInstitution::create($institution);
        $institution->locations()->create( $request->all());

    // or if you want to be specific

        $institution->locations()->create([
        'street' => $request->street,
        // etc
    ]);


Abi left a reply on If Exists: Update, Else: Insert In Laravel 5.5

It might be your query as you're comparing string here. the created_at section is time stamp format and you're sending the month number to it.

27 Aug
8 months ago

Abi left a reply on One-to-One Relationships

you're doing new Post. this means that this is a new instance of the post model meaning that it will not have any related details.

you're not fetching from the database, you're creating a new instance of it

Abi left a reply on One-to-One Relationships

its because your method naming laravel might be looking for a details_id not post_details_id so in this case you need to be specific on which are the related columns.


class Post {


    public function details(){
        return hasOne(PostDetails::class, 'post_id', 'id');
    }
    

}


class PostDetails {


    public function posts(){
        return belongsTo(Post::class);
    }
    

}

//open

 php artisan tinker


Post::find(1)->details



Abi left a reply on Validation Checking For Input Exist In An Array

oh i see.

so you need to do something like.

'{array name}.key' => ['validation']

Abi left a reply on One-to-One Relationships

Lets put it this way.

Your post details table is holding the post_id column that means that you should be using belongsTo(Post::class) and Post model should use hasOne(PostDetail::Class)

Abi left a reply on Eloquent: Relationships HasMany Gets Only One Column

hmm I see, sooo your tables are something like

Hubs:

hub_id:
title
etc
-------
Devices:
device_id: ??
title
hub_id
etc

???

Abi left a reply on Validation Checking For Input Exist In An Array

use Illuminate\Validation\Rule;


Rule::in(['daily', 'weekly', 'monthly' ,'yearly'])

Abi left a reply on Problem With A Foreign Key

if you add the code into the same migration file, this would never run as it has already been migrated.

you need to add the code into a different migration file for it to run.

Abi left a reply on Many To Many In RestFUL API

Maybe a UserGroupController with only two methods store and delete

I don't think you should attach the user to user_groups table if they haven't accepted the invitation as this means that you need to always check the status of that relationship. Just add it when the invitation is accepted.

Abi left a reply on Eloquent: Relationships HasMany Gets Only One Column

@petritr

I don't think you're providing the right keys.

I don't think you have a hub_id in the hubs table?

$this->hasMany('App\Hub', 'foreign_key', 'local_key');

Abi left a reply on Form Handling With A OneToMany Relationship

do you mean you want to store them at the same time? basically send the information in the same form?

if that is the case you can do something like

$institution = MedicalInstitution::create($institution);


$institution->location->create([
    'street' => 'bla'
 ]);

and maybe a different end point to add more locations? or if you're sending multiple locations, just loop when creating the locations.

21 Aug
9 months ago

Abi left a reply on Create And Update In Two Different Tables On Form Submit

@myjosephine I believe you're sending the string [1,4]. if you want to send an array you need to add <input name="related_recipes[]" value="">

18 Aug
9 months ago

Abi left a reply on Getting Monthly Price Sum From Specific Year

@Stank0V01 you just need join your product table and sum the product_price.

Abi left a reply on How To Update Table In Controller Using A Relationship?

try something like


$recipe->ingredients()->update([
    'unit' => 'new unit ',
'quantity' => 'quantity ',
'column' => 'new value ',
]);

Abi left a reply on Getting Monthly Price Sum From Specific Year

@Cronix yeah of course, i skipped all the wheres as it he already knows it. :)

Abi left a reply on Getting Monthly Price Sum From Specific Year

you have a couple of options here, you can get the data and then transform it in the php side or just transform the data within the database.

you need to group by the created_at, for this you need to use format the date as created_at has the time and then you need to sum revenue.

here an example of how you would do it in the db.


Order::select(DB::raw('DATE_FORMAT(order.created_at, "%Y-%m-%d") AS created_at, Sum(order.`price`) AS price'))
            ->groupBy(DB::raw('DATE_FORMAT(order.created_at, "%Y-%m-%d")'))
            ->get();


make sure that if you use DB::raw you are not using variables that a user can manipulate

11 Aug
9 months ago

Abi left a reply on Vue Post To Api And Catch Request With Controller

The reason you cannot access players like $request->players its becase you're not sending a specific players attribute.

if you do a dd($request->all()) you will see the actual structure of what you're sending.

if you want to send a specific players attr. try something like this

 axios.post(url, {
    players : this.players
}).then

21 Feb
1 year ago

Abi left a reply on Polymorphic Relation Trought Id

If you don't want to change the database structure, you can probably just hack it around when you return the relationship. for example

public function products ($class){
    
    return belogsTo($class);
}

15 Sep
1 year ago

Abi left a reply on Use Bolean In Computed

it is always good to separate components, it makes the everything more readable and provides components with their own housing and that but it all comes to you as it is your application. if you think creating a child component for the list item its not worth it just create methods and pass the data you want to transform.

just like @sutherland said a simple publish method would do fine for what you want to do.

Abi left a reply on Use Bolean In Computed

I don't think you can use a computer property within a loop as computed properties are bind to the component itself.

it would be better to use a method or even better create a child component and transfer the data.

Abi left a reply on Use Bolean In Computed

Oh ok , Ill take a look at it

Abi left a reply on Use Bolean In Computed

it is important , an integer is not the same as a string.

with angular I did have to force it to be a boolean because the database was returning a string.

can i see the you full component?

Abi left a reply on Use Bolean In Computed

check that it is returned as a boolean if its not, force it to be a boolean.

go to the model and set the attribute as boolean

    public function get{{name of field}}Attribute($value)
    {
        return (bool) $value;
    }

Abi left a reply on Use Bolean In Computed

you need to output the computed property thingy as it is the one holding the value

11 Apr
2 years ago

Abi started a new conversation Coupons For Laravel Spark??

Do you guys know if these coupons are real?

https://www.couponbirds.com/u/laravel

08 Apr
2 years ago

Abi left a reply on Vue Component And Infinite Scroll

@Armata You might need the initialise the vue instance on the page you're connecting to or do the ajax call from the vue component itself.

Abi left a reply on Access Parent Component Data From The Nested Child Component

@mkdesign82

'''this.$parent''' will access the parent. ''' root element first element //this.$parent will access root element second element //this.$parent will access first element third element //this.$parent will access second element

// if you want to access the root element from the third or second element use this.$root '''

04 Apr
2 years ago

Abi left a reply on Best Practice For Multiple Vue Wrappers

why do you need so many vue instances? you can have one instance with different components and maybe you can add a second one for events but other than that you don't need that many.

something like

Vue.component('example', require('./components/Example.vue'));
//**** Content Loader ****//
Vue.component('app-content-loader', require('./components/ContentLoader/ContentLoader.vue'));

//**** User ****//

Vue.component('app-user', require('./components/User/User.vue'));
Vue.component('app-user-list', require('./components/User/UserList.vue'));


//**** Post ****//
Vue.component('app-post', require('./components/Post/Post.vue'));
Vue.component('app-post-list', require('./components/Post/PostList.vue'));


window.Event = new Vue();

window.vm = new Vue({
    el: '#app',
    data : {
        ContentLoaderConfig : {
            RequestType: 'GET',
            AutoLoadContent: true,
            LoadBtnText : "Load More",
            Url: 'load'

        }
    }

});



Abi left a reply on Hosting Godaddy.com Not Support Laravel 5.4

digital ocean/linode are good and cheap

03 Apr
2 years ago

Abi left a reply on Access Parent Component Data From The Nested Child Component

try something like

this.$parent.data //data that you want to access

01 Apr
2 years ago

Abi left a reply on Vue Component And Infinite Scroll

can you show your code?

30 Mar
2 years ago

Abi left a reply on Axios - Get Datas From Database Using Axios In Vuejs In Laravel

it does not have to be /user, it is just an example url. you can hit any url that you have available in your routes.

Abi left a reply on Axios - Get Datas From Database Using Axios In Vuejs In Laravel

// Make a request for a user with a given ID
axios.get('/user?ID=12345')
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

// Optionally the request above could also be done as
axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });




https://github.com/mzabriskie/axios look at the documentation

29 Mar
2 years ago

Abi left a reply on How To Pass A PHP Variable Into A Laravel Helper

try

{{ url('/products',[$tag]) }}

Abi left a reply on Two Parameters Via A Link

@Acidust I'm glad it helped. you can send as many params in the array just make sure you accept them in the controller and route, in my example I put everything inline so you could test it really quickly.

Remember that once you set it in the route, the params will be required but if for some reason you don't always need a param you can always set it like so

Route::get('test/{id}/{test?}', function ($id,$test = null){
    
    ///this should be extracted to a controller
    return $id . '   '.$test;
})->name('test');

by adding the ? the param will become optional but remember to set a default value for it.

Abi left a reply on Initializing VueJS App With Spinner

where and when are you fetching the data? can you share your code?

Abi left a reply on How To Use Offset And Limit In Laravel Query?

try

Trip::take(4)->skip(3)->get();

Abi left a reply on InnerHTML Compilation ( Vue 2 )

@IgorBabko You need to pass the object to the child component.

Look at the vue-content-loader that I built , It may give you a few ideas.

https://github.com/abisalazar1/Laravel-Vue-Content-Loader

Abi left a reply on InnerHTML Compilation ( Vue 2 )

that is the right way, just placing the component inside the parent

<template>
    <div>
        <app-user v-for="user in ProcessData.data" :user="user"></app-user>
        <app-content-loader ContentType="User" ></app-content-loader>
    </div>
</template>

<script>

    export default{
        data : function () {
            return{
                ProcessData : [],
            }
        }
    }
</script>



Abi left a reply on Two Parameters Via A Link

mate you have to accept it in your controller as well.

Route::get('test/{id}/{test}', function ($id,$test){

    return $id . '   '.$test;
})->name('test');


 <a href="{{ route('test',['a', 'e']) }}">test</a>