ARCANEDEV

ARCANEDEV

Member Since 3 Years Ago

Casablanca

Experience Points 78,615
Experience Level 16

1,385 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 693
Lessons
Completed
Best Reply Awards 21
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 Mar
1 month ago
03 Oct
6 months ago

ARCANEDEV left a reply on Eager Load Relations Stored In Json Field

Hi @christiangerdes,

Today, i've been searching for the solution and i found your post here.

There is no solution for the time being by using something like $this->belongsTo(User::class, 'data.user_id');.

So i started reading and searching in the laravel framework source code and i think i've found a work around.

So i'll share it with anyone who's struggling with this problem:

class Notification extends Model {
    //...

    public function user()
    {
        return $this->belongsTo(User::class, 'data_user_id');
    }

    // `data_user_id` accessor
    public function getDataUserIdAttribute()
    {
        return $this->data['user_id'] ?? null;
    }

    public function item()
    {
        return $this->belongsTo(Item::class, 'data_item_id');
    }

    // `item_user_id` accessor
    public function getDataItemIdAttribute()
    {
        return $this->data['item_id'] ?? null;
    }

    //...
}

Cheers

28 Feb
1 year ago

ARCANEDEV left a reply on How Use Works

Thanks to composer: official website

Check the autoloading (PSR-4): Video

ARCANEDEV left a reply on Where In Multiple Columns

My latest workaround if anyone is interested: link

21 Feb
1 year ago
20 Feb
1 year ago

ARCANEDEV left a reply on Where In Multiple Columns

Not the same, try to create the dummies table and check the result.

This is just an easy example but i'm using a complex table with a polymorphic colums.

SQL:

--

CREATE TABLE `dummies` (
  `id` int(10) NOT NULL,
  `morphable_type` varchar(255) NOT NULL,
  `morphable_id` int(10) UNSIGNED NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

--

INSERT INTO `dummies` (`id`, `morphable_type`, `morphable_id`) VALUES
(1, 'user', 1),
(2, 'user', 2),
(3, 'user', 4),
(4, 'user', 5),
(5, 'admin', 1),
(6, 'moderator', 1),
(7, 'admin', 2),
(8, 'user', 3);

ARCANEDEV left a reply on Where In Multiple Columns

Hi @shez1983, i've just tried the whereRaw()but it's not very eloquent.

<?php namespace App;

use Illuminate\Database\Eloquent\Model;

class Dummy extends Model
{
    /**
     * @param  array                                          $columns
     * @param  \Illuminate\Contracts\Support\Arrayable|array  $values
     *
     * @return \Illuminate\Database\Query\Builder
     */
    public static function whereInMultiple(array $columns, $values)
    {
        $values = array_map(function (array $value) {
            return "('".implode($value, "', '")."')"; }
        , $values);

        return static::query()->whereRaw(
            '('.implode($columns, ', ').') in ('.implode($values, ', ').')'
        );
    }
}

So the usage will be something like that:

$values = [
    ['type_a', 1],
    ['type_a', 2],
    ['type_b', 1],
    ['type_c', 1],
];

dd(Dummy::whereInMultiple(['morphable_type', 'morphable_id'], $values)->get())

ARCANEDEV left a reply on Where In Multiple Columns

Hi @JeffreyWay, you need to fix the SQL highlight ;)

ARCANEDEV started a new conversation Where In Multiple Columns

I have a table with something like that:

dummy
  - id
  - morphable_type
  - morphable_id

And i want to query this table with the Eloquent method whereIn(...):

$values = [
    ['type_a', 1],
    ['type_a', 2],
    ['type_b', 1],
    ['type_c', 1],
];

$dummies = Dummy::whereIn(['morphable_type', 'morphable_id'], $values)->get();

Any one has any idea how to achieve that ?

Works fine with a direct SQL but not with Eloquent class.

SELECT * FROM `dummy` 
WHERE (dummy.morphable_type, dummy.morphable_id) 
IN (('type_a', 1), ('type_a', 2), ('type_b', 1), ('type_c', 1))
11 Feb
1 year ago

ARCANEDEV left a reply on [Package] LogViewer (For Laravel 5)

Hi @Andicot, try to match the correct version of the laravel project with the package version , check this link: https://github.com/ARCANEDEV/LogViewer/blob/master/_docs/1.Installation-and-Setup.md#version-compatibility

18 Oct
1 year ago

ARCANEDEV left a reply on Is There A Documentation For Laravel 5.5 Api_token Based Authentication?

To understand the token-based authentication, start by reading about OAuth2 (server side).

Example: https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2

BTW, Laravel Passport is based on League OAuth2 server to build more rebust/secure/flexible APIs (check their documentation & repo).

01 Aug
1 year ago

ARCANEDEV left a reply on Api - Json Response Templates.. Where To Put Them?

You can create a new folder like app/Http/Transformers for example and put all your transformers classes inside:

<?php namespace App\Http\Transformers;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;

class PostsTransformer
{
    /* -----------------------------------------------------------------
     |  Main Methods
     | -----------------------------------------------------------------
     */

    public static function model(Model $model)
    {
        return static::respond(
            static::handle($model)
        );
    }

    public static function collect(Collection $collection)
    {
        $items = $collection->transform(function ($item) {
            return static::handle($item);
        });

        return static::respond($items->toArray());
    }

    /* -----------------------------------------------------------------
     |  Other Methods
     | -----------------------------------------------------------------
     */

    protected static function handle($data)
    {
        if ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        // handle the transformation

        return $data;
    }

    protected static function respond(array $data)
    {
        return response()->json($data);
    }
}

use App\Http\Transformers\PostsTransformer;

class Post extends \Illuminate\Database\Eloquent\Model {
    protected $fillable = ['title', 'content'];
}

Route::get('single', function () {
    $post = new Post([
        'title'   => 'Hello world!',
        'content' => "This is my post's content",
    ]);

    return PostsTransformer::model($post);
});

Route::get('multiple', function () {
    $posts = collect([
        new Post([
            'title'   => 'Hello world!',
            'content' => "This is my post's content",
        ]),
        new Post([
            'title'   => 'My second post',
            'content' => 'Check my other post',
        ])
    ]);

    return PostsTransformer::collect($posts);
});

If your app is a small one, you can use a trait or a helper class.

You can also use something like fractal

10 May
1 year ago
26 Apr
1 year ago

ARCANEDEV started a new conversation [Package] FormErrors Allows You To Manage Your Validation Errors Like You Do In Laravel Views

I extracted one of my utilities that i use in every Laravel + Vue.js project and i want to shared it with you guys.

ARCANESCRIPTS/FormErrors

Hope you enjoy it ( ^_^)b

Your comments, questions and feedback are welcome.

24 Apr
1 year ago

ARCANEDEV left a reply on Vue + Typescript

I've experienced the same situation the laste couple days but not with VueJs (It's awesome for modular components).

I use something like utilities/helpers for every single laravel project with vue js.

The question i've been asking: How to make these utilities/helpers maintainable and modular for my laravel's projects.

Let's take an example about these helpers:

There is $errors variable available in every views (blade) and it's an instance of Illuminate\Support\MessageBag.

This variable allows you to manage the validation's messages eloquently.

// Something like this:
@if ($errors->has('name'))
    <span class="label label-danger">{{ $errors->first('name') }}</span>
@endif

So i want to use something like this in my VueJs components (+API response):

// Something like this:
<span class="label label-danger" v-if="errors->has('name')">{{ errors->first('name') }}</span>

Yes, i'm not an expert in javascript but i've search for something OOP like if you program with PHP OOP.

I was afraid to get into something awfull & muddy.

Typescript was the solution (after i've googled like a mad man), it's like PHP7, it offers interfaces, typehints, Return Type Declarations and more.

Check the documentation for more details: http://www.typescriptlang.org

And i've used Typescript + ES6, it feels good and fun.

And I've tried also VS Code, OOOOH BOIIIIIII !!!

Here is the cool features that i've played with: https://code.visualstudio.com/docs/languages/typescript

I've managed to export the two main features with npm:

I didn't have the opportinity to use Typescript inside a laravel project but i'm eager to try it.

Bonus: laravel/echo is also a Typescript project.

ARCANEDEV started a new conversation Changing The Channel's Name From `Elixir` To `Elixir - Mix` ?

I think it's time to update the name !!

04 Feb
2 years ago

ARCANEDEV left a reply on A New Way To Structure Routes (PSR-4 Convention)

Thanks guys for your replies ( ^_^)b.

@CrushCandy Of course the route caching works with this structure and also IDE friendly.

03 Feb
2 years ago

ARCANEDEV left a reply on A New Way To Structure Routes (PSR-4 Convention)

What do you think of about this approach ?

Any feedback is greatly appreciated.

ARCANEDEV left a reply on A New Way To Structure Routes (PSR-4 Convention)

My bad, here you go ( ^_^)b

ARCANEDEV started a new conversation A New Way To Structure Routes (PSR-4 Convention)

There is a post on reddit shows how to structure your routes with PSR-4 convention.

It's pretty neat as a tip !!

31 Jan
2 years ago

ARCANEDEV left a reply on Laravel Array Value Validation

Try to check the Validating arrays section in Laravel documentation (Laravel >= 5.3).

28 Jan
2 years ago

ARCANEDEV left a reply on [L5.4] Maximum Function Nesting And Segmentation Fault

Try to delete the vendor folder & composer.lock and reinstall all the dependencies, see if it solves your issue.

Otherwise, create an issue in https://github.com/laravel/framework

ARCANEDEV left a reply on Need Help With User Role Relations

Are you using custom Model classes for instructors & pupils or just with User Model class ?

ARCANEDEV left a reply on [L5.4] Maximum Function Nesting And Segmentation Fault

Try to run these commands:

php artisan cache:clear 

chmod -R 777 app/storage 

composer dump-autoload

ARCANEDEV left a reply on Need Help With User Role Relations

The main goal is to differentiate between the users, something like this:

if (Auth::user()->isInstructor()) {
    // Instructor's Area
}
elseif (Auth::user()->isPupil()) {
    // Pupil's Area
}
else {
    // 404 or other logic
}

In your User model:

public function isInstructor()
{
    return $this->role->name === 'Instructor';
}

public function isPupil()
{
    return $this->role->name === 'isPupil';
}

ARCANEDEV left a reply on [L5.4] Maximum Function Nesting And Segmentation Fault

Try to add this:

https://github.com/ARCANESOFT/ARCANESOFT/blob/master/bootstrap/autoload.php#L8

You can increase the 'xdebug.max_nesting_level' until you solve your issue.

26 Dec
2 years ago

ARCANEDEV left a reply on [Package] SEO-Helper : Provides Tools And Helpers For SEO.

Hi @bulbulbigboss,

The SEO-Helper package allows you to manage the seo metas for your PHP/Laravel projects.

It does not have a GUI like wordpress yoast plugin.

For the readability checker, check this repo: https://github.com/DaveChild/Text-Statistics

15 Nov
2 years ago

ARCANEDEV left a reply on Laracasts Refresh

Like it

10 Nov
2 years ago

ARCANEDEV left a reply on [Package] LogViewer (For Laravel 5)

Hi artisans, i've just updated the package and i need your help to complete the translations.

The missing translations: https://github.com/ARCANEDEV/LogViewer/issues/95

Any help would be appreciated ( ^o^)b

Best regards

18 Oct
2 years ago

ARCANEDEV started a new conversation Does Anyone Had An Issue With Thephpleague/flysystem ?

For more details, check this issue on laravel/framework repo: https://github.com/laravel/framework/issues/15991

23 Aug
2 years ago

ARCANEDEV left a reply on [Package] SEO-Helper : Provides Tools And Helpers For SEO.

Thanks @JoeDawson for the example, very helpful.

The $this->seo() method is provided by Arcanedev\SeoHelper\Traits\Seoable Trait and you can add it in your controller, model, middleware ... wherever you want.

BTW Joe, you can also improve it like this:

/**
 * Display the specified resource.
 *
 * @param  \GrimeArchive\Video $video;
 * @return \Illuminate\Http\Response
 */
public function show(Video $video)
{
    $this->seo()
        ->setTitle($video->title)
        ->setDescription($video->description)
        ->twitter() // twitter card
            ->setType('summary_large_image')
            ->addImage($video->thumbnail());

    return view('videos.show', compact('video'));
}

The $this->seo()->setTitle() and $this->seo()->setDescription() covers also the twitter card and open graph tags.

And you can also grab the SEO stuff from the controller and put it in you video model (The SEO is related to the video) in a method like this $video->loadSEO().

22 Aug
2 years ago

ARCANEDEV left a reply on [Package] SEO-Helper : Provides Tools And Helpers For SEO.

Hi @ganesh, did you read the documentation and especially the usage section ?

I think this is better than a screenshot, and if you want a live example, check http://grimearchive.com website created by @JoeDawson.

28 Jul
2 years ago

ARCANEDEV left a reply on SEO Series, Please?

Hi @dmitry.g.ivanov, i don't think @JefferyWay will do a SEO series because is unrelated to web development (like PHP/Javascript...).

24 Jul
2 years ago

ARCANEDEV left a reply on Help Raw Query

You can do a check inside the closure:

if (empty($value)) {
    $join->on('join_one.some_id', '=', 'join_two.some_id');
}
else {
    $join->on('join_one.some_id', '=', 'join_two.some_id')
        ->where('join_two.value', '=', $value);
}

OR (i didn't test that) like this:

$join->on('join_one.some_id', '=', 'join_two.some_id');

if ( ! empty($value)) {
    $join->where('join_two.value', '=', $value);
}

ARCANEDEV left a reply on Help Raw Query

You do the same as the bookings join.

You pass a closure for users and courses, after the joins you add your where statements.

ARCANEDEV left a reply on Help Raw Query

You're welcome ( ^_^)b

ARCANEDEV left a reply on Help Raw Query

Can you try this:

$results = DB::table('advisor_user')
    ->join('bookings', 'advisor_user.user_id', '=', 'bookings.user_id')
    ->join('locations', 'bookings.location_id', '=', 'locations.id')
    ->join('courses', 'locations.course_id', '=', 'courses.id')
    ->join('users', 'bookings.user_id', '=', 'users.id')
    ->join('bookings', function ($join) {
        $join->on('advisor_user.user_id', '=', 'bookings.user_id')
             ->where('bookings.status', '=', 1)
             ->where('bookings.progress', '=', 2);
    })
    ->where('advisor_id', 3)
    ->select(
        'users.first_name', 
        'users.last_name', 
        'users.email', 
        'courses.title', 
        'locations.venue_name', 
        'locations.start_date', 
        'locations.end_date', 
        'bookings.status', 
        'bookings.progress'
    )->get();

ARCANEDEV left a reply on [Package] SEO-Helper : Provides Tools And Helpers For SEO.

It's been a while that i use this package in my projects (production apps) and it's awesome.

And now i'm asking if anyone in Laravel community sharing the same feeling about it.

I really you want to get more feedbacks if you've used this package.

Cheers

27 Jun
2 years ago

ARCANEDEV left a reply on [Request] Displaying Only My Favorited Links In Community Contributions

I've updated the title to be more clear about the feature request.

ARCANEDEV left a reply on [Request] Community Contributions Links

What i meant is to see only my favorite links. For the time being, there is no filter to achieve that.

ARCANEDEV started a new conversation [Request] Community Contributions Links

Hi @JeffreyWay,

Can you add a page like the favorite for the voted links in the community contributions ?

OR, How about a list next to the favorite lessons list ?

Thanks

06 Jun
2 years ago

ARCANEDEV left a reply on Laravel Elixir Does Not Remove CSS Comments With --production Flag

Hi @kossa,

Upgrade the elixir version to match with the latest one.

02 Jun
2 years ago

ARCANEDEV left a reply on Laravel Elixir Does Not Remove CSS Comments With --production Flag

@kossa The Elixir package has been changed.

Try to check the new config file: https://github.com/laravel/elixir/blob/master/src/Config.js#L188-L191

The new path is elixir.config.css.minifier.pluginOptions (Check https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api for more details).

01 May
2 years ago
29 Mar
3 years ago

ARCANEDEV left a reply on New Design...

Tnx @JeffreyWay for reducing the Line-height and list-item margins. Much impove, Such readability, Wow