Sergiu17

Sergiu17

Member Since 1 Year Ago

Chisinau

Experience Points 246,890
Experience Level 50

3,110 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 1377
Lessons
Completed
Best Reply Awards 163
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.

22 Mar
1 day ago

Sergiu17 left a reply on Do Anybody Know How To Install Laragon On Linux?

https://forum.laragon.org/topic/541/how-to-install-laragon-in-linux-operating-system

Looks like this is for Windows only

Currently, Laragon supports Windows only and I have no time to make it available on Linux.

21 Mar
2 days ago

Sergiu17 left a reply on How To Do A Foreach Loop For 1-10

Didn't read full post, according to your title and code

foreach (range(0, 10) as $item) {
    echo $item;
}

Sergiu17 left a reply on Method Delete Does Not Exist.

Yes, we know this

20 Mar
3 days ago

Sergiu17 left a reply on How To Make A Printout In Laravel

@ABDULBAZITH - https://codepen.io/JefMari/pen/jqPJdV

Google for: how to print specific portion | area js

19 Mar
4 days ago

Sergiu17 left a reply on Multiple File Upload

@FAIZANAHMED786 - Trust me, if I paste code here, on your side won't work, you will have errors, and you will not be sure what to do next, and you will ask what to do and what to change.

I already tried to help one person with the same problem Multiple file upload, but he had errors

17 Mar
6 days ago

Sergiu17 left a reply on About File

Could you reformulate your question?

14 Mar
1 week ago

Sergiu17 left a reply on PHP Confusion

I assume php was also installed as part of the laravel installation

No

how do I bring my php up to the required 7.1.3.

If you are using WAMP:

While I don't understand why the laravel install wouldn't have included the required version

https://github.com/laravel/laravel/blob/master/composer.json#L11

This is just composer, PHP version it's included in composer.json file, it forces you to have PHP 7 because, Laravel uses PHP 7 features - http://php.net/manual/en/migration70.new-features.php - you will find some PHP 7 features in Laravel core

06 Mar
2 weeks ago

Sergiu17 left a reply on How To Structure The Database For An E-commerce Using Mysql

When it comes to e-commerce applications - first thing I guess you should know is about - EAV https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model

05 Mar
2 weeks ago

Sergiu17 left a reply on Reusing Codeblocks In Blade

What I see first is that your variables are wrapped inside quotes, try to remove them

@include('admin.project.scheduleblock', ['table' => $parent])

@include('admin.project.scheduleblock', [table => $child])

Sergiu17 left a reply on Edit(elm)

If you are more familiar with php

<?php

function edit($elm)
{
    foreach($elm as $i => $el) {
        var_dump($i, $emelent);
    }   
}

$elements = [
    0 => 'Laravel',
    1 => 'PHP',
    2 => 'No clue'
];

edit($elements); // $elm comes from here
$i and $el come from the loop
04 Mar
2 weeks ago

Sergiu17 left a reply on PUT Request From Axios => "405 Method Not Allowed"

@CHARRUA - Yees, that's right PUT|PATCH budgets/{budget}. App\Http\Controllers\[email protected] - this route is for updating the resource

axios.put('http://127.0.0.1:8000/budgets', { - this is wrong

axios.put('http://127.0.0.1:8000/budgets/1', { - this will work

Sergiu17 left a reply on Public Folder Issue / .env File Related Issue

@TOWHID - You don't have to move anything. You have to change settings of root directory to be /var/www/your-app/public, usually cPanels provide this in UI, it's very easy to change it.

Sergiu17 left a reply on PUT Request From Axios => "405 Method Not Allowed"

Hi,

http://127.0.0.1:8000/budgets

This is the URL that you send a PUT Request, do you have this route registered?

php artisan route:list
GET /budgets // view all
GET /budgets/create // view form to create one item
GET /budgets/{id} // view specific
GET /budgets/{id}/edit // edit form for specific item
POST /budgets // create one
PUT/PATCH /budgets/{id} // update one
DELETE /budgets/{id} // delete one

So, you are sending a PUT request to /budgets, which is not correct, you need to send the request to: /budgets/{some-id}

Sergiu17 left a reply on Public Folder Issue / .env File Related Issue

What's the reason to put all files from public to root directory from applications?

Sergiu17 left a reply on I Want To Access Category Table Data Using Relation. But It Gives Me Error. I Have Created Relation Of Reminder Table With Reminder_category Table

@GURVINDERSINGH - ``` $data_rem = Reminder::with('reminderCategory') // add this: with('reminderCategory') ->latest() ->where('user_id','1') ->where('is_done','0') ->where('is_temp_delete','0') ->orderBy('priority','ASC') ->get();

dd($data_rem);

What does `dd($data_rem)` show you?

Sergiu17 left a reply on I Want To Access Category Table Data Using Relation. But It Gives Me Error. I Have Created Relation Of Reminder Table With Reminder_category Table

@GURVINDERSINGH - ``` Reminder::with('reminderCategory') // add this: with('reminderCategory') ->latest() ->where('user_id','1') ->where('is_done','0') ->where('is_temp_delete','0') ->orderBy('priority','ASC') ->get();


and should work, or
{{ $reminder->reminderCategory()->name }} // call reminderCategory as a method, not as a property ``` reminderCategory`()`->name

Sergiu17 left a reply on I Want To Access Category Table Data Using Relation. But It Gives Me Error. I Have Created Relation Of Reminder Table With Reminder_category Table

Did you eager load the results for reminderCategory ?

How do you query your results? Show your controller code

Sergiu17 left a reply on Controller Function With Request Class Input Not Found From Route

Hi, what is \App\Http\Requests\User ?

Sergiu17 left a reply on Database Notification Laravel 5.6

Does your Employeedetail Model use Notifiable trait?

class Employeedetail extends Model
{
    use Notifiable;
    
    // ..
}

02 Mar
3 weeks ago

Sergiu17 left a reply on Laravel Command Not Found

Make sure to place composer's system-wide vendor bin directory in your $PATH so the laravel executable can be located by your system. This directory exists in different locations based on your operating system; however, some common locations include:

$HOME/.config/composer/vendor/bin

https://stackoverflow.com/questions/25373188/laravel-installation-how-to-place-the-composer-vendor-bin-directory-in-your - example.

And after installation, restart your terminal.

01 Mar
3 weeks ago

Sergiu17 left a reply on Coupon Codes

Hi, as a member for two years on Laracasts :D I know that are two times per year, maybe more, one when is Black Friday - for sure, and one - just follow Jeffrey on Twitter https://twitter.com/jeffrey_way

28 Feb
3 weeks ago

Sergiu17 left a reply on How To Modify The Returned Result From Eloquent To Convert Json String To Json Object

class participation_detail extends Model
{
    $casts = [
        'complementary_zones' => 'array'
    ];
}

Sergiu17 left a reply on Storing Data With Loops

@MDELSHAD - ``` [ ['John', 25], ['Alex', 21], ['Mike', 40], ['Andrew', 18] ]

foreach(request('all') as $person) { Model::create([ 'name' => $person[0], 'age' => $person[1] ]); }

Sergiu17 left a reply on Storing Data With Loops

// for example
$user = ['John', 'Marry', 'Alex', 'Andrew'];

foreach($users as $name) {
    User::create([
        'name' => $name;
    ]);
}

Sergiu17 left a reply on Reporting Functions With @deprecated Docblock

@JDAVIDBAKR - hmm, not sure, this is just doc block. There may be some packages to inspect doc block by using reflection, and if it includes @deprecated, then throw error.

An example could be Annotations in Symfony for routes and relationships

27 Feb
3 weeks ago

Sergiu17 left a reply on Reporting Functions With @deprecated Docblock

Those @deprecated which are in 5.8, they will be removed in 5.9

Sergiu17 left a reply on How To Add Default Records When Fresh Migrating Database ?

I know that seed can be used but the doc tend to describe it more as test functionnality

Do you want to upload this data on production server? No! Of course is for testing only. https://laravel.com/docs/5.7/database-testing#writing-factories

Laravel Factories and DB Seeds is the solution

Sergiu17 left a reply on Store Into Database Data Record

Of course two records. As I said, in this situations, most of the time, you have to create one more table, or you could store it as JSON, and every single time encode/decode the field.

You can't store everything in one row ( at least the 'right' way ), JSON is an option

Sergiu17 left a reply on Store Into Database Data Record

You probably need two tables for this, but you could insert this data anyway.

foreach(request('group'a) as $group)
{
    Order::create([
        'customer_id' => request('customer_id'),
        'stock' => request('stock_date');
        // ...

        'item' => $group['item'];
        'amount' => $group['amount']
        // ...
    ]);
}
25 Feb
3 weeks ago

Sergiu17 left a reply on Load Related Model When Using Find.

Model::with('related_model')->find(1);

// ...

$model = Model::find(1);
$model->load('related_model');
23 Feb
1 month ago

Sergiu17 left a reply on How To Retrive A Category And All It's Child In Tree Structure Same As All Ecommerce Sites ?

// recursive helper function
function generateCategories($categories)
{
    foreach ($categories as $category) {
        echo '<li>' . $category->name . '</li>';
        if (count($category->children) > 0) {
            echo '<ul>';
                echo '<li>';
                    generateCategories($category->children);
                echo '</li>';
            echo '</ul>';
        }
    }
}
$categories = Categorie::where('parent_id', 0)->get();

<ul>
    generateCategories($categories);
</ul>

Sergiu17 left a reply on How To Retrive A Category And All It's Child In Tree Structure Same As All Ecommerce Sites ?

Warning - recursive queries

class Category extends Model
{

    public function subCategories()
    {
        return $this->hasMany(Category::class, 'parent_id')->with('subCategories');
    }
$category = Category::find(1);
$category->subCategories();

Sergiu17 left a reply on How To Iterate The Json Object In My View?

@SUNNYBOY - ``` @foreach($decodedJson->tasks as $task) // do a dd here to $task {{ dd($task) }} // you may need to have following syntax {{ $task["task_id"] }} @endforeach

Tinker with it till you make it work ))

Sergiu17 left a reply on How To Iterate The Json Object In My View?

@SUNNYBOY - Just dd you results

$decodedJson = json_decode($response);

dd($decodedJson) // this is an object, you have to access it's properties

return view('home', compact('decodedJson'));

http://php.net/manual/ro/function.json-decode.php

{!! $decodedJson->tasks[0]->progress !}}

Sergiu17 left a reply on How To Iterate The Json Object In My View?

$decodedJson = json_decode($response);

return view('home', compact('decodedJson '));
21 Feb
1 month ago

Sergiu17 left a reply on Interfaces And Parent Controllers

store($suspendee)
store(Model $model)

Here is the problem, if you will swap them, the code will work I think

<?php

namespace App\Http\Controllers;

use App\Interfaces\Suspendable;

class SuspensionsController extends Controller
{
    /**
     * Suspend a model.
     *
     * @param  \App\Interfaces\Suspendable  $suspendee
     * @return \lluminate\Http\RedirectResponse
     */
    public function store(Model $suspendee)
    {
        $this->authorize('suspend', $suspendee);

        abort_if($suspendee->isSuspended(), 403);

        $suspendee->suspend();

        $route = Str::plural($suspendee->getRouteKeyName());

        return redirect()->route("{$route}.index", ['state' => 'suspended']);
    }
}
<?php

namespace App\Http\Controllers;

use App\Model;
use Illuminate\Http\Request;

class ResourceOneSuspensionsController extends SuspensionsController
{
    public function store($model)
    {
        return parent::store($model);
    }

    public function destroy(Model $model)
    {
        return parent::destroy($model);
    }
}

Or, in SuspensionsController add the higher level model, and in child classes - lower level models: example

// SuspensionsController 
public function store(Model $suspendee)

// ResourceOneSuspensionsController
public function store(User $suspendee)

Where User extends Model

Sergiu17 left a reply on SQLSTATE[42000]: Syntax Error Or Access Violation: 1068 Multiple Primary Key Defined (SQL: Alter Table `device_models` Add Primary Key `device_models_device_model_primary`(`device_model`))

Multiple primary key defined

$table->increments('id')->unsigned();
$table->string('device_model', 32)->primary();

You can't have two of primary keys, as error says.

->unsigned() // redundant, it's already unsigned
$table->increments('id');

Solution would be:

$table->increments('id');
$table->string('device_model', 32)->unsigned();
20 Feb
1 month ago

Sergiu17 left a reply on Api Authorization

Hi, you could use Laravel Passport or JWT

Sergiu17 left a reply on Laravel Eloquent Relationship

@SOFTWEBGLOBE - OK, in this case you could do

User::with('blogpost.replies')->get()

Sergiu17 left a reply on Laravel Eloquent Relationship

$userId = auth()->id();

Blog::with(['replies' => function($query) user ($userId) { 
    $query->where('user_id', $userId);
}])->get();

I think this is one way to do it.

Sergiu17 left a reply on 'orWhere' Not Work Eloquent Model Relationship

@mwspacellc

Auth::user()->client() // SELECT * FROM `clients` where user_id = auth_user_id

>orWhere('vat_number', 'LIKE', '%' . $query . '%') // OR WHERE

So you end up with something like this:

SELECT * FROM clients WHERE user_id = $id OR WHERE vat_number LIKE .. OR WHERE fiscal_code LIKE

This is why you get others clients, I guess.

You can dump SQL queries, to see what's the query