LaraSell

LaraSell

Member Since 4 Months Ago

Experience Points
220
Total
Experience

4,780 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 your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 1
220 XP
Apr
06
3 months ago
Activity icon

Started a new Conversation Change Option Data Value In Select2 Ajax Tags

I have this code for select2 tags method using ajax:

json data:

[
    {
        "id": "5",
        "text": "laravel3"
    },
    {
        "id": "4",
        "text": "laravel2"
    }
]

code:


$(document).ready(function(){
      $('#tag_list').select2({
          placeholder: "Choose tags...",
          tags: true,
          minimumInputLength: 3,
          tokenSeparators: [",", " "],

          createSearchChoice: function(term, data) {
              if ($(data).filter(function() {
                  return this.text.localeCompare(term) === 0;
              }).length === 0) {
                  return {
                      id: term,
                      text: term
                  };
              }
          },
          ajax: {
              url: '/tags/find',
              dataType: 'json',
              data: function (params) {
                  return {
                      q: $.trim(params.term)
                  };
              },
              processResults: function (data) {
                  return {
                      results: data
                  };
              },
              delay: 250,
              cache: true
          }
      });
  });

with my code i can search and selected data from database or add new tag to my select2 area. now when i select data from database, <option value""> is data id but when i add new tag <option value""> is name(text) like this:

Now I need to change option value(database) from data id to data name(text). how do change option data value from id to name?!

Feb
22
4 months ago
Activity icon

Replied to Check Users In Roles Before Remove

@sinnbeck I check see error:

message: "No query results for model [Spatie\Permission\Models\Role] 999999" exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException"

Activity icon

Replied to Check Users In Roles Before Remove

@sinnbeck QueryExceptionis good idea. But in my action i see this error:

syntax error, unexpected ')', expecting '|' or variable (T_VARIABLE)

I think Add $e To QueryException.


try {
    $item = Role::withCount('users')->findOrFail($item_id);
} catch (QueryException $e) {
    return response()->json([
            'success' => false,
            'message' => 'Item not found!',
        ], 404);
}

if (! $item->users_count) {
    $item->delete();
}

Activity icon

Replied to Check Users In Roles Before Remove

@sinnbeck This Work True But this method find Role By users. For ie: if $item_id =='999999999' this code not work and not find true item_id. in action we need first check: role is find? Ok next step check if users in role.

Activity icon

Started a new Conversation Check Users In Roles Before Remove

I have this function for remove role (spatie package):

public function destroy(Request $request){

    $item_id = $request->get('item_id');
    $item = Role::find($item_id);
    if(empty($item)) {
        return response()->json([
            'success' => false,
            'message' => 'Item not found!',
        ], 404);
    } else {
        $item->delete();

        return response()->json([
            'success' => true,
            'message' => 'Item successfully deleted.',
        ], 200);
    }

}

this code work for me But i need to check role(users in role) before remove it. my mean is remove only role if There is no any user in that role.

Feb
18
4 months ago
Activity icon

Started a new Conversation Json_encode Not Work In Custom Output

I need too show query in json format:

class LocationController extends Controller { public function index(){

        $zoneNameByCountry = DB::table('zone')->where('country_id', '101')->first();

        echo json_encode(['output'=>$zoneNameByCountry]);
    }
}

Now in ouput i see:

{"output":{"zone_id":1538,"country_id":101,"name":"London","code":"30","status":1,"created_at":"2020-02-11 10:46:45","updated_at":"2020-02-11 10:46:45"}}

But I need to this:

{"output":[{"zone_id":1538,"country_id":101,"name":"London","code":"30","status":1,"created_at":"2020-02-11 10:46:45","updated_at":"2020-02-11 10:46:45"}]}

In My first output(false) json_encode remove [ and ]!! How do can i fix this problem?

Feb
17
4 months ago
Activity icon

Awarded Best Reply on Laravel Show Multiple Data In Datatables

I fix with this:

return implode(',', $admin->roles->pluck('name')->toArray());

Thanks Sinnbeck And snapey.

Activity icon

Replied to Laravel Show Multiple Data In Datatables

I fix with this:

return implode(',', $admin->roles->pluck('name')->toArray());

Thanks Sinnbeck And snapey.

Activity icon

Replied to Laravel Show Multiple Data In Datatables

Error from datatables:

Datatables warning: table id=yajra_datatable exeption message:

implode(); Invalid arguments passed

Activity icon

Replied to Laravel Show Multiple Data In Datatables

Error from datatables:

Datatables warning: table id=yajra_datatable exeption message:

implode(); Invalid arguments passed

Activity icon

Replied to Laravel Show Multiple Data In Datatables

Thanks Sure return implode(', ', $admin->getRoleNames()); work But in output i see array : ["moderator","manager"]

Activity icon

Started a new Conversation Laravel Show Multiple Data In Datatables

I work with laravel spatie permission package and need to show user role for each user in datatables lists. now I add datatables addColumn method:

$items = Admin::orderBy('id','DESC');

return DataTables::of($items)
->addColumn('role',function(Admin $admin){

    foreach($admin->getRoleNames() as $v){
        return $v;
    }

})
->toJson(); 

this code work and show role name for each user but If user have a two role name(multiple roles) My code not work and show only first role name. ie: for user test I have two roles name: moderator and editor But i see only moderator.

How to can i show multiple roles name for each user in datatables list?!