al0mie

al0mie

Member Since 1 Year Ago

Experience Points 10,490
Experience Level 3

4,510 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 18
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.

21 May
1 year ago

al0mie left a reply on Asking About Basic Js Module Syntax In Vue

It's same. But the only reasons to quote object keys are:

  • you have special characters or white spaces in your key.
  • the property name is reserved/used by the browser/js engine

so text-danger has a special character (dash), and active not.

al0mie left a reply on Run Config Clear On Browser

you can do it manual or try to use a command like

Artisan::call('config:clear');
19 May
1 year ago

al0mie left a reply on Accessing Elements In Vue Component

Can you past the whole component? But it's seems you want to get data, before your component is actually mounted. It usually works for me.

mounted() {
    console.log(document.querySelector(".grid"));
    console.log(document.getElementById("grid"));
    console.log(this.$refs.grid);
},
18 May
1 year ago

al0mie left a reply on L5.4 How To Handle NotFoundHttpException?

The best way it's go to app/Exceptions/Handler and set required actions in handler method. That will apply to all pages in your app. Example

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

public function render($request, Exception $exception)
{
    if ($exception instanceof NotFoundHttpException){
        return response('Resource not found', 404);
    }
        return parent::render($request, $exception);
    }

al0mie left a reply on Vue Axios Refresh

setInterval(function(){ axios.get('/bids-check').then(response => this.bids = response.data); }, 30000);

17 May
1 year ago

al0mie left a reply on Accounts Are Auto-Activating Themselves?

try to debug this method

 $user = User::whereActivationToken($token)->whereId($id)->first();

I am not sure, but it's possible that search by a token is not working and you just return user by id.

al0mie left a reply on Code Inside Event Listener Not Working

check that you correctly bind event and listener in EventServiceProvider and override postRegister method

al0mie left a reply on How To Use Merg Collection In View?

you can try

$exammarks1 = collect($exammarks); 
$testmarks1 = collect($testmarks); 

it just merge two collections, but not arrays

al0mie left a reply on Strange Things In Session Folder

Maybe the sessions just ran out of time?

al0mie left a reply on Laravel Edit Product, Set Correct Selected (with Many-to-many)

try to check it like

php <option value="{{ $shop->id }}" @if($product->shop->contains($shop->id)) selected @endif>{{ $shop->description }}</option>

al0mie left a reply on What Is The Better Way To Update The Structure Database

you just need to create a new migration and define there what you need, because laravel will not run already migrated migrations. After that you need to execute php artisan migrate, which will not drop existing database tables. In addition, updating existing migration, it's not recommended, because migrartions it's version control system for your db.

al0mie left a reply on Another Way To Set Custom Error Messages Using FormRequest

@devEs

you can write something like

public function store(MyCustomRequest $request)
{
    $this->validate( $request, $rules, $request->messages());
}

so in first there will be validation defined in MyCustomRequest

```php
  /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required'
        ];
    }

which will use your override messages there.

    public function messages()
    {
        return ['required' => 'My custom error'];
    }

after that you can call in the controller another validation, which not depends from what you write in request class, but you can get it manual and do it like $request->messages() or $request->rules(), wich allow you not duplicate your code. So if you just write $this->validate( $request, $rules); it will not automatically get data defined in request class (it will absolutely another validation).

In your case I don't think that you need use $this->validate, so you just can use different request, with different validation and custom messages.

16 May
1 year ago

al0mie left a reply on Another Way To Set Custom Error Messages Using FormRequest

you can override your messages in FormRequest and after do it like

public function messages()
{
    return [
        'title.required' => 'A title is required',
        'body.required'  => 'A message is required',
    ];
}

$this->validate( $request, $rules, $request->messages());

But before this happens, there will be validation defined in the request class

al0mie left a reply on Model __construct Overwrite

check if all that params defined in the model like

private $dFormat;

otherwise it all must be defined in db

al0mie left a reply on Request Data Missing When Using Custom Request Object

Lumen doesn't has support custom requests like laravel, so when happen autowiring, it instanced just empty object, if it has't filled before. But you can create something similiar to laravel with FormRequest https://github.com/laravel/framework/blob/5.4/src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php So you just need to copy data from actual request to extended request.

15 May
1 year ago

al0mie left a reply on How To Trigger A Form Submission From A Modal?

but if you want to submit the form you can bind it with ref and call from $refs Example

 <form role="form" method="post" ref="myForm">
            <div class="form-group">
                <label>Event name:</label>
                <input class="form-control" name="nameEvent" v-model="nameEvent">
            </div>
      </form>

and after

saveAction() {
     this.$refs.myForm.submit();
}

but using ajax seems is preferable

al0mie left a reply on FatalThrowableError Class ' ' Not Found

try composer dump-autoload and clear app cache

al0mie left a reply on Localization Faker\Factory Does Not Work In Laravel

Try

$this->app->singleton(\Faker\Generator::class, function () {
    return \Faker\Factory::create('fa_IR');
});

al0mie left a reply on Foreign Keys

you can try

$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')

details https://laravel.com/docs/5.4/migrations#foreign-key-constraints

al0mie left a reply on $request->ajax() Is Not Working

To catch wantsJson() you need to specify json type in ajax request like dataType: "json" and also you can try to use alias request()->ajax() to catch that ajax.

13 May
1 year ago

al0mie left a reply on Change Foreign Column Table

so you need either store access_token_id in AccessToken table or just reverse your relationship.

al0mie left a reply on Make Helper For Adding Class="active"

Perhaps there an error is because blade interprets that variables as constants and not as strings. You can try

        Blade::directive('active', function($path, $positive = 'active', $negative = '') {
            return Request::is($path . '*') ? "'$positive'" :  "'$negative'";
        });

And also don't forget to execute php artisan view:clear. And use it like @active('some_path')

al0mie left a reply on How To Begin Adding

you need to be auth user if you want to do it. Or send data, that validate that you auth user. Or just remove auth middleware for this route.

al0mie left a reply on How To Delete Using Forms And RESTful Controllers

forms support only GET and POST methods, so change method to POST and add {{ method_field('DELETE') }} if your route is delete.

al0mie left a reply on Retrieve Single Results

about the first solution - yes, you said that you want just last result. about the second solution - yes, you need return that about the third solution - after @endforeach you have some variables like {{$book->name}} or {{$book->description}} so you can just replace on {{$books->last()->name}} and {{$books->last()->description}}

al0mie left a reply on To Fire Event When User Failed To Login

You can read about it https://laravel.com/docs/5.4/events This is usually handled in the listener handler method which is bound with event.

public function handle(loginCreditialsArray $event)
{
        // Access the credentials using $event->loginCreditialsArray
}

But hard to understand what do you want to do with it.

al0mie left a reply on Retrieve Single Results

remove

     @foreach($books as $book)
            <div class="small-3 medium-3 large-3 columns">
                <div class="item-wrapper">
                    <div class="img-wrapper">
                        
                        <a href="#">
                            <img src="{{url('images',$book->image)}}"/>
                        </a>
                    </div>
                    
                </div>
            </div>
            @endforeach

or change your method like

 public function index()
    {
        //i need to just show single result on my home page.
        $books=Product::all();
        // latest book
        $book = $books->last();
        return view('front.home',compact('books', 'book'));
    }

or use in the view outside the loop like {{$books->last()->name}}

al0mie left a reply on Change Foreign Column Table

yes, and you may not define third argument, if it's named like id. Just

return $this->hasOne(AppUserAccessToken::class,  'access_token_id');

al0mie left a reply on Eloquent Design For Hashtags

@mathishuettl yes, you will have 3 entry in postTagRelationship table. You can refactor your db to avoid this, but it's not recommend.

al0mie left a reply on Eloquent Design For Hashtags

You need two models: Post and Tag and relationship between them like many to many.

just

Post.php

public function tags()
{
    return $this->belongsToMany(Tag::class, 'postTagRelationship');
}

Tag.php

public function posts()
{
    return $this->belongsToMany(Post::class, 'postTagRelationship');
}

details https://laravel.com/docs/5.4/eloquent-relationships#many-to-many

al0mie left a reply on Getting Error On Registration In Laravel 5.4

Seems you wrong update your create method in RegisterController. It usually returns the user model which implements Authenticatable interface, but in your case you return just redirect.

12 May
1 year ago

al0mie left a reply on Laravel Resources - Object Has Null And Always Redirects To Show() Method

no, it's depends from the route path which you define like 'usages'. It seems it doesn't take a plural form but try to take a singular one. I think it's only confusing.

al0mie left a reply on Laravel Resources - Object Has Null And Always Redirects To Show() Method

it's possible that the name of variable can be wrong. Try it like

public function show(Usages $usage)

al0mie left a reply on Give Access To Feedback Form Based On Registration Age

in users table you can store field created_at, which means the date of registration, so when somebody request feedback form, you can check his date of registration

al0mie left a reply on Where Method Is Returning Object Instead Of Collection Or Array

try $this->preguntas_simples = $preguntas->where('id_enun', null)->get()

al0mie left a reply on Accessing Model Data In Blade - Or Better Way?

You can add to model some kind of slug for categories or use it name and after inject to your view some menu manager which will handle activity or anything else of your category item. Example for active class In your template

<li{!! $menuManager->getActivity($category, ' class="active"') !!}>
    <a href="{!! route('category', $category->slug) !!}">{!! category->name !!} </a>
</li>

And in the menu manager

public function getActivity($category, $parameter)
{
    //check current url how as you want. It just extra simple example.
    $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if (strpos($url, $category->slug) !== false) {
        return $parameter;
    } 
}

It's just example how you can do it. Also you can check it directly in views.

al0mie left a reply on Returning The Form Method (POST, PATCH, PUT) In A Custom Request - Laravel 5.4

it's strange, but $this->method() must works. Try request()->method()

al0mie left a reply on Returning The Form Method (POST, PATCH, PUT) In A Custom Request - Laravel 5.4

you can use it like

$method = $request->method();

if ($request->isMethod('post')) {
    //
}

details https://laravel.com/docs/5.4/requests#request-information

al0mie left a reply on Improve Collection!

mm why do you double iterate your collection and not just use a cache of getClassName call in the first iteration? Something like

$someCollection->each(function ($value, $attribute) {
    $className = $this->getClassName($attribute);
    if (class_exists($className)) {
        app($className);
    }
});

al0mie left a reply on Laravel Resources - Object Has Null And Always Redirects To Show() Method

check that you bind the model in routes like

Route::model('usages', 'Usages');

al0mie left a reply on To Fire Event When User Failed To Login

@mstdmstd yes, it's app/Http/Controllers/Auth/LoginController.php file. And you don't need change vendor files.

11 May
1 year ago

al0mie left a reply on How To Show The Latest Post

try to refresh cache and do it like

public function index()
{
    $laatsteposts = Post::latest()->first();
    
    return view('showposts', compact('laatsteposts'));
}

al0mie left a reply on Too Many Redirects Using Back() Helper Method On Middleware

The reason is in your middleware, since Auth::check() will return false it brings to you to infinite back redirects. Check that your middleware starts after web middleware or use the standart middleware for auth in laravel.

al0mie left a reply on Previous Link Doesnt Work

@closer01 maybe the second way was changed behavior in depends of laravel version (in 5.4 works). But you sure about that? It cannot return just id, only either object or null.

$previous = Post::find(Post::where('id', '<', $post->id)->max('id'));

I guess after that you can get slug, like $previous->post_slug if there it exists.

al0mie left a reply on Previous Link Doesnt Work

@closer01 Ok. Just do it. In your template you can get your post_slug like $previous->post_slug

$previous = Post::find(Post::where('id', '<', $post->id)->max('id'));
$next = Post::find(Post::where('id', '>', $post->id)->min('id'));
//but if you on max page, $next will be null, same for $previous on min page.

and in the template

<a href="{{ url('/posts/' . $previous->id ) }}" > Previous </a>
<a href="{{ url('/posts/' . $next->id ) }}" > Next </a>

al0mie left a reply on Associate User With Post

just add in store method

$post->user_id=auth()->id();