NoneNameDeveloper

NoneNameDeveloper

Member Since 1 Year Ago

Tashkent

Experience Points 1,860
Experience Level 1

3,140 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 1
Lessons
Completed
Best Reply Awards 0
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.

26 Jan
3 months ago

NoneNameDeveloper left a reply on Doesn't Delete Files If Exists From Public Folder | Laravel 5.7

@SNAPEY - Oy Sorry, I fixed it, this is not error. All pictures that are stored in the correct user/ directory. The whole code is working correctly but the old uploaded photos are not removed. Automatically saving a new image, but the old ones are not deleted.

25 Jan
3 months ago

NoneNameDeveloper started a new conversation Doesn't Delete Files If Exists From Public Folder | Laravel 5.7

I am using Laravel app with Intervention Image. However, if i upload a new image, old images will not be deleted. I'm writing a controller as follows.


//user image
        $image_icon = $request->file('image_icon');
        if($image_icon) {
            \File::delete(public_path() .'/upload/user/'.$user->image_icon.'-b.jpg');
            \File::delete(public_path() .'/upload/user/big'.$user->image_icon.'-s.jpg');
            $tmpFilePath = 'upload/teachers/';
            $tmpFilePathBig = 'upload/user/big/';
            $hardPath =  str_slug($inputs['full_name'], '-').'-'.md5(time());
            $img = Image::make($image_icon);
            $img1 = Image::make($image_icon);
            $img->fit(270, 225)->save($tmpFilePath.$hardPath.'-b.jpg');
            $img1->fit(360, 360)->save($tmpFilePathBig.$hardPath.'-s.jpg');
            $user->image_icon = $tmpFilePath.$hardPath;
        } 

Now i have doesn't work File::delete method. There is no file upload error. But the old image is not removed. How can i fix this problem? Thanks!
03 Jan
4 months ago

NoneNameDeveloper left a reply on Automatically Translate Letters | Laravel 5.7

@musa11971 yeah Thank you. You understand right me. If I want to change the look of the common site in two letters, does the helper will slow down the application?

NoneNameDeveloper started a new conversation Automatically Translate Letters | Laravel 5.7

I am creating an app, this application is available in several languages ... However, there are two types of letters in some languages. For example, Cyrillic , latin, and so on. Now I have the following structure of DB:


articleDB
- title_en
- title_ru
- article_desc_en
- article_desc_ru and etc...

Some texts must be in two letters. That is, in the letters of Cyrillic and latin. I want to make text to be automatically converted from one language to another without creating a table. That is, if the locale is changed, texts automatic should be converted to other letters. For example Cyrillic to latin or Latin to Cyrillic. There is no translation of English into Russian here. Only letters must be translated. Like tish
In Latin letter: Hello Dear
In Cyrillic Letter: Ҳелло деар

I think I can explain the question. What can I do to resolve this? I did not find the right information on Google, or I'm making a mistake on searching.

11 Dec
5 months ago

NoneNameDeveloper started a new conversation How To Fix POST Request 419 Error? | Laravel 5.7

For two days, there is one problem displayed in my localhost (XAMMPP and OpenServer).

Sorry, your session has expired. Please refresh and try again. 
I tried to clear cache, route, views, sessions... and also generated new app key but they doesn't helpd to fix this problem. Everything is works in Real hosting. However, localhost (http://localhost:8000) does not work POST requests. I used Laravel Collections and
tags...
I did all the answers in the forums but did not work anything. I also cleared browsers.. Now i have

{!! Form::open(array('url' => array('nuu-admin/directions/submit_direc'),'class'=>'','name'=>'category_form','id'=>'category_form','role'=>'form','enctype' => 'multipart/form-data')) !!} 
---

                        @csrf

All of them doesn't work. Everytime displayed 419 error page!! How can i solve this problem? Please give some advice! Thanks!
23 Nov
5 months ago

NoneNameDeveloper left a reply on How To Create Custom Email Verification Template | Laravel 5.7

@MARTINBEAN - Hi, Thanks, but when I trying this, I have some problem like this

Call to undefined method App\Providers\AppServiceProvider::verificationUrl()
thanks!

NoneNameDeveloper started a new conversation How To Create Custom Email Verification Template | Laravel 5.7

Now I am starting using Laravel 5.7, and we know after upgrading to Laravel 5.7 added new feature Email Verification, So I saw method in this file:

laravel\framework\src\Illuminate\Auth\Notifications
. But I couldn't find template or blade for sending Verification template. How can I create or find it? I rad https://laravel.com/docs/5.7/verification#after-verifying-emails doc but I couldn't found anything about blading....

18 Oct
7 months ago

NoneNameDeveloper started a new conversation Summernote Image Upload Error While Editing Form | Laravel 5.7

I am using the Summernote editor to insert pictures with new data in the form. It does not make any mistakes while uploading new content to the Database; it works all the time. However, if I try to edit the content i have some errors. while entering a new image or if I want to add a new image to the content, there some following error is occurring.


The following error message will be displayed while editing the inserted information.
"Undefined offset: 1"

My Controller

public function addnew(Request $request)
    { 
        $data =  \Input::except(array('_token')) ;
        $rule=array(
                'menu_name' => 'required',            
                'lang_code' => 'required'
                 );
         $validator = \Validator::make($data,$rule);
        if ($validator->fails())
        {
                return redirect()->back()->withErrors($validator->messages());
        } 
        $inputs = $request->all();
        //dd($request->all());
        $ms = $inputs['news_description'];
    $dom = new \domdocument();
    $dom->loadHtml($ms, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
    
    $images = $dom->getelementsbytagname('img');
    foreach($images as $k => $img){
        $datas = $img->getattribute('src');
        list($type, $datas) = explode(';', $datas);
        list(, $datas)      = explode(',', $datas);

        $datas = base64_decode($datas);
        $image_name= time().$k.'.png';
        $path = public_path() .'/upload/menus/'. $image_name;
        file_put_contents($path, $datas);

        $img->removeattribute('src');
        $img->setattribute('src', '/upload/menus/'.$image_name);
    }
    $ms = $dom->saveHTML();

    if(!empty($inputs['id'])) {
        $menus = Menus::findOrFail($inputs['id']);
    }else{
        $menus = new Menus;
    }
    $menu_slug = str_slug($inputs['menu_name'], "-");
    
    $menus->menu_name = $inputs['menu_name'];
    $menus->menu_slug = $menu_slug; 

    $menus->news_description = $ms;
    $menus->lang_code = $inputs['lang_code']; 
    $menus->save();
    if(!empty($inputs['id'])){
        \Session::flash('warning', "Changes saved");
        return \Redirect::back();
    }else{
        \Session::flash('warning', "The New Menu Added!");
        return \Redirect::back();
    }            
}   

public function editmenus($menu_id) { $menupost = Menus::findOrFail($menu_id return view('administrator.modules.addeditmenus',compact('menupost')); }

The problem here is that the content you edit should not be erroneously modified. How can I resolve the issue? Thanks!
10 Sep
8 months ago

NoneNameDeveloper started a new conversation Laravel Scout Doesn't Catch Input Data | Laravel 5.6

Hi everyone! I working with Laravel scout and Laravel 5.6. But the browser doesn't catch input data in url myapp.com/q?search=(input data). Now i have like this controllers and modals.


My Model:
public function searchableAs()
    {
        return 'users_index';
    }

My Controller like this:

public function search(Request $request)
    {
    if($request->has('search')){
        $users = UserSearch::search($request->input('search'))->get();  
    }else{
        $users = UserSearch::get();
    }
    return view('resume.search', compact('users'));
}

And my html form like this:


                        
< input type="text" class="keyword-input" placeholder="e.g. user name, keyword..." name="search" /> < button type="submit" class="keyword-input-button ripple-effect">< /button > < /div > < /form >
When I runt this code, it just returned back to me only q?search=. The keyword entered in input does not appear in q?search = (inputdata). If I could explain, what could be the problem?
07 Sep
8 months ago

NoneNameDeveloper started a new conversation Display Avarage Of Rating With Query Builder? | Laravel 5.6

Hi, I have a query and I need average rating number (ex: 5, 3, 2 etc..) of single article. Now I have two table posts and ratings, that I get from a simple Eloquent query Post::where('id', '=', '1')->first(); This articles can have multiple ratings, that are stored in an other table. I need to get the average of ratings. So my query is now like this:


public function view_post($post_id)    
  { 
    $resume = DB::table('posts')
    ->leftJoin('post_categories', 'posts.cat_id', '=', 'post_categories.id')
    ->leftJoin('location', 'posts.location_id', '=', 'location.id')
    ->leftJoin('user_reviews', 'posts.id', '=', 'user_reviews.post_id')
    ->select('posts.*', 'location.state_name','location.state_flag', 'post_categories.category_name', DB::raw( 'AVG( user_reviews.rating )' ))
    //->groupBy('posts.id')
    ->where(array('posts.id'=>$post_id))->first();

I can't use groupBy (If I use and after run I have error)... How can I do it?Thanks!
05 Sep
8 months ago

NoneNameDeveloper started a new conversation Laravel Query Builder Counting Problem | Laravel 5.6

There is my query function using fluent query builder. And I want to count id from some tables.


$my_jobs = DB::table('jobs')
  ->leftJoin('job_categories', 'jobs.cat_id', '=', 'job_categories.id')
  ->leftJoin('location', 'jobs.location_id', '=', 'location.id')
  ->leftJoin('jobtypes', 'jobs.jobtype', '=', 'jobtypes.id')
  ->leftJoin('users', 'jobs.user_id', '=', 'users.id')
  ->leftJoin('apply_jobs', 'jobs.id', '=', 'apply_jobs.job_id')
  ->select('jobs.title', 'jobs.salary_from', 'jobs.salary_to', 'jobs.job_slug', 'jobs.id', 'jobs.user_id', 'jobs.location_id', 'jobs.created_at', 'jobs.status', 'jobs.end_date', 'job_categories.category_name', 'location.state_name', 'jobtypes.jobtypes_name', 'users.first_name', 'users.last_name', 'users.verified', 'users.image_icon', DB::raw('COUNT(apply_jobs.job_id) as appliers'))
  ->orderBy('id','desc')->where(array('jobs.user_id'=> $user_id))->paginate(10);

And i have this error:
"SQLSTATE[42000]: Syntax error or access violation: 1055 'free_jobs.jobs.title' isn't in GROUP BY (SQL: select `jobs`.`title`, `jobs`.`salary_from`, `jobs`.`salary_to`, `jobs`.`job_slug`, `jobs`.`id`, `jobs`.`user_id`, `jobs`.`location_id`, `jobs`.`created_at`, `jobs`.`status`, `jobs`.`end_date`, `job_categories`.`category_name`, `location`.`state_name`, `jobtypes`.`jobtypes_name`, `users`.`first_name`, `users`.`last_name`, `users`.`verified`, `users`.`image_icon`, COUNT(apply_jobs.job_id) as followers from `jobs` left join `job_categories` on `jobs`.`cat_id` = `job_categories`.`id` left join `location` on `jobs`.`location_id` = `location`.`id` left join `jobtypes` on `jobs`.`jobtype` = `jobtypes`.`id` left join `users` on `jobs`.`user_id` = `users`.`id` left join `apply_jobs` on `jobs`.`id` = `apply_jobs`.`job_id` where (`jobs`.`user_id` = 14) group by `apply_jobs`.`job_id` order by `id` desc limit 10 offset 0) ◀"
So how can i select count with query builder? Thanks!
26 Jul
9 months ago

NoneNameDeveloper left a reply on Laravel-MIX "npm Run Dev" Error | Laravel 5.6

@dawoodiddris I have all installed, In Laravel 5.6 same error, I don't know how can I solve it.

How can I solve this problem? There was no error installing.

NoneNameDeveloper started a new conversation Laravel-MIX "npm Run Dev" Error | Laravel 5.6

I am installing laravel app and NPM, But when i rund npm run dev i have some problems. So i did like that.


C:\Users\WSMG>
C:\Users\WSMG>cd C:\ospanel\domains\localhost

C:\OSPanel\domains\localhost>npm install [email protected] -g C:\Users\WSMG\AppData\Roaming\npm\npx -> C:\Users\WSMG\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js C:\Users\WSMG\AppData\Roaming\npm\npm -> C:\Users\WSMG\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js

C:\OSPanel\domains\localhost>npm install --save-dev cross-env npm notice created a lockfile as package-lock.json. You should commit this file.

  • [email protected] added 10 packages from 8 contributors and audited 10 packages in 1.682s found 0 vulnerabilities

C:\OSPanel\domains\localhost> C:\OSPanel\domains\localhost>npm run dev

@ dev C:\OSPanel\domains\localhost npm run development

@ development C:\OSPanel\domains\localhost cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

The system can not find the specified path. events.js: 183 throw er; // Unhandled 'error' event ^

Error: spawn node_modules\webpack\bin\webpack.js ENOENT at notFoundError (C:\OSPanel\domains\localhost\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26) at verifyENOENT (C:\OSPanel\domains\localhost\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16) at ChildProcess.cp.emit (C:\OSPanel\domains\localhost\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25) at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @ development: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @ development script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\WSMG\AppData\Roaming\npm-cache_logs18-07-26T09_45_11_656Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @ dev: npm run development npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @ dev script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\WSMG\AppData\Roaming\npm-cache_logs18-07-26T09_45_11_703Z-debug.log

C:\OSPanel\domains\localhost> C:\OSPanel\domains\localhost>

This problem occurs when I run NPM. I chacked GOOGLE but couldn't find solution for my problem. I am using WIndows, And OpenServer, NodeJS Command Promp Thanks.
24 Jul
9 months ago

NoneNameDeveloper left a reply on An Invalid ID Displayed In The Query Builder | Laravel 5.6

@Snapey Well, I reordered the tables. I think the role of the tables here is of great importance. It would be useful to use another option instead.


'users.id as u_id'

23 Jul
9 months ago

NoneNameDeveloper left a reply on An Invalid ID Displayed In The Query Builder | Laravel 5.6

@Snapey thanks, I fixed it by like this. I changed users. and jobs.


 ->select('users.*', 'job_categories.category_name', 'experience_type.experience_name', 'location.state_name','location.state_flag', 'jobtypes.jobtypes_name', 'jobs.*')->where(array('status'=>'1', 'jobs.id'=>$job_id))->first();

In my view, the role of the table when calling tables is of great importance.

NoneNameDeveloper left a reply on Select All And Group By Using A Column Value

@bmm , ok so:


$destination = DB::table(destination )
                 ->leftJoin('users', 'destination.user_id', '=', 1)
        ->select('destination.*', 'users.*')
                ->groupBy('tenantID')
                ->get();

This is the most optimal variant.

NoneNameDeveloper left a reply on Select All And Group By Using A Column Value

@bmm , Use like this, not Group By use Order By.


$destination = DB::table('destination')->where(array('user_id'=>'1' ))->orderBy('tenantID')->get();

This should work.

NoneNameDeveloper left a reply on Select All And Group By Using A Column Value

You can do like this:


$listing = DB::table('destination')->where(array('user_id'=>'1', ))->groupBy('tenantID')

NoneNameDeveloper started a new conversation An Invalid ID Displayed In The Query Builder | Laravel 5.6

I have more_info controller. And it will be addressed via post_id/post_title. After the Read more page opens (site.com/post/post_id/post_title/), I have a post that is linked to that post id. But there is another id in the post. So my Controller:


public function more_info($job_id, $job_slug)    
  { 
    $listing = DB::table('jobs')
    ->leftJoin('job_categories', 'jobs.cat_id', '=', 'job_categories.id')
    ->leftJoin('location', 'jobs.location_id', '=', 'location.id')
    ->leftJoin('jobtypes', 'jobs.jobtype', '=', 'jobtypes.id')
    ->leftJoin('experience_type', 'jobs.experience_id', '=', 'experience_type.id')
    ->leftJoin('users', 'jobs.user_id', '=', 'users.id')
    ->select('jobs.*', 'job_categories.category_name', 'experience_type.experience_name', 'location.state_name','location.state_flag', 'jobtypes.jobtypes_name', 'users.*')->where(array('status'=>'1', 'jobs.id'=>$job_id))->first();
        return view('jobs.view',compact('listing'));
  }

In my View;

URL: http://localhost:8000/jobs/8/why-do-we-use-it

In the page

{{$listing->id}} {{$listing->title}}

It displayed like this 14 Why do we use it? In this controller only ID is wrong, other all things as wel as.

My linked post's id is 8, but it displayed 14.


My Route

Route::get('jobs/{id}/{job_slug}', 'Jobs\[email protected]_info');

What's wrong with this place? I do not understand. In my opinion all is correct. Thanks!
20 Jul
10 months ago

NoneNameDeveloper started a new conversation Search Posts In The Database | Integrity Constraint Violation: 1052 | Laravel 5.6

I am creating Laravel app, but when I work with searching I have some problems. Now i have like this codes:


My Model
public function scopeSearchByKeyword($query, $keyword, $location)
    {
        if ($keyword!='' and $location!='') {
            $query->where(function ($query) use ($keyword,$location) {
                $query->where("title", "LIKE","%$keyword%")
                    ->where("location_id", "$location")
                    ->where("status", "1");                     
            });
        }
        elseif ($location!='') {
            $query->where(function ($query) use ($location) {
                $query->where("location_id", "$location")
                ->where("status", "1");
        });
    }
    else
    {
        $query->where(function ($query) use ($keyword) {
            $query->where("title", "LIKE","%$keyword%")
            ->where("status", "1");
                                
        });
    }
    return $query;
}

And than my controller:

My Model

public function search_jobposts(Request $request) {
   $inputs = $request->all();
   $keyword = $inputs['search_keyword'];
   $location = $inputs['location'];

   $all_jobs = Jobposts::SearchByKeyword($keyword,$location)
    ->leftJoin('job_categories', 'jobs.cat_id', '=', 'job_categories.id')
    ->leftJoin('location', 'jobs.location_id', '=', 'location.id')
    ->leftJoin('jobtypes', 'jobs.jobtype', '=', 'jobtypes.id')
    ->leftJoin('users', 'jobs.user_id', '=', 'users.id')
    ->select('jobs.title', 'jobs.salary_from', 'jobs.salary_to', 'jobs.job_slug', 'jobs.id', 'jobs.user_id', 'jobs.location_id', 'jobs.created_at', 'jobs.description', 'jobs.featured_job', 'job_categories.category_name', 'location.state_name', 'jobtypes.jobtypes_name', 'users.first_name', 'users.last_name', 'users.verified', 'users.image_icon')->get();

   $total_res = count($all_jobs);  

    
return view('jobposts.search',compact('all_jobs','total_res','keyword','location'));
}

When i run this code i have this error:


"SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'location_id' in where clause is ambiguous (SQL: select `jobs`.`title`, `jobs`.`salary_from`, `jobs`.`salary_to`, `jobs`.`job_slug`, `jobs`.`id`, `jobs`.`user_id`, `jobs`.`location_id`, `jobs`.`created_at`, `jobs`.`description`, `jobs`.`featured_job`, `job_categories`.`category_name`, `location`.`state_name`, `jobtypes`.`jobtypes_name`, `users`.`first_name`, `users`.`last_name`, `users`.`verified`, `users`.`image_icon` from `jobs` left join `job_categories` on `jobs`.`cat_id` = `job_categories`.`id` left join `location` on `jobs`.`location_id` = `location`.`id` left join `jobtypes` on `jobs`.`jobtype` = `jobtypes`.`id` left join `users` on `jobs`.`user_id` = `users`.`id` where (`title` LIKE %Education% and `location_id` = 9 and `status` = 1)) ◀"

Where am I doing wrong? I think I'm making a mistake in Query Builder. Thanks!

05 Jul
10 months ago

NoneNameDeveloper started a new conversation Importing File With Category Using Laravel Excel 2.*

Hi everyone! I have a problem with importing XLS file with category. So I have this controller.


public function importExcel(Request $request)
    {   
        if($request->hasFile('import_file')){
            Excel::load($request->file('import_file')->getRealPath(), function ($reader) {
                foreach ($reader->toArray() as $key => $row) {
                    $cv = array_values($row);
                    $data['stir'] = $cv[0]; 
                    $data['berildi'] = $cv[1]; 
                    $data['lit_num'] = $cv[2]; 
                    $data['gacha'] = $cv[3]; 
                    $data['cat_id'] = 'cat_id';  
                if (!empty($data) )
                {
                DB::table('my_date')->insert($data);
                }
            }
        });
    }
    Session::put('success', 'Youe file successfully import in database!!!');
    return back();
}

And i have this view (Form)

@if ($errors->has('import_file')) {{ $errors->first('import_file') }} @endif
How can i fix this? That i need import file via category id. Thanks!
28 Jun
10 months ago

NoneNameDeveloper started a new conversation Problem With Working With Column And Rows In Laravel-Excel | Laravel 5.6

Hi everyone! Sorry for simple question. So i have this controller but this controller import all rows from column that if row is empty, this import empty rows. I need only import not empty rows.

if($request->hasFile('import_file')){ Excel::load($request->file('import_file')->getRealPath(), function ($reader) { foreach ($reader->toArray() as $key => $row) { $columnValues = array_values($row); $data['stir'] = $columnValues[0]; //Column A $data['berildi'] = $columnValues[1]; $data['lit_num'] = $columnValues[2]; $data['gacha'] = $columnValues[3]; if (!empty($data) and !empty($columnValues)) { DB::table('my_date')->insert($data); } } }); }

After run it:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'lit_num' cannot be null (SQL: insert into `my_date` (`stir`, `berildi`, `lit_num`, `gacha`) values (303418124, 2018-02-06 00:00:00, , 2019-02-06 00:00:00))
I need to import non empty columns and rows into database.
27 Jun
10 months ago

NoneNameDeveloper left a reply on Selecting Columns And Rows Laravel Excel 2.* | Laravel 5.6

@Yorki still I have a few question. How can I do that, This code import all columns, But I need import only not nulled rows. So how can I do it? Thanks!

NoneNameDeveloper left a reply on Selecting Columns And Rows Laravel Excel 2.* | Laravel 5.6

@Yorki I dumped it. And there is result:


0
array:5 [▼
  207245769 => 207260940.0
  43104 => Carbon @1515024000 {#8856 ▼
    date: 2018-01-04 00:00:00.0 UTC (+00:00)
  }
  "0312_0001_bg" => "03/15-0002-АЮ"
  43473 => Carbon @1546560000 {#8859 ▼
    date: 2019-01-04 00:00:00.0 UTC (+00:00)
  }
  207245770 => null
]

NoneNameDeveloper left a reply on Selecting Columns And Rows Laravel Excel 2.* | Laravel 5.6

@Yorki thanks but still has a problem!I hcanged but


public function importExcel(Request $request)
    {
        if($request->hasFile('import_file')){
            Excel::load($request->file('import_file')->getRealPath(), function ($reader) {
                foreach ($reader->toArray() as $key => $row) {
                    $data['stir'] = $row['A'];
                    $data['lit_num'] = $row['B'];
                    $data['berildi'] = $row['C'];
                    $data['gacha'] = $row['D'];
                    if(!empty($data)) {
                        DB::table('data')->insert($data);
                    }
                }
            });
        }
        Session::put('success', 'Youe file successfully import in database!!!');
        return back();
    }

After then:
Undefined index: A
Files
import_file
array:5 [▼
  "name" => "ion.xls"
  "type" => "application/vnd.ms-excel"
  "tmp_name" => "C:\OSPanel\userdata\temp\php780F.tmp"
  "error" => 0
  "size" => 141312
]

NoneNameDeveloper started a new conversation Selecting Columns And Rows Laravel Excel 2.* | Laravel 5.6

Hi! I'm using the very useful https://github.com/Maatwebsite/Laravel-Excel package. And i need import date from excel to database. But when i tried i have

Undefined index: stir
eroor! How can i fix it? I need import dates from A, B, C, D columns. There is my controller:


public function importExcel(Request $request)
    {
        if($request->hasFile('import_file')){
            Excel::load($request->file('import_file')->getRealPath(), function ($reader) {
                foreach ($reader->toArray() as $key => $row) {
                    $data['A'] = $row['stir'];
                    $data['B'] = $row['lit_num'];
                    $data['C'] = $row['berildi'];
                    $data['D'] = $row['gacha'];
                    if(!empty($data)) {
                        DB::table('data')->insert($data);
                    }
                }
            });
        }
        Session::put('success', 'Your file successfully import in database!!!');
        return back();
    }

There is my excel structure: My excel structure image: https://imgur.com/a/pWw3wsJ Thanks!
02 Jun
11 months ago

NoneNameDeveloper left a reply on Call To A Member Function Format() With Date | Laravel 5.6

Hi. @Cronix i have all is correctly. I fixed it already:D But no solution

NoneNameDeveloper left a reply on Call To A Member Function Format() With Date | Laravel 5.6

@Snapey thanks, But I have all is same with older version of Laravel. So I have this controller.

public function index()
{
   $blogs = DB::table('blogs')
                       ->leftJoin('blog_categories', 'blogs .cat_id', '=', blog_categories.id')
                       ->select('blogs .*','blog_categories.category_name')
                       ->where(array('featured_blog'=>'1'))->take(6)->get();
    return view('pages.home',compact('categories', blogs));
}
And in view

@foreach(blogs as blog) {{ $blogs->created_at->format('Y-m-d , G:i:s') }} @endforeach.

NoneNameDeveloper started a new conversation Call To A Member Function Format() With Date | Laravel 5.6

After working with Laravel 5.6.x i have some errors with date to string. In older versions i used it for date to string.

{{ $blogs->created_at->format('Y-m-d , G:i:s') }}

But after laravel 5.6 it doesn't work. How can i fix it? Thanks!

31 May
11 months ago

NoneNameDeveloper left a reply on How To Fetch Most Popular Categories From Database? | Laravel 5.6

@lostdreamer_nl Thanks! But a little problem, how can I display count in view?

@foreach($categories as $i => $cat
                                        {{ $cat->category_name }}
                                        ({{ $cat->blogs_count }} Open Blogs) It doesn't work)
                                    
                                    @endforeach 

NoneNameDeveloper started a new conversation How To Fetch Most Popular Categories From Database? | Laravel 5.6

I have creating news portal. And I need display sort most popular 8 categories with count of blogs in category. But I can't do it with Query builder.....( So how can I sort most popular categories and count of blogs in this category. Ex: Technology (10 posts).

Now i have this controller.

$mpc = DB::table('blog_categories') ->leftJoin('blogs', 'blog_categories.id', '=', 'blogs.cat_id') ->select('blog_categories.','blog_categories.) ->get();

So how can i sort 8 most popualr categories with count of blogs in this category? Thanks!

13 May
1 year ago

NoneNameDeveloper started a new conversation Ho Can I Get Field From Provider | Laravel 5.6.x Socialite

Hi, I am adding social login to my project, so when user registration I need get some fields from provider like,

last_name, fist_name, gender, email, username
At the moment I have model

 

class SocialAccountService { public function findOrCreate(ProviderUser $providerUser, $provider) { $account = LinkedSocialAccount::where('provider_name', $provider) ->where('provider_id', $providerUser->getId()) ->first(); if ($account) { return $account->user; } else { $user = User::where('email', $providerUser->getEmail())->first(); if (!$user) { $user = User::create([
'email' => $providerUser->getEmail(), 'first_name' => $providerUser->getName(), ]); } $user->accounts()->create([ 'provider_id' => $providerUser->getId(), 'provider_name' => $provider, ]); return $user; } } }

So how can I get needed fields from linkedin, facebook, google and twitter? Now i need this.

  • last_name
21 Mar
1 year ago

NoneNameDeveloper started a new conversation Laravel Add Rating Score After Submiting Post | Laravel 5.6

I have creating blog, and I need give rating score after posting users. Then I have this functions.


$posts->cat_id = $inputs['category'];
        $posts->title = $inputs['title']; 
        $posts->blog_slug = $blog_slug;
        $posts->description = $inputs['description'];
        $posts->tags = $inputs['tags'];
    $total_avg = round($inputs['listing_id'])->avg('rating'));
    $posts->review_avg = $total_avg;  
    $posts->save();

My Table Schame: $table->string('review_avg')->nullable(); So, but it is not working valid. I need give score after adding new post. For example: if user add new post he will get 2 score.... How can i do it?
15 Mar
1 year ago

NoneNameDeveloper left a reply on Problem With Registration User Data | Laravel 5.6

Thanks! @Seilem , But I have question. IMHO Why is not it a must-have for versions up to 5.5? If I am not mistaken? Is it true?

NoneNameDeveloper started a new conversation Problem With Registration User Data | Laravel 5.6

After updating Larawel to 5.6, users are required to enter each field in registration (all fields should not be asked). I only have to ask 4 or 5 fields... But at the same time, I have to give start to value in every field.


protected function create(array $data)
    {
        return User::create([
            'usertype' => 'Admin',
            'username' => $data['username'],
            'first_name' => $data['first_name'],
            'last_name' => $data['last_name'],
            'email' => $data['email'],
            'lavel' => 1,
            'my_skills' => 'blogger',
            'mobile' => 'no',
            'website' => 'no',
            'address' => 'no',
            'about_me' => 'no',
            'facebook_url' => 'no',
            'google_url' => 'no',
            'twitter_url' => 'no',
            'linkedin_url' => 'no',
            'youtube_url' => 'no',
            'contact_email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);


But I need only 4 fields, then username, usertype, email and password . If I add like I have general error 1364 field.

protected function create(array $data)
    {
        return User::create([
            'usertype' => 'Admin',
            'username' => $data['username'],
            'first_name' => $data['first_name'],
            'last_name' => $data['last_name'],
            'email' => $data['email'],
         'password' => bcrypt($data['password']),
        ]);


If I did this with Larawel 5.5 all is ok, but it was a mistake in version 5.6, it would require every space.
My database table structure like this:
Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('usertype', 20)->nullable(); $table->string('username', 30)->unique(); $table->integer('lavel')->length(1); $table->boolean('verified')->default(false); $table->text('my_skills'); $table->string('first_name'); $table->string('last_name'); $table->string('email')->unique(); $table->string('password', 60); $table->string('image_icon')->nullable(); $table->string('mobile'); $table->string('contact_email'); $table->string('website'); $table->text('address'); $table->text('about_me'); $table->string('facebook_url'); $table->string('twitter_url'); $table->string('linkedin_url'); $table->string('google_url'); $table->string('youtube_url');
        $table->rememberToken();
        $table->timestamps();

What i need to fix it? Thanks!

19 Feb
1 year ago
16 Feb
1 year ago

NoneNameDeveloper left a reply on Argument 1 Must Be An Instance (Registration Error) | Laravel 5.5

@skliche Now I have default authentication Of laravel, and I read it before add user activation. https://www.5balloons.info/user-email-verification-and-account-activation-in-laravel-5-5/ Then I added this codes.

NoneNameDeveloper left a reply on Argument 1 Must Be An Instance (Registration Error) | Laravel 5.5

@skliche I don't understand this error, Because app created user, but when registration is completed I have this error. If I back user already registered and Logged to site automatic. I changed it before add this code. protected $redirectTo = '/profile'; I changed it to this protected function registered(Request $request, $user) { $this->guard()->logout(); return redirect('/login')->with('status', 'We sent you an activation code. Check your email and click on the link to verify.'); } After Then I have an error.

NoneNameDeveloper left a reply on Argument 1 Must Be An Instance (Registration Error) | Laravel 5.5

@bobbybouwmann I have imported it already, This error with not same this function.

NoneNameDeveloper started a new conversation Argument 1 Must Be An Instance (Registration Error) | Laravel 5.5

I saw this Tuturial User email verification and account activation in Laravel 5.5 And I have add it to my project. But when I register new user I have that error!? Argument 1 passed to App\Http\Controllers\Auth\RegisterController::registered() must be an instance of App\Http\Controllers\Auth\Request, instance of Illuminate\Http\Request given, called in C:\OSPanel\domains\openjobs.uz\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php on line 37 And i have this code in Line 37

protected function registered(Request $request, $user)
    {
        $this->guard()->logout();
        return redirect('/login')->with('status', 'We sent you an activation code. Check your email and click on the link to verify.');
    }
And my create method:
protected function create(array $data)
    {
        Session::flash('flash_message', "Thank You. Your Account Has Been Created.");
        return User::create([
            'usertype' => $data['usertype'],
            'username' => $data['username'],
            'first_name' => $data['first_name'],
            'last_name' => $data['last_name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);
        $activateUser = ActivateMe::create([
            'user_id' => $user->id,
            'token' => str_random(40)
        ]);
        Mail::to($user->email)->send(new ActivateMail($user));
        return $user;
}
What i need to fix it? Thanks!
17 Jan
1 year ago

NoneNameDeveloper left a reply on Redirect If Usertype Is Invalid | Laravel 5.5

@cameronscott137 no solution yet! I have null returned.

16 Jan
1 year ago

NoneNameDeveloper left a reply on Redirect If Usertype Is Invalid | Laravel 5.5

@cameronscott137 If I run dd($request->user()); returned null... Nothing also.

NoneNameDeveloper left a reply on Redirect If Usertype Is Invalid | Laravel 5.5

@cameronscott137 thanks, But when I running it I have that error: Trying to get property of non-object

…\app\Http\Middleware\CheckUserType.php:20 
I created it that: public function handle($request, Closure $next) {
    if($request->user()->usertype == "User") { 
   return $next($request); 
        // return the next request
    }
    flash()->error('OOPS! We did not found any user, Search valid user!');
    return redirect('/'); }

}

NoneNameDeveloper started a new conversation Redirect If Usertype Is Invalid | Laravel 5.5

I have some problem with redirecting to user profile. So I have this controller public function single_user($username) { $resume = User::where(array('usertype'=>'User','username'=>$username))->first(); if($resume->usertype=="Admin" or $resume->usertype=="Manager") { \Session::flash('flash_message', 'OOPS! We did not found any user, Search valid user!'); return redirect('/'); }

    return view('resumes.single_resume',compact('resume','educations','work_experiences','languages','skills','rcategories','ecategories'));
}
I need redirect if user type admin or manager when some one entered it?How can i do it? Thanks!
27 Dec
1 year ago

NoneNameDeveloper started a new conversation Send Email After Saving Data To Table | Laravel 5.5

I have creating newsletter and I need send email after saving user_email, user_name to newslatter table. So I have this controller, But i can't found idea for doing it.

public function addnew(Request $request)
{
$data =  \Input::except(array('_token')) ;
$rule=array(
'user_name' => 'required',
'user_email' => 'required',
); $validator = \Validator::make($data,$rule); if ($validator->fails()) { return redirect()->back()->withErrors($validator->messages()); } $inputs = $request->all();

    if(!empty($inputs['id'])){
       
        $newsletter = Subscribers::findOrFail($inputs['id']);

    }else{

        $newsletter = new Subscribers;

    }
    
    
    $newsletter ->user_name = $inputs['user_name'];
    $newsletter ->user_email= $inputs['user_email']; 
   
    $newsletter ->save();
    
    if(!empty($inputs['id'])){

        \Session::flash('flash_message', 'Changes Saved');
        return \Redirect::back();
    }else{
        \Session::flash('flash_message', 'Added');
        return \Redirect::back();

    }            
    
     
}  </pre></code>

I have no problem, Now problem is sand this data after saving to table to subscribed user. That, "Thanks you are subscribed to our newslatter"

24 Dec
1 year ago

NoneNameDeveloper left a reply on Problem With Find Out Category Name | Laravel 55

@tanmay_das thanks, but I did it for publish post, No other way for doing that? for example only {{ $category->category_name }} or {{ $category_name }}?

NoneNameDeveloper left a reply on Problem With Find Out Category Name | Laravel 55

@tanmay_das I me too {{ $categories->category_name }}, when i posting this question i wrote it mistake sorry, i fixed it.. No solution yet! If i run it {{ $categories->category_name }} i've Property [category_name] does not exist on this collection instance.

NoneNameDeveloper started a new conversation Problem With Find Out Category Name | Laravel 55

I have post by category, and i need display witch category name for this post. That, post category_id equal to category_name. So I have this controller:

public function single_post($post_slug,$post_id)    {
$post = Posts::where(array('status'=>'1','id'=>$post_id))->first();
$categories = Category::where('id', $post->category_id)->orderBy('category_name')->get();

    return view('posts.single_post',compact('post','categories'));
}</pre></code>

And if i run it in my blade i have some problem...

If I put it in blade
{{$jjtypes->jobtype_name}}
This error displayed
Property [category_name] does not exist on this collection instance.
If I put only
{{$jjtypes}}
It worked but like this:
In my blade That's look like
[{"id":3,"category_name":"Internship","category_slug":"internship","status":0}]

That's I need display category name in post blade.
21 Dec
1 year ago

NoneNameDeveloper started a new conversation Custom Helpers File Doesn't Work | Laravel 5.5

I have create my own helpers file, But it doesn't work. First I create helpers.php in app\http and after create I added it to composer.json, After adding own function, I saw only empty displey for my function, I created the function

if (! function_exists('getcong')) {
function getcong($key)
{
$settings = AppSettings::findOrFail('1');
return $settings->$key;
}
}

and my view blade is
@yield(getcong('site_name'))
But it doesn't show anything.... In my table added this columns